01-05-2017 11:15 AM
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.
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
01-05-2017 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
01-05-2017 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
01-06-2017 6:46 AM
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
01-06-2017 7:07 AM
Perform some search on SCMS_XSTRING_TO_BINARY, BAPI_DOCUMENT_CREATE2, CVAPI_DOC_CHECKIN or similiar FM/methods.