ABAP文件選擇框函數

由於WS_FILENAME_GET已經被廢棄因此使用接口CL_GUI_FRONTEND_SERVICES來實現本地文件的選擇.spa

用接口類CL_GUI_FRONTEND_SERVICES實現的方法接口

 


 

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOGfile

EXPORTING方法

WINDOW_TITLE = '選擇'di

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返回選擇目錄

如圖:

相關文章
相關標籤/搜索