Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results forÂ
Search instead forÂ
Did you mean:Â
Success! Subscription added.
We have launched new Developer forums/groups in the SAP Community. If you are here to publish developer- or SAP-technology related blog posts, please check out our new groups instead. You can find more information about the developer forums in this What's New post.
It took some seconds and investigation before I found out how this icon could be set at this position of the SAPGUI.
Containers All Around
If you want to place a control somewhere on the SAPGUI, you need a container. The most common containers are:
CL_GUI_DOCKING_CONTAINER for docking a container to one side of the dynpro
CL_GUI_CUSTOM_CONTAINER for implementing custom controls inside a dynpro
CL_GUI_DIALOGBOX_CONTAINER for displaying a resizeable amodal popup
CL_GUI_SPLITTER_CONTAINER which provides several containers divided by a splitter
CL_GUI_EASY_SPLITTER_CONTAINER which provides two containers divided by a splitter
They all ere inherited by super class CL_GUI_CONTAINER.If you take a look at the sub classes of CL_GUI_CONTAINER then you will find another container class: CL_GUI_GOS_CONTAINER.
This is the container where I placed the attention image of the screen shot.
Coding Is Believing
Here is the minimum of code for hacking the SAPGUI
REPORT.
PARAMETERS p_test.
INITIALIZATION.
DATA(picture) = NEW cl_gui_picture( parent = NEW cl_gui_gos_container( width = 38 ) ).
DATA url TYPE cndp_url.
CALL FUNCTION 'DP_PUBLISH_WWW_URL'
EXPORTING
objid = 'ACHTUNG'
lifetime = cndp_lifetime_transaction
IMPORTING
url = url
EXCEPTIONS
dp_invalid_parameters = 1
no_object = 2
dp_error_publish = 3.
IF sy-subrc = 0.
picture->load_picture_from_url_async( url = url ).
picture->set_display_mode( picture->display_mode_fit ).
ENDIF.
More Experiments
I simply love things that are unusual or "impossible". Therefore I started some experimenting with the "new" container.
Multiple instances
I found out that it can be used multiple times, which gives a lot more options...
The following code displays the icons as shown above. Clicking on checkbox P_SHOW shows or hides the attention image.
Clicking on an icon brings up an information message.
REPORT.
PARAMETERS p_test.
PARAMETERS p_show AS CHECKBOX DEFAULT 'X' USER-COMMAND dummy.
CLASS info DEFINITION.
PUBLIC SECTION.
METHODS icon IMPORTING name TYPE clike RETURNING VALUE(info) TYPE REF TO info.
METHODS pic IMPORTING name TYPE clike RETURNING VALUE(info) TYPE REF TO info.
METHODS constructor IMPORTING width TYPE i.
METHODS with_text IMPORTING text TYPE clike RETURNING VALUE(info) TYPE REF TO info..
METHODS hide.
METHODS show.
PROTECTED SECTION.
DATA picture TYPE REF TO cl_gui_picture.
METHODS handle_click FOR EVENT picture_click OF cl_gui_picture.
DATA text TYPE string.
ENDCLASS.
CLASS info IMPLEMENTATION.
METHOD constructor.
picture = NEW cl_gui_picture( parent = NEW cl_gui_gos_container( width = width ) ).
picture->set_registered_events( VALUE #(
( eventid = cl_gui_picture=>eventid_picture_click )
) ).
SET HANDLER handle_click FOR picture.
ENDMETHOD.
METHOD icon.
picture->load_picture_from_sap_icons( name ).
picture->set_display_mode( picture->display_mode_fit ).
info = me.
ENDMETHOD.
METHOD pic.
DATA url TYPE cndp_url.
CALL FUNCTION 'DP_PUBLISH_WWW_URL'
EXPORTING
objid = CONV w3objid( name )
lifetime = cndp_lifetime_transaction
IMPORTING
url = url
EXCEPTIONS
dp_invalid_parameters = 1
no_object = 2
dp_error_publish = 3.
IF sy-subrc = 0.
picture->load_picture_from_url_async( url = url ).
picture->set_display_mode( picture->display_mode_fit ).
ENDIF.
info = me.
ENDMETHOD.
METHOD with_text.
me->text = text.
info = me.
ENDMETHOD.
METHOD handle_click.
CHECK text IS NOT INITIAL.
MESSAGE text TYPE 'I'.
ENDMETHOD.
AT SELECTION-SCREEN OUTPUT.
CASE p_show.
WHEN abap_true.
info->show( ).
WHEN abap_false.
info->hide( ).
ENDCASE.
btw: Method Chaining
Because I like the idea of bfeeb8ed7fa64a7d95efc21f74a8c135 to write the code in a way that the code itself says what will happen, I tried to do so in this little report via method chainging:
Seriously: I recommend NOT to use it in any of your custom transactions unless you have a really really good reason for it. It will confuse your users strongly...