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
Menu

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
  EXPORTING
    default_file_name    'file.txt'
    default_extension    'TXT'
  CHANGING
    filename             gv_filename
    path                 gv_path
    fullpath             gv_fullpath
    user_action          gv_useraction
  EXCEPTIONS
    cntl_error           1
    error_no_gui         2
    not_supported_by_gui 3
    OTHERS               4.
 
* Check if the user clicked OK
IF gv_useraction <> 0.
  EXIT.
ENDIF.
 
* Do the actual download
CALL METHOD cl_gui_frontend_services=>gui_download
  EXPORTING
    filename gv_filename
  CHANGING
    data_tab gt_data
  EXCEPTIONS
    OTHERS   24.