cancel
Showing results for 
Search instead for 
Did you mean: 

Disable button based on the value in the context attribute

Former Member
0 Kudos

Hi,

I have a scenario in my webdynpro abap application where a button should be disabled/enabled based on the value populated in the context attribute at run time to which the button is binded.How can this be handled.

I appreciate your help.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please create a node in the context of the concerned view.

Under that node create an attribute 'visible' (example) of type WDUI_VISIBILITY.

Go to the layout, bind this attribute to the Visible property of the button.

In my case I had another button, clicking on which the hidden button will be displayed.

So in the event created for this button I put the following logic.

DATA lo_nd_visibility TYPE REF TO if_wd_context_node.

DATA lo_el_visibility TYPE REF TO if_wd_context_element.

DATA ls_visibility TYPE wd_this->element_visibility.

  • navigate from <CONTEXT> to <VISIBILITY> via lead selection

lo_nd_visibility = wd_context->get_child_node( name = wd_this->wdctx_visibility ).

  • get element via lead selection

lo_el_visibility = lo_nd_visibility->get_element( ).

  • get all declared attributes

lo_el_visibility->get_static_attributes(

IMPORTING

static_attributes = ls_visibility ).

CALL METHOD lo_nd_visibility->set_attribute

EXPORTING

value = '02'

name = 'VISIBLE'

.

wd_this->fire_to_main_plg(

).

Reward if Helpful.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

create a context attribute 'enable' TYPE WDY_BOOLEAN.

Then bind this attribute to enable property of button.

Then based on condition use

set_attribute(exporting name = 'ENABLE' value = 'X' )

Former Member
0 Kudos

Hi Rohini

You can directly bind the enabled property of the button directly to context attribute(of type wdy_boolean).

When you set 'ABAP_TRUE' to this attribute the button is enabled and 'ABAP_FALSE' will disable the button during runtime using set_attribute method of respective context node.

Regards

Kartik

Former Member
0 Kudos

Thanks for all the answers

The component type for the attribute is WDUI_VISIBILITY. The values populated in the context attribute(value) are

01 and 02.

So if at run time the value =01 the button should be disabled

Value = 02 enabled.

Former Member
0 Kudos

Hi,

In WDDOMODIFYVIEW check the value of the context attribute and then call the method SET_ENABLED of class

CL_WD_BUTTON if the context value is 02.

As when u will enter the value for this field the WDDOMODIFYVIEW method will be called.

I hope it helps.

Revert back in case of issues.

Regards,

Sumit

baskaran00
Active Participant
0 Kudos

Hi rohini,

If the context attribute, binded to the button is boolean.

Depending upon the value(true/false) - button will be enabled/disabled.

If the contrext attribute is not boolean, then declare one more context attribute with type boolean.

U can check the populated value of ur context atribute and set the boolean value to the newly defined context attribute.

<<element name>>->set_attribute(

name = `<<context attribute name>>`

value = abap_false ). "abap_true for enable

Thanks,

Router

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi,

>

> I have a scenario in my webdynpro abap application where a button should be disabled/enabled based on the value populated in the context attribute at run time to which the button is binded.How can this be handled.

>

> I appreciate your help.

>

> Thanks

What kind of value in the context attribute are we talking about? Is it a true/false kind of value? If so you could bind the enabled property of the button directly to it (maybe use the inverse option on the binding if necessary).

Otherwise you will probably want to create a different context attribute to hold the enabled/disabled flag and bind the property to it.