1

I have a button on a module pool screen. I need to change the icon, tooltip and text dynamically based on logic/a condition. I can successfully change the icon and text but am unable to change all three things (icon, text and tooltip) together.

Sample PBO code:

Data but(30) type c." here but is the name of button in screen.
write 'icon xxx' as ICON to but.
Concatenate but 'click here' into but separated by space.

It does not set the value of the tooltip, which should show "Please Click here to proceed". How can I do this?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user3757558
  • 55
  • 4
  • 12
  • Why don't you define all the buttons, and dynamically hide the buttons you don't need? – Oguz Dec 05 '17 at 06:38

1 Answers1

1

Use ICON_CREATE FM instead.

Here is the sample how to change all three attributes on-the-fly:

PARAMETERS: p_icon  TYPE icon_d MATCHCODE OBJECT h_icon,
            p_text  TYPE string,
            p_toolt TYPE string.

SELECTION-SCREEN BEGIN OF SCREEN 500.
SELECTION-SCREEN PUSHBUTTON 49(30) but USER-COMMAND ret.
SELECTION-SCREEN END OF SCREEN 500.

AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'ONLI'.
       CALL FUNCTION 'ICON_CREATE'
        EXPORTING
          name       = p_icon
          text       = p_text
          info       = p_toolt
          add_stdinf = 'X'
        IMPORTING
          result     = but.
      CALL SELECTION-SCREEN 500.
    WHEN 'RET'.
      LEAVE TO SCREEN 0.
    WHEN OTHERS.
  ENDCASE.
Suncatcher
  • 10,355
  • 10
  • 52
  • 90