弹出保存文件、打开文件对话框
PARAMETERS : p_file LIKE rlgrap - filename OBLIGATORY .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file . " 弹出选择文件对话框
CALL FUNCTION
'
WS_FILENAME_GET
'
EXPORTING
* DEF_FILENAME = ' '
def_path
=
'C:\'
"Structure of MASK: ,<text>,<FILTERGROUP>.
"Structure of FILTERGROUP: <filter>;<filter>*
mask
=
',Excel File,*.xls;*.xlsx;*.txt.'
title
=
'Window Title:
请选择文件
'
"
弹出框的模式
S --
用来保存文件
O --
用来打开文件
MODE
=
'S'
IMPORTING
filename
=
p_file
* RC
=
EXCEPTIONS
INV_WINSYS
=
1
NO_BATCH
=
2
SELECTION_CANCEL
=
3
"
如果用户取消了对话框
SELECTION_ERROR
=
4
OTHERS
=
5
.
上面函数已过时,可以分别是使用以下两个方法代替:
DATA
:
l_obj
TYPE REF TO
cl_gui_frontend_services
.
CREATE
OBJECT l_obj
.
CALL METHOD
l_obj
->
file_open_dialog
EXPORTING
file_filter
=
'.txt'
initial_directory
=
'C:\data'
CHANGING
file_table
=
it_file
rc
=
l_rc
.
DATA
:
l_obj
TYPE REF TO
cl_gui_frontend_services
.
CREATE
OBJECT l_obj
.
CALL METHOD
l_obj
->
file_save_dialog
EXPORTING
file_filter
=
'.pdf'
initial_directory
=
'C:\data'
CHANGING
filename
=
l_name
path
=
l_path
fullpath
=
l_fpath
user_action
=
l_rc
.