Skip to Content

issue with extracting the contents of a ZIP file

Hi All,

I am working on document management system. In our system, we can attach ZIP files to our project. I have the below requirement -

1. Get the ZIP file.

2. Explode/Unzip the ZIP folder.

3 Get all the files in the ZIP folder.

4. Attach all the files in the project.

5. Remove the original ZIP folder.

splice-data.png

Basically, I need to replace the ZIP file with its contents. If a ZIP folder has 5 files, then 5 files should be attached to the project, the original ZIP file should be removed. I have used the splice method of the class cl_abap_zip and I have got the below output. I am stuck at this point. I think this output only provides me the name of the files in the ZIP folder. I want to access these files, so I can attach them to the project. Can anyone help me with this ? Screenshot attached

splice-data.png (26.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 05, 2017 at 12:23 PM

    Use now the get method to read each file content.

     CREATE OBJECT lo_zip.
     CALL METHOD lo_zip->load
       EXPORTING
         zip = ls_zip_content.
     CALL METHOD lo_zip->splice
       EXPORTING
         zip     = ls_zip_content
       RECEIVING
         entries = lt_entries.
     LOOP AT lt_entries ASSIGNING <entry>.
       CALL METHOD lo_zip->get
         EXPORTING
           name    = <entry>-name
         IMPORTING
           content = ls_file_xstring.
     ENDLOOP.

    Regards,
    Raymond

    Add comment
    10|10000 characters needed characters exceeded