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.
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.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |