Datei Download auf Client: Unterschied zwischen den Versionen
Aus SAP Wiki ツ
Die Seite wurde neu angelegt: „Kategorie:Codeschnipsel === Parameter der Methode === [--->] iv_data TYPE truxs_t_text_data [--->] iv_filename TYPE rlgrap-filename [EXC!] zcx_bc_b…“ |
|||
Zeile 7: | Zeile 7: | ||
=== Codeschnipsel === | === Codeschnipsel === | ||
<syntaxhighlight lang="abap" line start="1"> | |||
DATA: path TYPE string, | DATA: path TYPE string, | ||
path_file TYPE string, | path_file TYPE string, | ||
Zeile 74: | Zeile 74: | ||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. | WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. | ||
ENDIF. | ENDIF. | ||
</syntaxhighlight> |
Aktuelle Version vom 12. August 2021, 07:57 Uhr
Parameter der Methode
[--->] iv_data TYPE truxs_t_text_data [--->] iv_filename TYPE rlgrap-filename [EXC!] zcx_bc_basic.
Codeschnipsel
DATA: path TYPE string,
path_file TYPE string,
default_file_name TYPE string,
filename TYPE string,
windows_title TYPE string,
user_action TYPE i,
data TYPE truxs_t_text_data.
default_file_name = iv_filename.
filename = iv_filename.
windows_title = TEXT-002.
CHECK iv_data IS NOT INITIAL.
"Open dialog for saving and path for saving on client
cl_gui_frontend_services=>file_save_dialog( EXPORTING window_title = windows_title
default_file_name = default_file_name
default_extension = 'csv'
file_filter = '*.csv'
CHANGING filename = filename
path = path
fullpath = path_file
user_action = user_action
EXCEPTIONS cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
invalid_default_file_name = 4 ).
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_bc_basic
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CHECK user_action = cl_gui_frontend_services=>action_ok.
"Build file like read and save it to client path link
data = iv_data.
cl_gui_frontend_services=>gui_download( EXPORTING filename = path_file
CHANGING data_tab = data
EXCEPTIONS file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22 ).
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_bc_basic
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.