首页 > 代码库 > ABAP文件选择框函数

ABAP文件选择框函数

因为WS_FILENAME_GET已经被废弃所以使用接口CL_GUI_FRONTEND_SERVICES来实现本地文件的选择.

用接口类CL_GUI_FRONTEND_SERVICES实现的方法

 


 

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

EXPORTING

WINDOW_TITLE = ‘选择‘

DEFAULT_EXTENSION = ‘XLS‘

DEFAULT_FILENAME = ‘defaultfilename‘

FILE_FILTER = ‘Excel文件(*.XLS)|*.XLS|全部文件 (*.*)|*.*|‘

* INITIAL_DIRECTORY =

* MULTISELECTION =

* WITH_ENCODING =

CHANGING

FILE_TABLE = g_text

RC = rc

* USER_ACTION =

* FILE_ENCODING =

* EXCEPTIONS

* FILE_OPEN_DIALOG_FAILED = 1

* CNTL_ERROR = 2

* ERROR_NO_GUI = 3

* NOT_SUPPORTED_BY_GUI = 4

* others = 5

.

如图

 

 

接口CL_GUI_FRONTEND_SERVICES 的其他几个常用方法:

 


 

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

EXPORTING

FILE = LW_FILE

RECEIVING

RESULT = LW_RESULT

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

WRONG_PARAMETER = 3

NOT_SUPPORTED_BY_GUI = 4

OTHERS = 5.

 


CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST

EXPORTING

DIRECTORY = LW_PATH

RECEIVING

RESULT = LW_RESULT

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

WRONG_PARAMETER = 3

NOT_SUPPORTED_BY_GUI = 4

OTHERS = 5.


CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

EXPORTING

WINDOW_TITLE = LW_TITLE

CHANGING

FILENAME = LW_FILENAME

PATH = LW_PATH

FULLPATH = LW_FULLPATH

USER_ACTION = LW_ACTION

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

NOT_SUPPORTED_BY_GUI = 3

OTHERS = 4.

 


 

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE

EXPORTING

WINDOW_TITLE = ‘选择一个路径‘

INITIAL_FOLDER = ‘Z:\‘

CHANGING

SELECTED_FOLDER = lw_folder

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

NOT_SUPPORTED_BY_GUI = 3

others = 4

.


方法描述:弹出选择目录对话框

SELECTED_FOLDER返回选择目录

如图: