Code: Alles auswählen.
call method CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
exporting
WINDOW_TITLE = L_TITLE
DEFAULT_EXTENSION = 'CSV'
DEFAULT_FILENAME = M_FILENAME
* file_filter = cl_gui_frontend_services=>filetype_text
* WITH_ENCODING =
INITIAL_DIRECTORY = M_FILEPATH
MULTISELECTION = 'X'
changing
FILE_TABLE = LT_FILE
RC = L_RETURN
* USER_ACTION =
* FILE_ENCODING =
exceptions
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5.
Code: Alles auswählen.
* Pfad holen
call method CL_GUI_FRONTEND_SERVICES=>GET_UPLOAD_DOWNLOAD_PATH
changing
UPLOAD_PATH = M_FILEPATH
DOWNLOAD_PATH = L_DOWNLOADPATH
* EXCEPTIONS
* cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* gui_upload_download_path = 4
* upload_download_path_failed = 5
* others = 6
.
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.
if L_RETURN > 0.
loop at LT_FILE assigning <LT_FILE>.
* echten Dateinamen herausfinden
split <LT_FILE>-FILENAME at '\' into table LT_RESULT.
describe table LT_RESULT lines L_LINES.
* Wenn alles in einem gelandet ist, nochmal versuchen
if L_LINES = 1.
split <LT_FILE>-FILENAME at '/' into table LT_RESULT.
endif.
* ist überhaupt etwas vorhanden
describe table LT_RESULT lines L_LINES.
if L_LINES > 0.
* Letztes Stück ist der Dateiname
read table LT_RESULT assigning <LT_RESULT> index L_LINES.
if <LT_RESULT> is initial.
raise NO_FILE.
endif.
* ab in die Namenstabelle
append initial line to ET_FILE assigning <ET_FILE>.
<ET_FILE>-FILENAME = <LT_RESULT>.
M_FILENAME = <LT_RESULT>.
* Pfad aus der "Abholung" des Pfades
<ET_FILE>-FILEPATH = M_FILEPATH.
else.
raise NO_FILE.
endif.
endloop.
else.
raise NO_FILE.
endif.
Code: Alles auswählen.
call method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
exporting
FILENAME = L_FULL_FILENAME
* filetype = 'ASC'
* HAS_FIELD_SEPARATOR = SPACE
* HEADER_LENGTH = 0
READ_BY_LINE = 'X'
* DAT_MODE = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
importing
FILELENGTH = L_FILE_LENGTH
* HEADER =
changing
DATA_TAB = T_BDATARAW
exceptions
FILE_OPEN_ERROR = 1
...
others = 19
.
if SY-SUBRC > 0.
raise UPLOAD_FAILED.
endif.
Code: Alles auswählen.
data: et type table of string.
split I_BDATARAW at I_SEPARATOR into table ET.
Code: Alles auswählen.
field-symbols <et> like line of et.
read table et assigning <et> index SPALTENNUMMER.
....