File Upload
- Execute the Transaction code : SMW0
Choose "Binary data for WebRFC applications" Radio button and execute
- Input Object Name, Description and upload file by upload icon and save.
File Download by Program
- Create function key or pushbutton on screen.
INCLUDE <icon>.
SELECTION-SCREEN FUNCTION KEY 1.
DATA: LV_FILE TYPE CHAR40.
AT SELECTION-SCREEN.
CASE SSCRFIELDS-UCOMM.
WHEN 'FC01'.
PERFORM TEMPLATE_EXPORT USING LV_FILE.
ENDCASE.
INITIALIZATION.
DATA: LS_SEL_BUTTON TYPE SMP_DYNTXT.
LS_SEL_BUTTON-ICON_ID = ICON_EXPORT.
LS_SEL_BUTTON-QUICKINFO = 'Download production version template'.
LS_SEL_BUTTON-ICON_TEXT = 'Download Template'.
SSCRFIELDS-FUNCTXT_01 = LS_SEL_BUTTON.
FORM TEMPLATE_EXPORT USING VALUE(P_TEMP_NAME).
DATA: LS_RETURN TYPE BAPIRET2,
LS_WWWDATA_TAB LIKE WWWDATATAB.
CLEAR: LS_RETURN.
*Make sure template exists in SMw0 as binary object
SELECT * FROM WWWDATA INNER JOIN TADIR
ON WWWDATA~OBJID = TADIR~OBJ_NAME
INTO CORRESPONDING FIELDS OF LS_WWWDATA_TAB UP TO 1 ROWS
WHERE WWWDATA~SRTF2 = 0
AND WWWDATA~RELID = 'MI'
AND TADIR~PGMID = 'R3TR'
AND TADIR~OBJECT = 'ZSMS'
AND TADIR~OBJ_NAME = P_TEMP_NAME.
ENDSELECT.
IF SY-SUBRC <> 0.
PERFORM FILL_RETURN USING 'E'
'OO'
'000'
'Template'
P_TEMP_NAMe
'does not exist in'
'transaction SMW0'
CHANGING LS_RETURN.
EXIT.
ENDIF.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
KEY = LS_WWWDATA_TAB.
ENDFORM.
FORM FILL_RETURN USING P_TYPE
P_ID
P_NUMBER
P_MESSAGE_V1
P_MESSAGE_V2
P_MESSAGE_V3
P_MESSAGE_V4
CHANGING P_RETURN LIKE BAPIRET2.
CLEAR: P_RETURN.
P_RETURN-TYPE = P_TYPE.
P_RETURN-ID = P_ID.
P_RETURN-NUMBER = P_NUMBER.
P_RETURN-MESSAGE_V1 = P_MESSAGE_V1.
P_RETURN-MESSAGE_V2 = P_MESSAGE_V2.
P_RETURN-MESSAGE_V3 = P_MESSAGE_V3.
P_RETURN-MESSAGE_V4 = P_MESSAGE_V4.
MESSAGE ID P_ID TYPE P_TYPE NUMBER P_NUMBER
WITH P_MESSAGE_V1 P_MESSAGE_V2 P_MESSAGE_V3 P_MESSAGE_V4
INTO P_RETURN-MESSAGE.
ENDFORM. " FILL_RETURN
No comments:
Post a Comment