SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Demo: Picture Control



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Nov 04, 2007 8:00 pm    Post subject: Demo: Picture Control Reply with quote

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.

    wa_events-eventid = picture->eventid_context_menu.
    wa_events-appl_event = ' '.
    APPEND wa_events TO events.
    wa_events-eventid = picture->eventid_context_menu_selected.
    wa_events-appl_event = ' '.
    APPEND wa_events TO events.
    CALL METHOD picture->set_registered_events
          EXPORTING  events                    = events
          EXCEPTIONS cntl_error                = 1
                     cntl_system_error         = 2
                     illegal_event_combination = 3.
    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.

  REFRESH query_table.
  query_table-name = '_OBJECT_ID'.
  query_table-value = 'ENJOYSAP_LOGO'.
  APPEND query_table.

  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.
    pic_size = content_length.
  ENDIF.

  CALL FUNCTION 'DP_CREATE_URL'
       EXPORTING
            type     = 'image'
            subtype  = cndp_sap_tab_unknown
            size     = pic_size
            lifetime = cndp_lifetime_transaction
       TABLES
            data     = pic_data
       CHANGING
            url      = url
       EXCEPTIONS
            OTHERS   = 1.


ENDFORM.                               " LOAD_PIC_FROM_DB


*Messages
*----------------------------------------------------------
*
* Message class: EU
*300   &


****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
RSDEMO_PICTURE_CONTROL
0100
620
40
%_HEADER
RSDEMO_PICTURE_CONTROL 0100 0100 17 51192 35 0 0 21 83 0G D 19990125140738
%_DESCRIPTION
Screen 100
%_FIELDS
CUSTOM_CONTAINER 51 00 00 00 30 00 1 2 0 0 0 17 U 1 1 102
OK_CODE CHAR 20 80 10 00 00 00 255 1 O 0 0 0
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
module exit at exit-command.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.