ABAP文件上传下载 用SMW0
以excel举例
smw0事物代码进入传输模板到服务器上:
下载模板的用到的from代码如下:
FORM sub_chek_directory . DATA: l_formkey1 LIKE wwwdatatab. DATA: l_filename1 LIKE rlgrap-filename. DATA: l_file TYPE string. DATA: l_rc LIKE sy-subrc. DATA: l_temp(70). DATA:l_result TYPE c. l_filename1 = 'C:\Users\00186159\Desktop\333.XLS '. "此路径为模版下载到本地的地址,可 自己改 SELECT SINGLE * INTO CORRESPONDING FIELDS OF l_formkey1 FROM wwwdata WHERE objid = 'ZEXCEL' . CLEAR l_file. CLEAR l_result. l_file = l_filename1. CALL METHOD cl_gui_frontend_services=>file_exist EXPORTING file = l_file RECEIVING result = l_result EXCEPTIONS cntl_error = 1 error_no_gui = 2 wrong_parameter = 3 OTHERS = 5. IF l_result = space. CALL FUNCTION 'DOWNLOAD_WEB_OBJECT' EXPORTING key = l_formkey1 destination = l_filename1 IMPORTING rc = l_rc CHANGING temp = l_temp. IF l_temp NE l_filename1. MESSAGE e398(00) WITH text-001. ENDIF. ENDIF. ENDFORM.
注意一点: HTML模板和二进制的对象名称可以使用同名,在WWWDATA表里面以RELID 区分。