Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

issue with extracting the contents of a ZIP file

meenakshi_raina
Advisor
Advisor
0 Kudos

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

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

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

3 REPLIES 3

raymond_giuseppi
Active Contributor
0 Kudos

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

0 Kudos

Thanks Raymond.

I have used the Get method of this class. But it seems the individual file ( from the ZIP folder) is now in XSTRING format. Do you have any idea, how to upload this xstring data to server ?

Thanks and Regards

Meenakshi

0 Kudos

Perform some search on SCMS_XSTRING_TO_BINARY, BAPI_DOCUMENT_CREATE2, CVAPI_DOC_CHECKIN or similiar FM/methods.