第一种: call method
FORM FORM_GET_FILE_PATH CHANGING O_PATH TYPE CHAR128.
DATA:
LTD_FILE_TABLE TYPE FILETABLE,
LW_RC TYPE I,
LW_ACTION TYPE I.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
CHANGING
FILE_TABLE = LTD_FILE_TABLE
RC = LW_RC
USER_ACTION = LW_ACTION.
IF SY-SUBRC = 0.
*- アップロードファイルはそれぞれの取得
PERFORM FORM_GET_FILE USING LTD_FILE_TABLE
CHANGING O_PATH.
ELSE.
*- 選択画面に戻る
MESSAGE E001.
ENDIF.
IF LW_ACTION = 9.
*- 選択画面に戻る
MESSAGE E001.
ELSE.
*- アップロードファイルはそれぞれの取得
PERFORM FORM_GET_FILE USING LTD_FILE_TABLE
CHANGING O_PATH.
ENDIF.
ENDFORM. " FORM_GET_FILE_PATH
FORM FORM_GET_FILE USING I_FILETABLE TYPE FILETABLE
CHANGING O_PATH TYPE CHAR128.
DATA:
LTH_FILETABLE LIKE LINE OF I_FILETABLE.
IF NOT I_FILETABLE IS INITIAL.
READ TABLE I_FILETABLE INTO LTH_FILETABLE INDEX 1.
IF SY-SUBRC = 0.
O_PATH = LTH_FILETABLE.
ENDIF.
ENDIF.
ENDFORM. " FORM_GET_FILE
第二种: call function
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = p_path