Code: Alles auswählen.
call function 'SAP_CONVERT_TO_XLS_FORMAT'
exporting
i_field_seperator = '#'
i_line_header = 'X'
i_filename = lv_filename
I_APPL_KEEP = ' '
tables
i_tab_sap_data = gt_ausgabe
* CHANGING
* I_TAB_CONVERTED_DATA =
exceptions
conversion_failed = 1
others = 2.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
" Hiermit soll die Datei auf die Festplatte gespeichert werden.
cl_gui_frontend_services=>gui_download(
exporting
filename = p_file2
changing
data_tab = i_tab_converted_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
not_supported_by_gui = 22
error_no_gui = 23
others = 24 ).
if sy-subrc <> 0.
MESSAGE 'Die Datei konnte leider nicht gespeichert werden!' TYPE 'I' DISPLAY LIKE 'I'.
endif.
endif.
Code: Alles auswählen.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
i_field_seperator = ';'
TABLES
i_tab_sap_data = gt_ausgabe
CHANGING
i_tab_converted_data = i_tab_converted_data
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Code: Alles auswählen.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
* i_field_seperator =
* i_line_header =
i_filename = `C:\Temp\Zieldatei.xls`
* i_appl_keep = space
TABLES
i_tab_sap_data = i_tab
* CHANGING
* i_tab_converted_data =
* EXCEPTIONS
* conversion_failed = 1
* others = 2
.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Code: Alles auswählen.
SELECT * FROM t000 INTO TABLE @DATA(clients_tab).
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
i_field_seperator = cl_abap_char_utilities=>horizontal_tab
i_line_header = 'X'
i_filename = 'c:\temp\test.xls'
* I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = clients_tab
* CHANGING
* I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2 .