Enterprise Resource Planning Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Akshay_Anil
Explorer
1,261

Hey everyone,

Just wanted to share something I recently tried out — displaying an image (like a logo) directly on the selection screen of a report.
This can be useful if you want to brand your report or make it look a bit more user-friendly. I used CL_GUI_PICTURE along with a few standard function modules to fetch and show the image from SE78 , I'm sharing the code below not only displays a logo but also allows removing the picture when needed.

Code Implementation:

AT SELECTION-SCREEN OUTPUT.
  PERFORM preview_logo.
FORM preview_logo.

  DATA: docking          TYPE REF TO cl_gui_docking_container,
        picture_control_1 TYPE REF TO cl_gui_picture,
        url(256)          TYPE c,
        pic_data          TYPE TABLE OF w3mime WITH HEADER LINE,
        pic_size          TYPE i.

  IF picture_control_1 IS INITIAL.

    CREATE OBJECT picture_control_1
      EXPORTING
        parent = docking.

    CHECK sy-subrc = 0.

    CALL METHOD picture_control_1->set_3d_border
      EXPORTING
        border = 0.

    CALL METHOD picture_control_1->set_display_mode
      EXPORTING
        display_mode = cl_gui_picture=>display_mode_fit.

    CALL METHOD picture_control_1->set_position
      EXPORTING
        height = 139
        left   = 970
        top    = 1
        width  = 300.

    " Read image from SE78
    DATA: l_content   TYPE STANDARD TABLE OF bapiconten WITH DEFAULT KEY,
          l_bytecount TYPE i.

    CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
      EXPORTING
        i_object       = 'GRAPHICS'
        i_name         =  " Your image name from SE78
        i_id           = 'BMAP'
        i_btype        = 'BMON'
      IMPORTING
        e_bytecount    = l_bytecount
      TABLES
        content        = l_content
      EXCEPTIONS
        not_found      = 1
        bds_get_failed = 2
        OTHERS         = 3.

    CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
      EXPORTING
        old_format                = 'BDS'
        new_format                = 'BMP'
        bitmap_file_bytecount_in = l_bytecount
      IMPORTING
        bitmap_file_bytecount    = pic_size
      TABLES
        bds_bitmap_file          = l_content
        bitmap_file              = pic_data
      EXCEPTIONS
        OTHERS                   = 0.

    IF url IS INITIAL.
      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.
    ENDIF.

    CALL METHOD picture_control_1->load_picture_from_url
      EXPORTING
        url = url.

  ENDIF.

ENDFORM.

 
To Remove the Picture:

FORM disable_logo.

  IF picture_control_1 IS BOUND.
    CALL METHOD picture_control_1->free.
    FREE picture_control_1.
  ENDIF.

ENDFORM.

Call this form where you want to disable the logo , usually when the program is getting executed.

Notes:

  • Save ,  " DATA : picture_control_1 TYPE REF TO cl_gui_picture " at your main declaration part.
  • Ensure your image is uploaded in SE78 under the correct object name and ID (GRAPHICS, BMAP, etc.).
  • You can adjust the position (LEFT, TOP) and size (HEIGHT, WIDTH) in set_position as per your layout requirement.
  • This implementation works well for classic reports and can be extended further based on dynamic selections.

Let me know if anyone tries this or if there's a better way to optimise it. I hope this helps! Let me know your thoughts or if you have any questions.

Thanks,

Akshay Anil   Linkedin Profile
Technical Consultant, SAP ABAP | BTP | Fiori | Ui5

#ABAP #SAP #SAPABAP #ABAPTips #SelectionScreen #SAPGUI #UIDesign #SAPCommunity

 

2 Comments
SOUHAIL_FAIRADI
Explorer

Good job, it worked with me, but there is a little problem is the picture appear in all pages not only in the selection screen

Akshay_Anil
Explorer
0 Kudos

@SOUHAIL_FAIRADI Thanks! Glad it worked for you .
Yes, you're right — if the picture appears on all pages instead of just the selection screen, you need to disable or hide the logo after the selection screen is processed.

FORM disable_logo.
  IF picture_control_1 IS BOUND.
    CALL METHOD picture_control_1->free.
    FREE picture_control_1.
  ENDIF.
ENDFORM.

Call this FORM in the event block where your main processing starts (like AT SELECTION-SCREEN or right at the start of START-OF-SELECTION) to make sure the logo is cleared after the selection screen is displayed.

I hope this helps! Let me know your thoughts or if you have any questions.

Thanks,

Akshay Anil 
Technical Consultant, SAP ABAP | BTP | Fiori | Ui5