Skip to Content
0

issue with extracting the contents of a ZIP file

Jan 05, 2017 at 11:15 AM

156

avatar image

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Raymond Giuseppi
Jan 05, 2017 at 12:23 PM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

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

0