2018 Oct 17 7:51 PM
Hi, My requirement is to zip a file and then zip that into another folder with few more files and place it on App Server. I could do the first zip, but couldn't figure out how to do nested zip. Please help if anyone has done it before.
Example:
1. Zip files A, B, C into Zipper1.zip
2. Zip Zipper1.zip, D, E, F into Zipper2.zip
3. Write Zipper2.zip onto App Server
Thanks,
Murali.
2018 Oct 18 12:26 PM
You can v_zip->add( ) any xstring data (content) to ZIP. Even the v_zipcontent which you got from v_zip->save( ). Just make sure you do not use same cl_abap_zip object instance (basic OOP).
Hi, My requirement is to zip a file and then zip that into another folder with few more files and place it on App Server. I could do the first zip, but couldn't figure out how to do nested zip. Please help if anyone has done it before.
Example:
1. Zip files A, B, C into Zipper1.zip
2. Zip Zipper1.zip, D, E, F into Zipper2.zip
3. Write Zipper2.zip onto App Server
Thanks,
Murali.
2018 Oct 18 3:34 AM
Hi,
Not sure why 2 times zipped. I think the logic for first zip will work with files only and the same can not be used to zip - zipped file along with other file.
Technically, you are doing zip for A,B,C,D,E,F..then why not single zip for all these?
Thanks,
Mohan
2018 Oct 18 11:20 AM
Sorry No, I am not doing all the files in a single zip.
My requirement for 3rd party is to generate a zip file which contains "1 zip file with n number of files + some more files".
This is the requirement. If I have to zip all in one zip then I could have done it.
Thanks,
Murali.
2018 Oct 18 7:46 AM
What is there to figure out? Second level of archiving is same like first or any other.
Where exactly you have problem?
2018 Oct 18 8:00 AM
2018 Oct 18 11:25 AM
I will share how to zip(including nested zip) once I am done with my development.
Thanks,
Murali
2018 Oct 18 11:45 AM
"I will share how to zip(including nested zip) once I am done with my development."
You say you've done the first zip. The reason I wanted to see that was that it might give a hint as to why you're finding doing the second zip difficult. A Tomas Buryanek points out - what is there to figure out?
2018 Oct 18 12:04 PM
Here is the code for the first zip. It generated Test.zip on the Application Server.
*>>>>>>
REPORT ztest_zip.
PARAMETERS: p_file TYPE localfile.
TYPES: BEGIN OF type_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
END OF type_ekpo.
TYPES: type_t_ekpo TYPE STANDARD TABLE OF type_ekpo,
type_t_rec TYPE STANDARD TABLE OF sdokcntasc.
DATA: t_ekpo TYPE type_t_ekpo,
t_rec TYPE type_t_rec,
t_zipdata TYPE TABLE OF x255,
w_ekpo TYPE type_ekpo,
w_rec TYPE sdokcntasc,
w_zipdata TYPE x255.
DATA: v_date TYPE sy-datum,
v_zipcontent TYPE xstring,
v_zipcontent1 TYPE xstring,
v_zipfile TYPE string VALUE 'Test.zip',
v_content TYPE xstring,
v_xstr TYPE xstring,
v_name TYPE string,
v_filelength TYPE i,
v_zip TYPE REF TO cl_abap_zip.
v_date = sy-datum - 7.
SELECT ebeln
ebelp
FROM ekpo
INTO TABLE t_ekpo
WHERE aedat >= v_date.
CLEAR: w_rec.
CONCATENATE 'Purchase Order#'
'Item #'
INTO w_rec-line
SEPARATED BY ','.
APPEND w_rec TO t_rec.
CLEAR w_rec.
LOOP AT t_ekpo INTO w_ekpo.
CONCATENATE w_ekpo-ebeln
w_ekpo-ebelp
INTO w_rec-line
SEPARATED BY ','.
APPEND w_rec TO t_rec.
CLEAR w_rec.
ENDLOOP.
CLEAR v_content.
CREATE OBJECT v_zip.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
IMPORTING
buffer = v_xstr
TABLES
text_tab = t_rec
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc = 0.
REFRESH: t_rec.
FREE: t_rec.
ENDIF.
v_name = 'Test.csv'.
v_zip->add( name = v_name content = v_xstr ).
v_zipcontent = v_zip->save( ).
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = v_zipcontent
IMPORTING
output_length = v_filelength
TABLES
binary_tab = t_zipdata.
CONCATENATE p_file
v_zipfile
INTO v_zipfile
SEPARATED BY '/'.
OPEN DATASET v_zipfile FOR OUTPUT IN BINARY MODE.
LOOP AT t_zipdata INTO w_zipdata.
TRANSFER w_zipdata TO v_zipfile.
ENDLOOP.
CLOSE DATASET v_zipfile.
*<<<<<<
2018 Oct 18 12:26 PM
You can v_zip->add( ) any xstring data (content) to ZIP. Even the v_zipcontent which you got from v_zip->save( ). Just make sure you do not use same cl_abap_zip object instance (basic OOP).
2018 Oct 18 12:48 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |