Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Download zip file from Al11 to presentation layer

2,063

Hi All,

I am trying to download zip file in zip format. But the downloaded file is corrupted. I am able to download unzipped files separately.

Has anyone achieved downloading zip file in zip format to your pc from application server?

4 REPLIES 4

FredericGirod
Active Contributor
1,253

Did you specify to download it in binary mode ?

Sandra_Rossi
Active Contributor
0 Kudos
1,253

It's not difficult, just use binary mode, indicate the number of bytes to write, and conversion from xstring to table of bytes can be done for instance with CL_BCS_CONVERT=>XSTRING_TO_SOLIX.

Former Member
0 Kudos
1,253
DATA zipped_data TYPE xstring.

DATA unzipped_data TYPE xstring.
DATA conv_x2c TYPE REF TO cl_abap_conv_in_ce.
DATA lt_csv_data TYPE stringtab.
OPEN DATASET path FOR INPUT IN TEXT MODE ENCODING UTF-8.
READ DATASET path INTO zipped_data.

CLOSE DATASET path.

CREATE OBJECT zip.

zip->load( zipped_data ).

CALL METHOD zip->get
EXPORTING
index = 1 " first file in zip
IMPORTING
content = unzipped_data.

conv_x2c = cl_abap_conv_in_ce=>create( ).
conv_x2c->convert( EXPORTING input = unzipped_data IMPORTING data = ls_file_data ).

then I have called GUI_DOWNLOAD

it is getting downloaded as zip folder and inside it one file with corrupted data is there ..

Former Member
0 Kudos
1,253

Closing thread. Found the solution.
after reading the zip file divide it by 1024 type

DESCRIBE FIELD zip_data LENGTH xchunk IN BYTE MODE.
xlength = xstrlen( zipped_data ).
xlines = xlength DIV xchunk.
DO xlines TIMES.
zip_data = zipped_data+xoffset(xchunk).
APPEND zip_data TO zip_data.
xoffset = xoffset + xchunk.
ENDDO.

IF xoffset < xlength.
zip_data = zipped_data+xoffset.
APPEND zip_data TO zip_data.

ENDIF.