1.T-Code:SMW0--------------------上载图片
2.Table:WWWDATA和WWWparams能查到所创建的对象.
REPORT ZDISPHOTO .
DATA: OK_CODE TYPE SY-UCOMM,
SAVE_OK LIKE OK_CODE.
*定制控制和图象对象定义
DATA CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA PICTURE TYPE REF TO CL_GUI_PICTURE.
DATA INIT.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_0100 input.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_0100 output.
SET PF-STATUS 'STATUS1'.
* SET TITLEBAR 'xxx'.
IF INIT IS INITIAL.
*图片地址字段定义
DATA URL(255).
CLEAR URL.
*创建对象
CREATE OBJECT CONTAINER
EXPORTING CONTAINER_NAME = 'P1'.
CREATE OBJECT PICTURE
EXPORTING PARENT = CONTAINER
EXCEPTIONS ERROR = 1.
IF SY-SUBRC NE 0.
ENDIF.
*定义通用函数取得图片地址
PERFORM LOAD_PIC_FROM_DB CHANGING URL.
*显示图片
CALL METHOD PICTURE->LOAD_PICTURE_FROM_URL
EXPORTING URL = URL.
IF SY-SUBRC NE 0.
ENDIF.
*置标志位已初始
INIT = 'X'.
ENDIF.
endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form LOAD_PIC_FROM_DB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_URL text
*----------------------------------------------------------------------*
form LOAD_PIC_FROM_DB changing p_url.
DATA QUERY_TABLE LIKE W3QUERY OCCURS 1 WITH HEADER LINE.
DATA HTML_TABLE LIKE W3HTML OCCURS 1.
DATA RETURN_CODE LIKE W3PARAM-RET_CODE.
DATA CONTENT_TYPE LIKE W3PARAM-CONT_TYPE.
DATA CONTENT_LENGTH LIKE W3PARAM-CONT_LEN.
DATA PIC_DATA LIKE W3MIME OCCURS 0.
DATA PIC_SIZE TYPE I.
REFRESH QUERY_TABLE.
*查询对象数据
QUERY_TABLE-NAME = '_OBJECT_ID'.
*图片对象名称
* QUERY_TABLE-VALUE = 'ZTESTGIF'.
QUERY_TABLE-VALUE = 'TMS_LOGO.GIF'.
APPEND QUERY_TABLE.
*读取WWWDATA表,取得图片对象信息
CALL FUNCTION 'WWW_GET_MIME_OBJECT'
TABLES
query_string = QUERY_TABLE
html = HTML_TABLE
mime = PIC_DATA
changing
return_code = RETURN_CODE
content_type = CONTENT_TYPE
content_length = CONTENT_LENGTH
EXCEPTIONS
OBJECT_NOT_FOUND = 1
PARAMETER_NOT_FOUND = 2
OTHERS = 3
.
IF sy-subrc = 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
PIC_SIZE = CONTENT_LENGTH.
ENDIF.
*创建图片URL地址
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = CNDP_SAP_TAB_UNKNOWN
SIZE = PIC_SIZE
* DATE =
* TIME =
* DESCRIPTION =
LIFETIME = CNDP_LIFETIME_TRANSACTION
* CACHEABLE =
tables
data = PIC_DATA
* FIELDS =
* PROPERTIES =
changing
url = URL
EXCEPTIONS
* DP_INVALID_PARAMETER = 1
* DP_ERROR_PUT_TABLE = 2
* DP_ERROR_GENERAL = 3
OTHERS = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " LOAD_PIC_FROM_DB