Hello,
I am using CL_ABAP_ZIP to upload zipped archive (it's a XSLX with zipped XML's), modifying one of the contained files, zipping it back and downloading to PC. It is opened by Excel application, but with a message that it's a damaged archive (values inside are OK). If I rebuild/repair the archive by WINRAR, then everything is OK and message is not reported any more. I assume that it's the wrong CRC.
Here is my code:
lo_zip->get(
EXPORTING name = lc_shared_strings
IMPORTING content = l_xstr ).
*... change content of L_XSTR, get new L_NEW_SHARED_STRINGS_XSTR
lo_zip->delete( name = lc_shared_strings ).
lo_zip->add( name = lc_shared_strings
content = l_new_shared_strings_xstr ).
* get ZIP content as XSTRING
l_xstr = lo_zip->save( ).
* save ZIP file to PC
CLEAR gt_upload.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = l_xstr
TABLES
binary_tab = gt_upload.
cl_gui_frontend_services=>gui_download(
EXPORTING filename = p_file
filetype = 'BIN'
* IMPORTING filelength = g_len
CHANGING data_tab = gt_upload
EXCEPTIONS OTHERS = 19 ).
I also tried another approach: take what I needed from the original ZIP and re-pack it into another:
lo_zip->delete( name = lc_shared_strings ).
l_xstr_old = lo_zip->save( ).
lt_splice = lo_zip->splice( l_xstr_old ).
CREATE OBJECT lo_new_zip.
LOOP AT lt_splice ASSIGNING <ls_splice>.
lo_zip->get( EXPORTING name = <ls_splice>-name
IMPORTING content = l_xstr_old ).
lo_new_zip->add( name = <ls_splice>-name
content = l_xstr_old ).
ENDLOOP.
lo_new_zip->add( name = lc_shared_strings
content = l_shared_strings_xstr ).
l_xstr = lo_new_zip->save( ).
*... save file to PC
The result was the same.
There is also a method CL_ABAP_ZIP=>CRC32 which returns integer CRC for given XSTRING, but I don't know how what to do with it (if anything).
I also found the following fourm posts claiming that the CRC is taken care of by CL_ABAP_ZIP:
1. [abap gzip zip|abap gzip zip;
2. [zip binary data and save zip file to disk at bsp|zip binary data and save zip file to disk at bsp;
3. [How to Zip the data in an internal table|How to Zip the data in an internal table;
They all suggest that it's as simple as my example above, but still, there's something wrong with my solution.
What could be wrong with my ZIP?
Thanks!
KR,
Igor