DATA: it_file_table TYPE filetable.
DATA: s_file_table TYPE file_table.
DATA: lv_file_count TYPE i.
DATA: lv_folder TYPE string VALUE 'C:\'.
cl_gui_frontend_services=>directory_list_files(
EXPORTING
directory = lv_folder " Verzeichnis
filter = '*.*' " Dateifilter
files_only = abap_false " nur Dateien listen
directories_only = abap_false " nur Verzeichnisse listen
CHANGING
file_table = it_file_table
count = lv_file_count
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6 ).
IF sy-subrc = 0.
WRITE: / 'Anzahl Directory + Files: ', lv_file_count.
WRITE: /.
WRITE: / 'Directory:'.
WRITE: / '----------'.
LOOP AT it_file_table INTO s_file_table.
WRITE: / s_file_table-filename.
ENDLOOP.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.