Code: Alles auswählen.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'DEIN PFAD'
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
tables
data_tab = DEINE_IT
Code: Alles auswählen.
REPORT z_test.
TABLES: kna1.
PARAMETERS: go AS CHECKBOX.
TYPES:
t_cfield(1024) TYPE c,
BEGIN OF t_line,
name2 TYPE anred,
name1 TYPE name1,
END OF t_line.
DATA:
b_ret TYPE c,
n_action TYPE i,
n_filelen TYPE i,
rc TYPE i,
tbl_files TYPE filetable,
s_filename TYPE string,
s_path TYPE string,
s_fullpath TYPE string,
x_header TYPE xstring,
str_line TYPE t_line,
tbl_lines TYPE STANDARD TABLE OF t_line,
obj_feservices TYPE REF TO cl_gui_frontend_services.
START-OF-SELECTION.
CHECK go = 'X'.
SELECT name2 name1 FROM kna1
INTO CORRESPONDING FIELDS OF TABLE tbl_lines UP TO 20 ROWS.
* Erzeugen des Objektes
* Bem: Da nur statische Methoden genutzt werden, ist
* es nicht zwingend erforderlich
CREATE OBJECT obj_feservices.
* Selektionsdialog
CALL METHOD obj_feservices->file_open_dialog
EXPORTING
window_title = 'Öffnen einer txt-Datei'
file_filter = obj_feservices->FILETYPE_EXCEL
initial_directory = 'C:\'
multiselection = abap_false
CHANGING
file_table = tbl_files
rc = rc
user_action = n_action
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
file_open_dialog_failed = 4
OTHERS = 1.
* Wenn 'ok' gewählt und eine Datei selektiert ist
IF n_action = obj_feservices->action_ok AND rc = 1 .
* Ermitteln des Dateinamens
read table tbl_files index 1 into s_filename.
*Interne Tabelle als TXT-File speichern
CALL METHOD obj_feservices->gui_download
EXPORTING
filename = s_filename
filetype = 'ASC'
append = abap_false
write_field_separator = abap_true
IMPORTING
filelength = n_filelen
CHANGING
data_tab = tbl_lines
EXCEPTIONS
file_write_error = 1
no_authority = 2
not_supported_by_gui = 3
error_no_gui = 4
OTHERS = 5.
ENDIF.