cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable a button dynamically ?

Former Member
0 Kudos

Hi

Is there a way to set the ENABLE property of an UI-element button dynamically without creating a new attribute and bind it to the element and dynamcally change its value?

I want to find a way to do it without the creation of the attribute because i have severals buttons in my WD application and i dont want to create a lot of attributes in my context for each button (every button is enable/disable in different situations).

Thanks

Elad 

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor
0 Kudos

Hi Elad,

You can toggle a button's enabled property with the following code (here, wd_this refers to the current view)...

DATA lo_view        TYPE REF TO if_wd_view.
DATA lo_button     TYPE REF TO cl_wd_button.
DATA lv_enabled  TYPE wdy_boolean.

* Get a reference to the VIEW, casting to the appropriate interface
   lo_view ?= wd_this->wd_get_api( ).

* Get a reference to the BUTTON that needs to be enabled/disabled 
   lo_button ?= lo_view->get_element( 'BUTTON' ).

* Determine if BUTTON is currently enabled or disabled 
   lv_enabled = lo_button->get_enabled( ).

* Toggle BUTTON enabled or disabled
   CASE abap_true.
        WHEN lv_enabled.
              lo_button->set_enabled( abap_false ).

        WHEN OTHERS.
              lo_button->set_enabled( abap_true ).
   ENDCASE.

Cheers,

Amy

former_member196213
Active Participant
0 Kudos

Hi Amy,

Thanks that was a great help. Although I was not into this issue but this will definatly help me in future.

Elad

Very nice question. Thankyou very much.

Hi Me,

Feeling happy, I learned something

HAPPY ABAPing

Cheers

Former Member
0 Kudos

Hi Amy

Thank u very much it worked !

Elad

Answers (2)

Answers (2)

former_member196213
Active Participant
0 Kudos

Hi Elad,

     See as here we dont have any primary atribute mentioned in the document for button. In document they are talking about e.g. input field which whose value is binded to some context attribute. here in our case there is nothing like which can be binded(In button). Anyways we are trying to ignore bindings here.

So our button will have no reference with any context attribute. Hence its a problem here. So I suggest if it dont work out. try to look whether we can get a UI element based on their ID. because here I am not able to reach to UI button as there is no context. If get it done. please share for sure.

nice question

HAPPY ABAPing

former_member196213
Active Participant
0 Kudos

Hi Elad,

     Yes you can do it, by making use of set_attribute_property method.

    

     For details,

          you can go through...

     http://help.sap.com/saphelp_nw04s/helpdata/en/45/d44e0cdff073b1e10000000a11466f/content.htm

     I hope it helps.

HAPPY ABAPing