Announcement:
wanna exchange links? contact me at sapchatroom@gmail.com.
Posted by
Admin at
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). What could be wrong with my ZIP? Thanks! KR, Igor | __.____._ Copyright © 2011 Toolbox.com and message author. Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251 | | Most Popular White Papers In the Spotlight _.____.__ |