in src/zgoog_i_bqtr_gen_repl_obj_im2.prog.abap [0:0]
METHOD download_template.
TYPES: BEGIN OF lty_template,
trkey TYPE string,
dsnam TYPE string,
cds TYPE string,
logsy TYPE string,
appl TYPE string,
adso TYPE string,
chain TYPE string,
trig TYPE string,
info TYPE string,
mfnam TYPE string,
active TYPE string,
END OF lty_template.
DATA: lv_file TYPE string,
lv_csv_file TYPE rlgrap-filename,
lv_msg TYPE string,
ls_template TYPE lty_template,
lt_template TYPE STANDARD TABLE OF lty_template.
ls_template-trkey = 'Transfer Key'.
ls_template-dsnam = 'Datasource name'.
ls_template-cds = 'CDS View Name'.
ls_template-logsy = 'Logical System'.
ls_template-appl = 'Application Component'.
ls_template-adso = 'ADSO Name'.
ls_template-chain = 'Process Chain Name'.
ls_template-trig = 'Trigger Name'.
ls_template-info = 'Infoarea'.
ls_template-mfnam = 'MANDT Field Name'.
ls_template-active = 'Activate Process chain'.
APPEND ls_template TO lt_template.
DATA: lt_csv_converted_table TYPE truxs_t_text_data.
lv_csv_file = p_dpath && '\' && 'bw_gen_template.csv'.
DATA: lv_csv_line TYPE c LENGTH 4096.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE ls_template TO FIELD-SYMBOL(<lv_field_name>).
IF sy-subrc IS NOT INITIAL.
EXIT.
ENDIF.
IF lv_csv_line IS INITIAL.
lv_csv_line = <lv_field_name>.
ELSE.
lv_csv_line = lv_csv_line && ',' && <lv_field_name>.
ENDIF.
ENDDO.
APPEND lv_csv_line TO lt_csv_converted_table.
lv_file = lv_csv_file.
cl_gui_frontend_services=>gui_download(
EXPORTING
filename = lv_file " Name of file
CHANGING
data_tab = lt_csv_converted_table " Transfer table
EXCEPTIONS
file_write_error = 1 " Cannot write to file
no_batch = 2 " Front-End Function Cannot Be Executed in Backgrnd
gui_refuse_filetransfer = 3 " Incorrect Front End
invalid_type = 4 " Invalid value for parameter FILETYPE
no_authority = 5 " No Download Authorization
unknown_error = 6 " Unknown error
header_not_allowed = 7 " Invalid header
separator_not_allowed = 8 " Invalid separator
filesize_not_allowed = 9 " Invalid file size
header_too_long = 10 " Header information currently restricted to 1023 bytes
dp_error_create = 11 " Cannot create DataProvider
dp_error_send = 12 " Error Sending Data with DataProvider
dp_error_write = 13 " Error Writing Data with DataProvider
unknown_dp_error = 14 " Error when calling data provider
access_denied = 15 " Access to File Denied
dp_out_of_memory = 16 " Not Enough Memory in DataProvider
disk_full = 17 " Storage Medium full
dp_timeout = 18 " Timeout of DataProvider
file_not_found = 19 " Could not find file
dataprovider_exception = 20 " General Exception Error in DataProvider
control_flush_error = 21 " Error in Control Framework
not_supported_by_gui = 22 " GUI does not support this
error_no_gui = 23 " GUI not available
OTHERS = 24
).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
lv_msg = |Template { lv_file } was successfully downloaded!|.
MESSAGE lv_msg TYPE 'S'.