Skip to Content
author's profile photo Former Member
Former Member

change button text dynamically

hi,

Situation:

I have a 2 Buttons on a dynpro, which are labelled <i>start</i> and <i>stop</i>.

Aim:

The aim is to have only one button, which changes the label when pushed.

Question:

is there a way to change the text on a button (on a dynpro) dynamically? (I don't talk about GUI-Status Buttons).

Regards,

Matthias

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2005 at 10:16 AM

    Hi,

    Declare a global variable in TOP include as gv_pb_text(20). And then have one push button in the screen with name gv_pb_text and then mark it as Output only.

    In your PBO, fill gv_pb_text based on your conditions,

    IF gv_button_clicked EQ 'X'.

    gv_pb_text = 'Start'(001).

    ELSE.

    gv_pb_text = 'Stop'(002).

    ENDIF.

    In your USER_COMMAND Module in PAI (or whatever your Fcode handling module is),

    WHEN 'STARTSTOP'. "Assuming this pb's function code

    IF gv_button_clicked EQ 'X'.

    CLEAR gv_button_clicked.

    ELSE.

    gv_button_clicked = 'X'.

    ENDIF.

    Hope this helps..

    Sri

    Message was edited by: Srikanth Pinnamaneni

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 23, 2005 at 10:20 AM

    Mattias,

    It can be done!!!!

    I am assuming u have screen 100.

    Intially the text will be 'START' in the button and when u press that button, It should change to STOP???

    Idea:

    1. Create only ONE Button in the Screen 100.

    2. Name the button as BUTTONNAME and assign a FCODe

    as 'PRES'.

    3. In the main program, have

    data: buttonName(20).

    4. Have a FLag

    data: clicked type c value 'N'.

    5. In the PBO.

    If clicked eq 'N'.

    buttonName = 'START'.

    else.

    buttonName = 'STOP'.

    endif.

    6. In the PAI.

    case okCode.

    when 'PRES'.

    clicked = 'Y'.

    .............

    when others.

    leave program.

    endcase.

    This could help and it is not a good programming practice. Instead , have a Second Screen 200(just a copy of Screen 100). When u press START in screen 100, get the okCode and call Screen 200(having STOP Button). When the User press STOP in Screen 200, u could Stop the transaction or leave the program.

    Thanks

    Kam

    Note: Allot points for all worthful postings

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 23, 2005 at 10:34 AM

    Hi!

    There is a simple way to do this:

    1. Add a button with the screen painter and name it perhaps "HARRY".

    2. In the properties set the button to "Output"

    3. Create a variable in TOP or somewhere else which is also named "HARRY" perhaps by "DATA: HARRY(16) TYPE C."

    4. Change HARRY to contain something by "HARRY = 'harry'." in the PAI.

    Here is the sample coding

    REPORT z_dietzha_test_000000000000085.

    DATA: testbutton TYPE c, okcode TYPE syucomm.

    CALL SCREEN 0100.

    INCLUDE z_dietzha_test_00000000000085i.

    ***INCLUDE Z_DIETZHA_TEST_00000000000085I .

    MODULE user_command_0100 INPUT.

    IF sy-ucomm = 'EXIT'. LEAVE TO SCREEN 0. ENDIF.

    IF testbutton = '1'. testbutton = '2'. ELSE. testbutton = '1'. ENDIF.

    ENDMODULE.

    And in the screen 0100 the TESTBUTTON has the field "Output" checked in the "General attr." tab.

    Regards

    Harry

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2005 at 09:54 AM

    JUST CREATE TWO BUTTONS.

    1. START

    2. STOP

    NOW..

    wriite a module <b>loop_screen</b> at pbo. here you set one button visible, another invisible, depending o condiion.

    i am just giving you one report program..where the selection screen get changed dynamically.

    you can use the code of the <b>modify_screen</b> perform in your <b>loop_screen</b> module

    run this code..and select radio buttons, see the screen change

    for better understanding..just create 3 text-element, before running this code.

    text-100 = COPY

    text-200 = MOVE

    text-300 = DELEET

    report zxx.

    -parameters----


    selection-screen:

    Begin of block r1 with frame title text-006.

    parameters:

    p_cp1 radiobutton group rb1 default 'X' USER-COMMAND RND,

    • p_cp2 radiobutton group rb1,

    p_mv1 radiobutton group rb1,

    • p_mv2 radiobutton group rb1,

    p_ren radiobutton group rb1,

    p_del1 radiobutton group rb1.

    • p_del2 radiobutton group rb1.

    selection-screen:

    End of block r1.

    selection-screen:

    begin of block b1 with frame title text-004.

    parameters:

    loc1(128) obligatory lower case "Location1

    default 'E:\usr\sap\put' modif id 1,

    file(128) obligatory lower case "Filename

    default 'E:\usr\sap\put\ekpo.dat' modif id 2,

    newname(128) obligatory lower case "Filname

    default 'abcd.txt' modif id 3,

    loc2(128) obligatory lower case "Location2

    default 'E:\usr\sap\D12\SYS\gen' modif id 4.

    selection-screen:

    skip,

    PUSHBUTTON /05(23) TEXT-001 USER-COMMAND ZCOPY modif id 5,"COPY

    PUSHBUTTON 30(23) TEXT-002 USER-COMMAND ZMOV modif id 6, "CUT

    PUSHBUTTON 55(23) TEXT-003 USER-COMMAND ZDELETE modif id 7, "DELTE

    skip,

    PUSHBUTTON /30(23) TEXT-005 USER-COMMAND ZREN modif id 8, "RENAME

    end of block b1.

    *

    at selection-screen output .

    perform modify_screen.

    &----


    *& Form modify_screen

    &----


    form modify_screen.

    loop at screen.

    if p_cp1 eq 'X'.

    if screen-group1 = '3' or

    screen-group1 = '6' or

    screen-group1 = '7' or

    screen-group1 = '8'.

    screen-active = 0.

    endif.

    elseif p_mv1 eq 'X'.

    if screen-group1 = '3' or

    screen-group1 = '5' or

    screen-group1 = '7' or

    screen-group1 = '8'.

    screen-active = 0.

    endif.

    elseif p_del1 eq 'X'.

    if screen-group1 = '3' or

    screen-group1 = '4' or

    screen-group1 = '5' or

    screen-group1 = '6' or

    screen-group1 = '8'.

    screen-active = 0.

    endif.

    elseif p_ren eq 'X'.

    if screen-group1 = '4' or

    screen-group1 = '5' or

    screen-group1 = '6' or

    screen-group1 = '7'.

    screen-active = 0.

    endif.

    endif.

    modify screen.

    endloop.

    endform. " modify_screen

    plz reward points if it helps you.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Ya.i can understand the problem

      but you can't put one object (here BUTTON) over another in screen painter.

      visible/invisible is the solution as per my idea.

      one cumbersome method is..(funny, stil it works)

      1. just keep one button in that screen(100 say)

      2.create a duplicate screen 200 with one button, the lable being different.

      3.now call appropriate screen depending on condition, for better look and feel.

      cheers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 25, 2013 at 07:08 AM

    Please check this post... you will definitely get it...

    http://theabap.blogspot.in/2013/06/changing-label-of-push-button.html

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.