13 Replies Latest reply: Jul 13, 2011 3:20 PM by rama basa RSS

How to use CL_GUI_FRONTEND_SERVICES=>GET_SCREENSHOT?

Marcin Cholewczuk
Currently Being Moderated

Hi everybody,

 

I've noticed this function lately and wanted to test it. I wrote report like below, but nothing is displayed. Data are read (at least I'm getting something in this xstring), url is being generated, container and picture objects are created, and url is loaded without error. So what is wrong here?

 

REPORT  ZTEST11.
 data: lv_mime TYPE string,
       lv_data TYPE xstring.

DATA: BEGIN OF graphic_table OCCURS 0,
        line(255) TYPE x,
      END OF graphic_table.

DATA: graphic_size TYPE i.
DATA: graphic_url(255).

DATA: l_graphic_conv TYPE i,
      l_graphic_offs TYPE i.

DATA: lo_picture TYPE REF TO cl_gui_picture,
      lo_container TYPE REF TO cl_gui_docking_container.
data lv_result type i.

PARAMETERS tmp.

AT SELECTION-SCREEN OUTPUT.
  IF lo_container IS NOT BOUND.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_SCREENSHOT
      IMPORTING
        MIME_TYPE_STR        = lv_mime
        IMAGE                = lv_data.

      graphic_size = XSTRLEN( lv_data ).
      CHECK graphic_size > 0.

      l_graphic_conv = graphic_size.
      l_graphic_offs = 0.

      WHILE l_graphic_conv > 255.
        graphic_table-line = lv_data+l_graphic_offs(255).
        APPEND graphic_table.
        l_graphic_offs = l_graphic_offs + 255.
        l_graphic_conv = l_graphic_conv - 255.
      ENDWHILE.

      graphic_table-line = lv_data+l_graphic_offs(l_graphic_conv).
      APPEND graphic_table.

    CALL FUNCTION 'DP_CREATE_URL'
      EXPORTING
        TYPE                       = 'image'
        SUBTYPE                    = 'png'
      TABLES
        DATA                       = graphic_table
      CHANGING
        URL                        = graphic_url.

    CREATE OBJECT LO_CONTAINER
      EXPORTING
        EXTENSION                   = 600.

    CREATE OBJECT LO_PICTURE
      EXPORTING
        PARENT = LO_CONTAINER.

    CALL METHOD LO_PICTURE->LOAD_PICTURE_FROM_URL
      EXPORTING
        URL    = graphic_url.
  ENDIF.

 

Best regards

Marcin Cholewczuk

Actions