Posted: Sun Nov 04, 2007 8:00 pm Post subject: Demo: Picture Control
Code:
REPORT rsdemo_picture_control .
include <icon>.
DATA container TYPE REF TO cl_gui_custom_container.
DATA picture TYPE REF TO cl_gui_picture.
DATA init.
DATA ok_code TYPE sy-ucomm.
DATA save_ok TYPE sy-ucomm.
TYPE-POOLS cndp.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS contextmenurequest
FOR EVENT context_menu OF cl_gui_picture.
METHODS contextmenuselected
FOR EVENT context_menu_selected OF cl_gui_picture
IMPORTING fcode.
ENDCLASS.
DATA event_receiver TYPE REF TO lcl_event_receiver.
DATA events TYPE cntl_simple_events.
DATA wa_events TYPE cntl_simple_event.
SET SCREEN 100.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD contextmenurequest.
DATA menu TYPE REF TO cl_ctmenu.
CREATE OBJECT menu.
CALL METHOD menu->load_gui_status
EXPORTING program = 'RSDEMO_PICTURE_CONTROL'
status = 'CONTEXT'
menu = menu
EXCEPTIONS read_error = 1.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
CALL METHOD picture->display_context_menu
EXPORTING context_menu = menu
EXCEPTIONS error = 1.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
* <weiterer>
ENDMETHOD.
METHOD contextmenuselected.
MESSAGE i300(eu) WITH fcode. "#EC NOTEXT
ENDMETHOD.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS'.
* SET TITLEBAR 'xxx'.
IF init is initial.
CREATE OBJECT container
EXPORTING container_name = 'CUSTOM_CONTAINER'.
CREATE OBJECT picture
EXPORTING parent = container
EXCEPTIONS error = 1.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->contextmenurequest FOR picture.
SET HANDLER event_receiver->contextmenuselected FOR picture.
init = 'X'.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'LOAD_PICTURE'.
* Request an URL from the data provider by exporting the pic_data.
DATA url(255).
CLEAR url.
PERFORM load_pic_from_db CHANGING url.
* load picture
CALL METHOD picture->load_picture_from_url
EXPORTING url = url.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
WHEN 'DELETE'.
CALL METHOD picture->clear_picture
EXCEPTIONS error = 1.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
WHEN 'STRETCH'.
CALL METHOD picture->set_display_mode
EXPORTING display_mode = picture->display_mode_stretch
EXCEPTIONS error = 1.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
WHEN 'NORMAL'.
CALL METHOD picture->set_display_mode
EXPORTING display_mode = picture->display_mode_normal
EXCEPTIONS error = 1.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
WHEN 'LOAD_ICON'.
CALL METHOD picture->load_picture_from_sap_icons
EXPORTING icon = '@00@'
EXCEPTIONS error = 1.
IF sy-subrc ne 0.
* Fehlerbehandlung
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
CALL METHOD picture->free.
CALL METHOD container->free.
LEAVE PROGRAM.
ENDMODULE. " EXIT INPUT
*&---------------------------------------------------------------------*
*& Form LOAD_PIC_FROM_DB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM load_pic_from_db CHANGING 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.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.