*&---------------------------------------------------------------------*
*& Report ZMM_6501
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmm_6501.
TYPE-POOLS:SLIS,SHLP,ICON.
TABLES:SSCRFIELDS."按钮
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
P_PATH TYPE RLGRAP-FILENAME.
SELECTION-SCREEN: FUNCTION KEY 1.
SELECTION-SCREEN END OF BLOCK BLK1.
INITIALIZATION.
SSCRFIELDS-FUNCTXT_01 = '下载模板'."下载导入EXCEL模板
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PATH.
PERFORM frm_get_filename USING P_PATH.
*&下载模版
AT SELECTION-SCREEN.
PERFORM FRM_DOWNLOAD.
*&---------------------------------------------------------------------*
*& Form frm_get_filename1
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_get_filename USING P_PATH TYPE RLGRAP-FILENAME.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* def_filename = PAY_FILE
* DEF_PATH = ' '
* mask = ',*.XLS ,*.XLS.'
mode = '0'
title = 'Get the import file name!'
IMPORTING
filename = p_path
* RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE 'ERROR' TYPE 'E' .
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DOWNLOAD
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FRM_DOWNLOAD .
DATA: L_ACTION TYPE I.
DATA: L_NAME TYPE STRING.
DATA: L_PASS_PATH TYPE STRING .
DATA: L_PASS_PATH1(128).
DATA: L_KEY LIKE WWWDATATAB,
RC LIKE SY-SUBRC,
TEMP TYPE C.
CASE SY-UCOMM.
WHEN 'FC01'.
CLEAR:RC,TEMP, L_KEY.
SELECT SINGLE WWWDATA~RELID WWWDATA~OBJID
INTO CORRESPONDING FIELDS OF L_KEY
FROM WWWDATA
WHERE WWWDATA~RELID = 'MI' AND
WWWDATA~OBJID = 'ZBP_TY_TEST' AND
WWWDATA~SRTF2 = 0.
IF SY-SUBRC <> 0.
MESSAGE S558(5A) WITH 'EXCEL模板不存在' DISPLAY LIKE 'E'. "The excel template no existed !EXCEL模板不存在
RETURN.
ENDIF.
L_NAME = 'TY_TEMP'.
CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
EXPORTING
FILE_FILTER = '.XLS'
* DEFAULT_EXTENSION = '.XLS'
DEFAULT_FILE_NAME = L_NAME
INITIAL_DIRECTORY = 'C:\'
IMPORTING
FULLPATH = L_PASS_PATH
USER_ACTION = L_ACTION.
IF SY-SUBRC = 0 AND L_ACTION <> 9.
L_PASS_PATH1 = L_PASS_PATH && '.XLS'.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
KEY = L_KEY
DESTINATION = L_PASS_PATH1
IMPORTING
RC = RC
CHANGING
TEMP = TEMP.
IF RC = 0.
MESSAGE S558(5A) WITH '下载模板成功!'."下载模板成功!
ELSE.
MESSAGE S558(5A) WITH '下载模板失败!' DISPLAY LIKE 'E'."下载模板失败!
RETURN.
ENDIF.
ENDIF.
WHEN OTHERS.
IF P_PATH IS INITIAL .
MESSAGE E558(5A) WITH '请选择文件上传路径!' DISPLAY LIKE 'S'."请选择文件上传路径!
ENDIF.
ENDCASE.
ENDFORM.