Warning: Parameter 2 to qtranxf_postsFilter() expected to be a reference, value given in /www/htdocs/w01362c7/dev-workbench.com/wp-includes/class-wp-hook.php on line 298
Create and Download a File from ABAP - Page 2 of 2 - SAP Developer Workbench

Create and Download a File from ABAP

DevWorkbench    Sunday August 24th, 2014   

REPORT zdemofiledownload.
DATA gv_filename TYPE string.
DATA gv_path TYPE string.
DATA gv_fullpath TYPE string.
DATA gv_useraction TYPE i.
DATA gt_data TYPE TABLE OF string.
DATA gv_data TYPE string.
* Add some data to the table
gv_data 'All your base'.
APPEND gv_data TO gt_data.
gv_data 'are belong to us'.
APPEND gv_data TO gt_data.
* Show the file download dialog
CALL METHOD cl_gui_frontend_services=>file_save_dialog
    default_file_name    'file.txt'
    default_extension    'TXT'
    filename             gv_filename
    path                 gv_path
    fullpath             gv_fullpath
    user_action          gv_useraction
    cntl_error           1
    error_no_gui         2
    not_supported_by_gui 3
    OTHERS               4.
* Check if the user clicked OK
IF gv_useraction <> 0.
* Do the actual download
CALL METHOD cl_gui_frontend_services=>gui_download
    filename gv_filename
    data_tab gt_data
    OTHERS   24.