02-19-2010 4:07 PM
Hi,
Is there a way to read a zip file from the applicatoin server to internal table in ABAP program? The operation system is running MS windows server. The zip file contains only 1 text file. I tried to use open dataset 'uncompress', and use read dataset, but read dataset gave me sy-subrc = 4. Any feedback is greatly appreciated.
Thanks.
02-19-2010 4:43 PM
hi,
briefly, without error handling.
DATA zip TYPE REF TO cl_abap_zip.
DATA file_name TYPE string.
DATA zipped_data TYPE xstring.
DATA unzipped_data TYPE xstring.
OPEN DATASET file_name IN BINARY MODE FOR INPUT.
READ DATASET file_name INTO zipped_data.
*CLOSE DATASET file_name.
CREATE OBJECT zip.
zip->load( zipped_data ).
CALL METHOD zip->get
EXPORTING
index = 1 " first file in zip
IMPORTING
content = unzipped_data.
02-19-2010 4:37 PM
02-19-2010 4:43 PM
hi,
briefly, without error handling.
DATA zip TYPE REF TO cl_abap_zip.
DATA file_name TYPE string.
DATA zipped_data TYPE xstring.
DATA unzipped_data TYPE xstring.
OPEN DATASET file_name IN BINARY MODE FOR INPUT.
READ DATASET file_name INTO zipped_data.
*CLOSE DATASET file_name.
CREATE OBJECT zip.
zip->load( zipped_data ).
CALL METHOD zip->get
EXPORTING
index = 1 " first file in zip
IMPORTING
content = unzipped_data.
02-19-2010 5:45 PM
Thanks for the quick response.
I tested it, and I get the data from the zip file. And now how to I read the data as lines of character type? I'd like to read content of the data and populate it in the internal table.
Thanks
Lily
02-21-2010 2:22 AM
hi,
to convert xstring to text you can use this:
DATA unzipped_data TYPE xstring.
DATA text_data TYPE string.
DATA conv_x2c TYPE REF TO cl_abap_conv_in_ce.
conv_x2c = cl_abap_conv_in_ce=>create( ).
conv_x2c->convert( EXPORTING input = unzipped_data IMPORTING data = text_data ).
moreover, if you want to split your text at "end of line" (CR LF in microsoft windows) into lines:
DATA text_lines TYPE TABLE OF string.
SPLIT text_data AT cl_abap_char_utilities=>cr_lf INTO TABLE text_lines.
07-23-2010 7:01 AM
Some days ago I downloaded a film in zip archive. Today I have tried to watch it but I couldn't extract the archive. I saw an unknown error. My friend told me that he didn't know what to do next. I was distressed, but suddenly entered the Google and by chance found - <a href="http://www.recoverytoolbox.com/damaged_zip_file.html">damage zip</a>. The utility worked out my issue within seconds and totally free of charge as I kept in mind.