文件路径相关
CONSTANTS:
c_initial_folder TYPE string VALUE 'c:\', "起始目录
c_title TYPE string VALUE'选择文件存放目录'. "TITLE
CALL FUNCTION
'WS_FILENAME_GET'
EXPORTING
mask
= ',Excel
Files,*.xls,All Files,*.*.'(101)
title
=
'选择文件'(100)
IMPORTING
filename
= p_file
EXCEPTIONS
inv_winsys
= 1
no_batch
= 2
selection_cancel = 3
selection_error = 4
OTHERS
= 5.
IF sy-subrc <> 0 AND sy-subrc
<> 3.
MESSAGE e100(zdev) WITH
'选择文件出错!'(007).
ENDIF.
lo_mime LIKE w3mime,
lc_filename
TYPE string VALUE 'test01',
"默认文件名,用户可以修改
lc_path
TYPE string
,
"路径
lc_fullpath
TYPE string ,
"完整路径加名称
"保存下载的模板
CALL METHOD
cl_gui_frontend_services=>file_save_dialog "调用保存对话框
EXPORTING
default_extension = 'XLS'
"保存类型
default_file_name =
lc_filename
"文件名:test01
CHANGING
filename
=
lc_filename
"文件名
path
= lc_path
"地址,用户选择的时候赋值如d:\
fullpath
=
lc_fullpath
"文件路径:如d:\test01.xls
EXCEPTIONS
cntl_error
= 1
error_no_gui
= 2
not_supported_by_gui = 3
OTHERS
= 4.
IF lc_fullpath = ''.
MESSAGE
'不能打开excel' TYPE 'E'.
ENDIF.
*--------------------------------------------------------------------*
"获取文件保存路径
"获取文件保存路径
*--------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_s_dir.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = c_title "File Directory'
initial_folder = c_initial_folder "windows c盘为本地目录起点
CHANGING
selected_folder = l_localpath. "输入的本地下载目录
CALL METHOD cl_gui_cfw=>flush. "方法:Send Buffered Automation Queue to Front End
p_s_dir = l_localpath.
*--------------------------------------------------------------------*
"获取文件路径
AT
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_moban.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
dynpro_number = syst-dynnr
field_name = 'PATH'
IMPORTING
file_name = p_moban. "文件路径
AT
*--------------------------------------------------------------------*
获取文件路径
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
获取文件路径:下载时,弹出下载地址选择窗口
*--------------------------------------------------------------------*
DATA: lo_objdata LIKE
wwwdatatab,
另外有个函数可以校验文件是否存在
TMP_GUI_GET_FILE_EXIS
http://blog.sina.com.cn/sapliumeng