SELECTION-SCREEN FUNCTION KEY 1.
*子屏幕
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN END OF SCREEN 100.
*子屏幕
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
*选项卡
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 20 LINES,
TAB (20) button1 USER-COMMAND push1 DEFAULT SCREEN 100,
TAB (20) button2 USER-COMMAND push2 DEFAULT SCREEN 200,
END OF BLOCK mytab.
*选项卡名字
INITIALIZATION.
button1 = 'XXXXXXXXXXXXX'.
button2 = 'XXXXXXXXXXXXX'.
*选项卡跳转
IMPORT p1 = w_dynnr FROM MEMORY ID 'DYNNR'.
IMPORT p2 = w_tab FROM MEMORY ID 'TAB'.
IF w_dynnr IS INITIAL AND w_tab IS INITIAL.
mytab-prog = sy-repid.
mytab-dynnr = 100.
mytab-activetab = 'PUSH1'.
ELSE.
mytab-prog = sy-repid.
mytab-dynnr = w_dynnr.
mytab-activetab = w_tab.
ENDIF.
FREE MEMORY ID 'DYNNR'.
FREE MEMORY ID 'TAB'.
sscrfields-functxt_01 = '下载模板'(012).
*选项卡跳转
IF sy-dynnr EQ 1000.
CASE sy-ucomm.
WHEN 'PUSH1'.
mytab-dynnr = 100.
WHEN 'PUSH2'.
mytab-dynnr = 200.
WHEN OTHERS.
ENDCASE.
ENDIF.
CASE mytab-dynnr.
WHEN 100.
p_main = 'X'.
WHEN 200.
p_zz = 'X'.
WHEN OTHERS.
ENDCASE.
*下载模板
FORM frm_download_model .
DATA pfolder LIKE rlgrap-filename.
DATA objdata LIKE wwwdatatab.
CHECK sscrfields-ucomm EQ 'FC01'.
CLEAR sscrfields-ucomm.
* 检测文件是否存在
SELECT SINGLE * FROM wwwdata AS f INNER JOIN tadir AS p
ON f~objid = p~obj_name
INTO CORRESPONDING FIELDS OF objdata
WHERE objid EQ 'XXXXXXXX.XLS'
AND f~srtf2 = 0
AND f~relid = 'MI'
AND p~pgmid = 'R3TR'
AND p~object = 'W3MI'.
IF objdata IS INITIAL.
MESSAGE '模板文件不存在!' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
* 选择下载路径
PERFORM frm_get_folder CHANGING pfolder.
IF pfolder IS INITIAL.
STOP.
ENDIF.
*往SAP中放文件模板事物码:SHD0
CONCATENATE pfolder '\XXXXXXXXXXXX.XLS' INTO pfolder.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
key = objdata
destination = pfolder.
STOP.
ENDFORM. " FRM_DOWNLOAD_MODEL