具体参考:
ABAP EXCEL 下载摸板

获取数据模板文件路径

FORM fm_get_filepath .DATA: lv_filename TYPE string,lv_path TYPE string,lv_fullpath TYPE string,lv_titleTYPE string.co_objid = 'ZMMRP002'.CONCATENATEco_objid '-' sy-datumsy-uzeit INTO lv_title .CALL METHOD cl_gui_frontend_services=>file_save_dialogEXPORTINGwindow_title = '模板保存为EXCEL'default_extension= 'xls'default_file_name= lv_title* file_filter= '.xls'file_filter= 'Excel 文件 (*.XLS)'initial_directory= 'D:/'* DEFAULT_FILE_NAME= p_filenameCHANGINGfilename = lv_filenamepath = lv_pathfullpath = gv_fullpathEXCEPTIONScntl_error = 1error_no_gui = 2not_supported_by_gui = 3OTHERS = 4.IF sy-subrc  0.STOP .ENDIF.ENDFORM.

” 下载数据模板

下载功能主要调用 FM ‘DOWNLOAD_WEB_OBJECT’
传入上述定义的模板名称以及文件保存的路径
返回下载的状态

DATA: ls_indcatortxt TYPE string,p_filename TYPE sapb-sappfad.DATA: lo_objdata LIKE wwwdatatab,lo_mimeLIKE w3mime,ls_destination LIKE rlgrap-filename,ls_objnamTYPE string,li_rcLIKE sy-subrc,ls_errtxtTYPE string.p_filename = gv_fullpath.”ABAP 进度条设置ls_indcatortxt = '程序正在下载模板' .CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'EXPORTINGpercentage = 0text = ls_indcatortxt.CONCATENATE co_objid '.XLS' INTO ls_objnam.CONDENSE ls_objnam NO-GAPS."判断模板文件是否存在SELECT SINGLE relid objid FROM wwwdataINTO CORRESPONDING FIELDS OF lo_objdataWHERE srtf2= 0AND relid= 'MI'AND objid= co_objid .IF sy-subrc NE 0 OR lo_objdata-objid EQ space .CONCATENATE '模板文件:' ls_objnam '不存在,请用TCODE:SMW0进行加载' INTO ls_errtxt.MESSAGE ls_errtxtTYPE'E' .ENDIF."下载文件功能"ls_destination = gv_fullpath.CALL FUNCTION 'DOWNLOAD_WEB_OBJECTEXPORTINGkey = lo_objdatadestination = ls_destinationIMPORTINGrc= li_rc.IF li_rc NE 0.CONCATENATE '模板文件:' ls_objnam '下载失败' INTO ls_errtxt.MESSAGE ls_errtxt TYPE 'E' .ENDIF.