Working with the SAP Picture

Use

This section describes the specific functions of the SAP Picture.

Prerequisites

The process described here is an extension of the general process for using controls that is specific to SAP Picture. It does not contain all of the steps required to produce a valid instance of the control.

Process

  1. Creating the Instance

    • Define a reference variable for the SAP Picture:

      DATA picture TYPE REF TO cl_gui_picture.

    • Create an instance of the SAP Picture:

      CREATE OBJECT picture
              EXPORTING parent  = container. 
  2. Registering the Events

    • Register the events for the SAP Picture that you want to handle. The control supports the following events:

      Event

      Meaning

      EVENTID_PICTURE_CLICK

      Single click on the graphic

      EVENTID_PICTURE_DBLCLICK

      Double-click on the graphic

      EVENTID_CONTROL_CLICK

      Single click within the control area

      EVENTID_CONTROL_DBLCLICK

      Double-click within the control area

      EVENTID_CONTEXT_MENU

      Right mouse click (or Shift+F10) to define a context menu

      EVENTID_CONTEXT_MENU_SELECTED

      Item chosen from a context menu

  3. Using SAP Picture

    • Load a graphic or a SAP icon:

      CALL METHOD picture->load_picture_from_url
              EXPORTING  url = 'http://www.xxx.com/images/picture.gif'
              EXCEPTIONS error = 1.
    • Define how you want the graphic to appear.

      CALL METHOD picture->set_display_mode
              EXPORTING display_mode = picture->display_mode_stretch
              EXCEPTIONS error = 1.
    • If necessary, delete the graphic from the display:

      CALL METHOD picture->clear_picture.
  4. Destroying the Control

    The Lifetime Management is normally responsible for destroying any controls you use. However, if you want to remove the controls manually in your program, you must proceed as follows:

    • Remove the custom control at the frontend. If you do not need the control container any more, remove it as well:

      CALL METHOD picture->free.
    • Delete the reference variables to the SAP Picture and the control container.

      FREE PICTURE.