最近领导要求开发一个文件上载程序,好久不写了,手生了,就又拿起WS_UPLOAD开始写,但好像多了个提示,过期了。
懒是偷不成只能用类CL_GUI_FRONTEND_SERVICES,不过这玩意我真说不明白,直接上例子吧还是。
REPORT ZHAO00001.
懒是偷不成只能用类CL_GUI_FRONTEND_SERVICES,不过这玩意我真说不明白,直接上例子吧还是。
REPORT ZHAO00001.
DATA: FILENAME TYPE STRING VALUE 'c:bathinput.csv'.
TYPES: BEGIN OF ITAB,
F(20),
END OF ITAB.
DATA: DATA_TAB TYPE STANDARD TABLE OF ITAB.
DATA: WA_TAB TYPE ITAB.
DATA: FILE_FILTER TYPE STRING,
RC TYPE I.
DATA: FILE_TABLE TYPE FILETABLE.
DATA: WA_FILE_TABLE TYPE LINE OF FILETABLE.
FILE_FILTER = 'All Files (*.*)|*.csv'.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'WINDOW_TITLE'
DEFAULT_EXTENSION = '*.CSV'
DEFAULT_FILENAME = 'BatchInput.csv'
FILE_FILTER = FILE_FILTER
INITIAL_DIRECTORY = 'c:\'
MULTISELECTION = 'X'
CHANGING
FILE_TABLE = FILE_TABLE
RC = RC
.
LOOP AT FILE_TABLE INTO WA_FILE_TABLE.
FILENAME = WA_FILE_TABLE-FILENAME.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = FILENAME
FILETYPE = 'DAT'
DAT_MODE = 'X'
CHANGING
DATA_TAB = DATA_TAB
.
IF SY-SUBRC <> 0.
WRITE:/ 'failure'.
ELSE.
LOOP AT DATA_TAB INTO WA_TAB.
WRITE:/ WA_TAB-F.
ENDLOOP.
ENDIF.
ENDLOOP.
据说这个类能实现所有的在客户端的操作,功能强大啊!
据说这个类能实现所有的在客户端的操作,功能强大啊!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9859323/viewspace-711016/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9859323/viewspace-711016/