Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Changing buttons texts dynamically

Former Member
0 Likes
529

Hello All

How can I change the button text dynamically on a screen?

I have one button with the text: "Overwrite = OFF" and I want to change to "Overwrite = ON" when the user click on it, and if the user click again it will change back to "Overwrite = OFF".

TIA. Mauro.

Message was edited by: Mauro

3 REPLIES 3
Read only

Former Member
0 Likes
467

Is this a report or an online program?

Rob

Read only

Former Member
0 Likes
467

I think that's kind of difficult cause you will have to search de properties of the screen. The best thing to do it could be to take a copy of the screen but with the text of the button you want, and set the screen in the event you want to catch.

I hope this idea be helpful.

Read only

Former Member
0 Likes
467

Hi Mauro,

Here's the code:

* Required
  TABLES:
    sscrfields.
  FIELD-SYMBOLS:
    <field> TYPE ANY,
    <value> TYPE ANY.
* Selection screen with one push button
  SELECTION-SCREEN:
    BEGIN OF BLOCK b1 WITH FRAME,
      PUSHBUTTON 3(20)  but1 USER-COMMAND cli1,
    END OF BLOCK b1.
* Event
  AT SELECTION-SCREEN.
    CASE sscrfields.
      WHEN 'CLI1'.
        LOOP AT SCREEN.
          IF screen-name EQ 'BUT1'.
            ASSIGN screen-name TO <field>.
            ASSIGN (<field>) TO <value>.
            IF <value> EQ 'Status = OFF'.
              <value> = 'Status = ON'.
            ELSE.
              <value> = 'Status = OFF'.
            ENDIF.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
    ENDCASE.
* Cleanup (don't forget)
  IF <field> IS ASSIGNED. UNASSIGN <field>. ENDIF.
  IF <value> IS ASSIGNED. UNASSIGN <value>. ENDIF.
* Initial value set
  INITIALIZATION.
    but1 = 'Status = OFF'.

Regards,

Rob.