导航

how-to-display-picture-in-screen

Posted on 2010-07-21 14:52  Hahappyppy  阅读(678)  评论(0编辑  收藏  举报

RSDEMO_CUSTOM_CONTROL
Step 1)Check what extensions are allowed in table "MIMITYPES".
clip_image001
Step 2)Modify the file extension of the picture from ".jpg" etc. to ".html"(any of the allowed MIME types from the previous step).
clip_image002
clip_image003
Step 3)Upload a picture through transaction SMW0 by creating a new "Z" object (you can save it in a transport if you want):
clip_image004
clip_image005
clip_image005[1]
clip_image005[2]
Step 4) Create a program as shown below with a Screen 0100, PF-STATUS "S0100" and Custom Container "CONT" . This program can be used to display any of the pictures uploaded through SMW0.

 

*&---------------------------------------------------------------------*
*& Report ZTEST_PICTURE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ztest_picture.
TYPE-POOLS: cndp.
DATA: ok_code TYPE syucomm,
container TYPE REF TO cl_gui_custom_container,
picture TYPE REF TO cl_gui_picture,
url TYPE cndp_url.
PARAMETERS: p_objid TYPE w3objid OBLIGATORY.
AT SELECTION-SCREEN.
SELECT COUNT(*) FROM wwwparams
WHERE objid = p_objid.
IF sy-subrc <> 0.
MESSAGE e001(00) WITH 'MIME Object not found'.
ENDIF.
START-OF-SELECTION.
IF container IS INITIAL.
CREATE OBJECT container
EXPORTING
container_name = 'CONT'
repid = 'ZTEST_PICTURE'
dynnr = '0100'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE i001(00) WITH 'Error while creating container'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
IF picture IS INITIAL.
CREATE OBJECT picture
EXPORTING
parent = container
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i001(00) WITH 'Error while displaying picture'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
IF picture IS NOT INITIAL.
CALL FUNCTION 'DP_PUBLISH_WWW_URL'
EXPORTING
objid = p_objid
lifetime = cndp_lifetime_transaction
IMPORTING
url = url
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
CALL METHOD picture->load_picture_from_url_async
EXPORTING
url = url.
CALL METHOD picture->set_display_mode
EXPORTING
display_mode = cl_gui_picture=>display_mode_fit.
ELSE.
MESSAGE i001(00) WITH 'Error while load picture'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
CALL SCREEN 0100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'S0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK'.
SET SCREEN 00.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT