|
本帖最后由 bgx5810 于 2010-2-2 10:48 编辑
文件打开的选择DIALOG
REPORT FILEOPENDIALOG.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME.
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
************************************************************************
PERFORM OPEN_FILENM.
*&---------------------------------------------------------------------*
*& Form OPEN_FILENM
*&---------------------------------------------------------------------*
* DIALOG打开
*----------------------------------------------------------------------*
FORM OPEN_FILENM.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
* EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
* INITIAL_DIRECTORY =
* MULTISELECTION =
CHANGING
FILE_TABLE = FILE_TABLE
RC = RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC = 0.
READ TABLE FILE_TABLE INTO FILE INDEX 1.
P_FILE = FILE-FILENAME.
ENDIF.
ENDFORM.
这个时候你所取得的P_FILE是路径加文件名的。
如果想单独得到文件名或者路径可以再调用以下方法
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
FULL_NAME = P_FILE
IMPORTING
STRIPPED_NAME = STRIPPED_NAME
FILE_PATH = FILE_PATH
EXCEPTIONS
X_ERROR = 1
OTHERS = 2.
以上方法的返回值:
STRIPPED_NAME是你所选的文件的文件名。
FILE_PATH是你所选的文件的路径。 |
|