Downloading Internal Table as a ZIP file on the Presentation Server

DATA lt TYPE TABLE OF scarr,
ls TYPE scarr,
lv_string TYPE string,
lv_xstring TYPE xstring,
lr_zip TYPE REF TO cl_abap_zip,
lt_bin TYPE TABLE OF x255.

START-OF-SELECTION.
  SELECT FROM scarr INTO TABLE lt.
  LOOP AT lt INTO ls.
    CONCATENATE lv_string ls INTO lv_string SEPARATED BY cl_abap_char_utilities=>newline.
  ENDLOOP.

* Convert String to X String
CALL FUNCTION ‘SCMS_STRING_TO_XSTRING’
EXPORTING
text   lv_string
IMPORTING
buffer lv_xstring.

CREATE OBJECT lr_zip.
* Add teh X String as a Zip file
CALL METHOD lr_zip->add
EXPORTING
name    ‘flight’
content lv_xstring.

CALL METHOD lr_zip->save
RECEIVING
zip lv_xstring.


* Convert Xstring to Binary Table
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer     lv_xstring
TABLES
binary_tab lt_bin.


* Download the Binary table
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename ‘C:\FLIGHT\FLIGHT.ZIP’
filetype ‘BIN’
TABLES
data_tab lt_bin.
IF sysubrc IS INITIAL.
MESSAGE ‘check the zip file in the location: C:\FLIGHT\’ TYPE ‘I’.
ENDIF.


 

Execute the program.

Check the location.


 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s