cancel
Showing results for 
Search instead for 
Did you mean: 

Activating/deactivating buttons at runtime

Former Member
0 Kudos

Hi,

I need to activate/deactivate buttons at runtime in method WDDOMODIFYVIEW.

I have tried the following:

DATA:

lr_button TYPE REF TO cl_wd_button.

lr_button ?= view->get_element( id = 'APPROVE' ).

lr_button->set_enabled( value = abap_false ).

I get the following error message: "Dynamic type conflict when assigning references"

Thanks,

Morten

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Morten,

Can you check in debug mode the exact line of code causing error ? to me it seems that its happening not in the line of code you pasted above.

Greetings

Prashant

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

First I strongly recommend that you not use coding in the WDDOMODIFYVIEW to control the enabled flag of such a UI element. Instead just data bind the enabled property to a context attibute and change the value of the context attribute to control the button state. This is the suggested way. WDDOMODIFYVIEW should only be used as a last resort to manipulate totally dynamically generated UIs. Otherwise design time binding should always be used.

Your specific error would seem to be coming becuase the UI element with the ID APPROVE isn't being returned as a button, I would guess. That would explain the type conflict. Make sure that APPROVE really is the button's ID and that you haven't accidentally chosen a different UI element. In order to debug you could declare lr_button as type ref to CL_WD_UIELEMENT. This is the generic super class and should avoid the type conflict. From the debugger you can see the sepecif class type that was passed back by GET_ELEMENT.