cancel
Showing results for 
Search instead for 
Did you mean: 

Disable & Enabled Buttons

Former Member
0 Kudos

hi all,

I would like to disable a button B1 or enable it depend on some status in my application.

How i can disable or enable the button in WDA?

BR,

Ali

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ali,

In your WDDOMODIFYVIEW method try the following:

DATA lr_button              TYPE REF TO cl_wd_button.

 lr_button             ?= view->get_element( '<Your Button ID Name>' ).

Based on some condition you can now set the enabled property of your button here.

lr_button->set_enabled( exporting  value = 'X' or SPACE ).

Hope this is helpful.

Regards,

Abhinav

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks all

My Problem Solved.

Former Member
0 Kudos

Hi,

Create a context attribute of typemWDY_BOOLEAN and bind the enabled property of the button to this.

In the MODIFYVIEW method..

DATA:
    lr_btn  type ref to cl_wd_button,
    lv_btn_app_enable type wdy_boolean,                   " Enable
    lr_view_ele type ref to if_wd_view_element.

  CALL METHOD VIEW->GET_ELEMENT
    EXPORTING
      ID      = 'B1'        "Button Id
    RECEIVING
      ELEMENT = lr_view_ele.

***Gettig the button object reference for REVIEW button
  lr_btn ?= lr_view_ele.

--------------Put your condition here-------------
***Enable and Disable  button
        lv_btn_app_enable = abap_false.                    "Disable
        CALL METHOD wd_context->SET_ATTRIBUTE
          EXPORTING
            VALUE = lv_btn_app_enable
            NAME  = `BTN_APP_ENABLE`      "Context attribute

        CALL METHOD lr_btn->SET_ENABLED
          EXPORTING
            VALUE = lv_btn_app_enable.

Regards,

Lekha.

saket_abhyankar
Active Participant
0 Kudos

Hi ALi,

Bind the 'enabled' property of the button with context attribute of type char1.

When you want to enable it set the value to 'X' or ' ' (space) when you want to disable it.

Regards,

Saket.

Former Member
0 Kudos

hi Saket Abhyankar ,

How i can bind the property of the button?

BR,

Ali

arjun_thakur
Active Contributor
0 Kudos

Hi Ali,

If you click on the button UI element, you'll see its properties on the right side of screen. Find a property named enabled. There will be a button on its right side, click on it, list of attributes will be displayed. Select an attribute of WDY_BOOLEAN type and change its values according to your logic.

Regards

Arjun

saket_abhyankar
Active Participant
0 Kudos

Follow the steps:

1) Click on button in the layout

2) Goto Properties (Button) on right side pane

3) 4th prop is 'enabled'. Click on the button (3 rd column i.e. Binding) next to 'enabled' property.

4) This will open the popup of context attributes.

5) Map it with desired attribute (previously created of type char1)

Regards,

Saket.