Google Search - Blog...........

ABAP - Read A File From Directory Using cl_gui_frontend_services Method

REPORT zread_a_file.

DATA: v_rc TYPE i.
DATA: lt_filetab TYPE filetable.
DATA: ls_filetab LIKE LINE OF lt_filetab.

PARAMETERS: p_file TYPE localfile.

AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.

CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_filetab
rc = v_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.

READ TABLE lt_filetab INTO ls_filetab INDEX 1.
IF sy-subrc = 0.
p_file = ls_filetab-filename.
ENDIF.

No comments:

Post a Comment