cancel
Showing results for 
Search instead for 
Did you mean: 

change the text of the button at runtime.

Former Member
0 Kudos

Hi All,

I am having two Input fields and two buttons Insert and EDIT/Display, I Have created Database table and iam inserting the records into the database table by entering into the input fields, After entering into the database table the button EDIT should be changed to Display.

Up on inserting data in to database table the button name should change,

Pls provide the code.

Thanks,

Harish.G

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

I tried what you all said but the problem was not solved.

can u pls suggest any more code.

ThankQ.

Former Member
0 Kudos

Have you statically specified any text in the button property? Can you remove that and bind to a string attribute. This is the only code to change text and you do not need anything more. What is the problem you are facing?

See this [thread|; also, which is for the same problem.

Regards,

Nithya

Former Member
0 Kudos

hi

I am getting the following error.

Note

The following error text was processed in the system RT1 : The lead selection has not been set. MAIN_VIEW ?ꯂ큳??

The error occurred on the application server winserv_RT1_00 and in the work process 0 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: RAISEELEMENT_NOT_FOUND of program CL_WDR_CONTEXT_NODE===========CP

Method: PATH_TABLE_GET_ELEMENT2 of program CL_WDR_CONTEXT_NODE===========CP

Method: GET_BOUND_ELEMENT of program CL_WDR_VIEW_ELEMENT_ADAPTER===CP

Former Member
0 Kudos

Declare the button text directly as an attribute of your context, then do a set_attribute. To do this, you can read the context attribute using the code wizard and just change the call of the get_attribute method to set_attribute by exporting both name and value.

Regards,

Nithya

Former Member
0 Kudos

Hi,

Create a context node BUTTON_TEXT with cardinality 0..1. Create an attribute EDIT_DISP in the context node, of type STRING.

Bind the 'text' property of the EDIT button, to the EDIT_DISP attribute.

In the ONCLICK event handler of the button EDIT, write the following code (modify the logic as reqd):


  data lo_nd_button_text type ref to if_wd_context_node.
  data lo_el_button_text type ref to if_wd_context_element.
  data ls_button_text type wd_this->element_button_text.
* navigate from <CONTEXT> to <BUTTON_TEXT> via lead selection
  lo_nd_button_text = wd_context->get_child_node( name = wd_this->wdctx_button_text ).

* get element via lead selection
  lo_el_button_text = lo_nd_button_text->get_element(  ).

* get all declared attributes
if lo_el_button_text IS NOT INITIAL.
  lo_el_button_text->get_static_attributes(
    importing
      static_attributes = ls_button_text ).
  if ls_button_text-edit_disp = 'EDIT'.
    ls-button_text-edit_disp = 'DISPLAY'.
  endif.
lo_nd_button_text->bind_element( ls_button_text ).
endif.

Regards,

Wenonah

Former Member
0 Kudos

Hi harish,

U might have written a method to pass the data to the database rite.

declare a attribute in the context also with type string if required u can give a default value to the button as 'Edit' and bind to the button which u want the text to be changed.

after successful passing, declare a string.

and assign lv_string = 'Display'.

and set the attribute of the button to lv_string.

now after the successful passing the name of the button will be changed to 'display' from edit.

Regards...

Arun.