Application Development and Automation 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: 
Read only

CL_ABAP_ZIP creates empty ZIP-file

Former Member
0 Likes
1,181

Hello togehter,

I want to ZIP an ABAP created XML-File into a ZIP file. The ZIP-File I created has a couple MB but doesn't have any file inside.

If I does not ZIP the XML will be created the right way.

What is wrong in the code below?

data : lv_zip_file type xstring,

lv_xml type xstring,

lv_binary type xstring,

lv_binary_tab type xstring_table,

lr_zip type ref to cl_abap_zip.

  • This Table does have content

loop at lt_table assigning <tablename>.

ls_line-tablename = <tablename>.

create data lr_data type table of (ls_line-tablename).

assign lr_data->* to <data>.

select * from (ls_line-tablename) into table <data>.

call transformation id

source data = <data>

result xml ls_line-tabledata.

append ls_line to et_data.

endloop.

call transformation id

source data = et_data

result xml l_string.

create object lr_zip.

call function 'ECATT_CONV_STRING_TO_XSTRING'

exporting

im_string = l_string

importing

ex_xstring = lv_xml.

call function 'SCMS_XSTRING_TO_BINARY'

exporting

buffer = lv_xml

tables

binary_tab = lv_binary_tab.

lr_zip->add( name = iv_filename

content = lv_xml ).

  • Create a new zip file

lv_zip_file = lr_zip->save( ).

append lv_zip_file to lv_binary_tab.

cl_gui_frontend_services=>gui_download(

exporting

filename = l_file

filetype = 'BIN'

changing

data_tab = lv_binary_tab ).

Hello togehter,

I want to ZIP an ABAP created XML-File into a ZIP file. The ZIP-File I created has a couple MB but doesn't have any file inside.

If I does not ZIP the XML will be created the right way.

What is wrong in the code below?

data : lv_zip_file type xstring,

lv_xml type xstring,

lv_binary type xstring,

lv_binary_tab type xstring_table,

lr_zip type ref to cl_abap_zip.

  • This Table does have content

loop at lt_table assigning <tablename>.

ls_line-tablename = <tablename>.

create data lr_data type table of (ls_line-tablename).

assign lr_data->* to <data>.

select * from (ls_line-tablename) into table <data>.

call transformation id

source data = <data>

result xml ls_line-tabledata.

append ls_line to et_data.

endloop.

call transformation id

source data = et_data

result xml l_string.

create object lr_zip.

call function 'ECATT_CONV_STRING_TO_XSTRING'

exporting

im_string = l_string

importing

ex_xstring = lv_xml.

call function 'SCMS_XSTRING_TO_BINARY'

exporting

buffer = lv_xml

tables

binary_tab = lv_binary_tab.

lr_zip->add( name = iv_filename

content = lv_xml ).

  • Create a new zip file

lv_zip_file = lr_zip->save( ).

append lv_zip_file to lv_binary_tab.

cl_gui_frontend_services=>gui_download(

exporting

filename = l_file

filetype = 'BIN'

changing

data_tab = lv_binary_tab ).

4 REPLIES 4
Read only

Former Member
0 Likes
882

Problem was fixed.

Read only

0 Likes
882

please tell me how your problem is solved.because i am facing the same problem now.its urgent.

Read only

0 Likes
882

The problem may be releated with non-ascii filenames inside zip. See my post []

Read only

Former Member
0 Likes
882

In my case it was because I had my filename as blank, when adding each file. Ended up with obviously an empty zip file.