Insert an image in Selection-screen

Insert an image in Selection-screen

Have a look on program : RSDEMO_CUSTOM_CONTROL. to insert an image in Dynpro (not selection screen)

To add image on selection-screen

check the code below :


*&---------------------------------------------------------------------*
*& Report ZTEST_FJO_TEST_PROGRAM
*&---------------------------------------------------------------------*
REPORT ZTEST_FJO_TEST_PROGRAM.

DATA: gv_img_url(256) TYPE c.

PARAMETERS: a(4) DEFAULT '4' .
WRITE a.

AT SELECTION-SCREEN OUTPUT.
  PERFORM display_picture.

START-OF-SELECTION.

*&-------------------------------------------------------------------
*& Form display_picture
*&-------------------------------------------------------------------
FORM display_picture.

  DATA: lo_docking_container TYPE REF TO cl_gui_docking_container,
        lt_html_table        LIKE w3html OCCURS 1,
        lv_return_code       TYPE w3retcode,
        lv_content_type      TYPE w3conttype,
        lv_content_length    TYPE w3contlen,
        lt_pic_data          TYPE lvc_t_mime,
        lv_pic_size             TYPE i.

  " Create picture object
  DATA(lo_picture) = NEW cl_gui_picture( parent = lo_docking_container  ).
  CHECK sy-subrc = 0.

  " Specify border size
  lo_picture->set_3d_border( 5 ).

  " Set picture format to be displayed
  lo_picture->set_display_mode( cl_gui_picture=>display_mode_stretch ).
  lo_picture->set_position( height = 50
                            left   = 40
                            top    = 30
                            width  = 190 ).

  IF gv_img_url IS INITIAL.
    DATA(lt_query_table) = VALUE rrxw3tquery( ( name = '_OBJECT_ID'
                                                value = 'SAP_LOGO.GIF' " Name of 
                                               ) ).             " object in SMW0

    CALL FUNCTION 'WWW_GET_MIME_OBJECT'
      TABLES
        query_string        = lt_query_table
        html                = lt_html_table
        mime                = lt_pic_data
      CHANGING
        return_code         = lv_return_code
        content_type        = lv_content_type
        content_length      = lv_content_length
      EXCEPTIONS
        object_not_found    = 1
        parameter_not_found = 2
        OTHERS              = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    CALL FUNCTION 'DP_CREATE_URL'
      EXPORTING
        type     = 'image' ##NO_TEXT
        subtype  = cndp_sap_tab_unknown " X-UNKNOWN
        size     = lv_pic_size
        lifetime = cndp_lifetime_transaction
      TABLES
        data     = lt_pic_data
      CHANGING
        url      = gv_img_url
      EXCEPTIONS
        OTHERS   = 1.
  ENDIF.
  lo_picture->load_picture_from_url( gv_img_url ).
ENDFORM.

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply