Skip to Content
author's profile photo Former Member
Former Member

How to use CL_ABAP_ZIP?

Hi Experts,

We have two separate files (Header & item) in the application server then the two files need to be zipped in one zip-file and needs to be stored on the Application server.

I found related class CL_ABAP_ZIP which will serves this purpose. But by using this how can i achive my solution?

If you have any other ideas about this requirement. Please share with me.

Thanks,

Satish

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 09:08 PM

    Satish,

    REPORT Z_ZIP_IT.

    TYPES:

    t_xline(2048) TYPE x, "BINARY FILES

    BEGIN OF t_line,

    line(1024) TYPE c,

    END OF t_line. "CONTENT

    DATA:

    size type i.

    DATA:

    data_tab TYPE STANDARD TABLE OF t_xline,

    text_tab TYPE STANDARD TABLE OF t_line,.

    DATA:

    input_x type xstring, "BINARY CONTENT INPUT

    output_x type xstring. "BINARY OUTPUT OUTPUT

    data : CL_ZIP type ref to CL_ABAP_ZIP .

    DATA files LIKE LINE OF obj_clabapzip->files.

    DATA:

    name type string.

    name = 'Example.txt'. "<-- Insert full path!

    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD

    EXPORTING

    FILENAME = name

    FILETYPE = 'BIN'

    IMPORTING

    FILELENGTH = size

    CHANGING

    DATA_TAB = data_tab.

    CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

    EXPORTING

    INPUT_LENGTH = size

    IMPORTING

    BUFFER = input_x

    TABLES

    BINARY_TAB = data_tab.

    CREATE OBJECT cl_zip.

    cl_zip->ADD(

    EXPORTING

    NAME = name

    CONTENT = input_x

    )

    .

    cl_zip->SAVE(

    RECEIVING

    ZIP = output_x

    )

    .

    REFRESH data_tab.

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

    EXPORTING

    BUFFER = output_x

    IMPORTING

    OUTPUT_LENGTH = size

    TABLES

    BINARY_TAB = data_tab

    .

    DATA:

    lw_output_path TYPE string.

    output_path = 'c:\myfile.zip':

    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

    EXPORTING

    BIN_FILESIZE = size

    FILENAME = output_path

    FILETYPE = 'BIN'

    CHANGING

    DATA_TAB = data_tab

    .

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 20, 2007 at 09:02 PM

    Hi,

    Are you referring to class CL_ABAP_GZIP?

    If you are, please check this weblog.

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c6b79908-0a01-0010-8ca0-b77aff37726d

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.