cancel
Showing results for 
Search instead for 
Did you mean: 

Change of text of the button at runtime

Former Member
0 Kudos

HI All,

I am having EDIT/Display text.

When the page is initial the text of the button should be EDIT.

After entering the fields and update the records into the table which is inthe same page,the button should change to Display

Cheers,

Mahalakshmi.K

Accepted Solutions (1)

Accepted Solutions (1)

p_2_5_6_9_6_0
Active Participant
0 Kudos

Hi,

Please follow the steps below (I'm assuming that the button's name is BTN1 and it is bound to a context attribute with the name BTNLABEL of type String)

1.) Create an action for the button using the Properties section of the view.(Lets say you created the action called "SELECT")

2.) Double click the action and you will be taken to the Methods section of the View. This is where you will write the code.

3.) Now what you need to do is use the Webdynpro method and read the context of the attribute "BTNLABEL" - do this by clicking the Web Dynpro wizard button and then select "READ CONTEXT" from the options - select the "BTNLABEL" attribute as well.

4.) After the code is inserted in the method - please add the ABAP code for the following pseudocode..

if lv_btnlabel eq 'EDIT.

lv_btnlabel = 'DISPLAY'

else.

lv_btnLABEL = 'EDIT'.

endif.

bind the variable to the control using the wizard after this.

Hope ths helps. Let me know

Thanks.

Former Member
0 Kudos

HI,

can you pls tell me how to generate the code for variable with code wizard.

Thanks

Former Member
0 Kudos

Select the code wizard (Ctrl + F7), choose "Read context node/attribute". Using F4, select the specific attribute that you want to read in your context node. And the code will be generated.

Regards,

Nithya

Former Member
0 Kudos

Hi

when you click on the wizard icon u get an option to rad the context, there you can see all of ur nodes and attributes.

selct the attribute you want to read and press enter

the code will be generated.

here you will get the code as.

lo_el_element->get_attribute

exporting

name = ' ATT1'.

importing

value = lv_value.

to set the value to the attribut you have to change the code like this:

lo_el_element->set_attribute

exporting

name = ' ATT1'.

value = 'text'. "this sets the text of ur button "

Former Member
0 Kudos

Hi ll,

thanks for all ur Answers.

Thanks

Mahalakshmi.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi u can create an attribute of type string. and bind it with the text property of the button.

in the init method you can set the value for attribute as "EDIT".

then when you enter some values and update your table. at the end of the code for updation you can set the value for attribute as "DISPLAY".

regards

chythanya.v

Former Member
0 Kudos

Hi,

Create a context attribute say BUTTON_TEXT. Bind the property 'Text' of the button you created to the context attribute BUTTON_TEXT.

Now, in the code, you can change the text of the button, by changing the value of the attribute 'BUTTON_TEXT'.

Regards

Wenonah