cancel
Showing results for 
Search instead for 
Did you mean: 

Make the input fields dynamically read only on the basis of condition check

Former Member
0 Kudos

Hi Experts

I want to make the UI elements of my application dynamically read only on the basis of value in a flag. What will be the best way to achieve this? The layout is containing many input fields, all shud be made read only, if the flag is set.

Thanks in advance

Gaurav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Create a Attribute in the type of boolean, and bind the attribute each field read only property.

in windows init method write set attribute for boolean field

ln_boolean->set_attribute( exporting name = 'BOOLEAN' value = abap_true ).

and search for the flag value

if that flag value came meams again write a query ln_boolean->set_attribute( exporting name = 'BOOLEAN' value = abap_false ).

Hope this helps,

Regards,

Srinivasan.R

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Gaurav,

Create one attribute of type WDY_BOOLEAN say READONLY and bind this to all input fields READ ONLY property.

Now in your action or event ( When you want to make all these fields to reaad only ).

If FLAG = 'X'.

*   set single attribute
    lo_el_existing->set_attribute(
      name =  ` READONLY  `
      value = ABAP_TRUE ).

endif.

Cheers,

Kris.

Former Member
0 Kudos

Hi,

If all the fields depends on the same flag the solution of Srinivasan is Ok.

If not, Is not necessary to create an attribute for each UI element.

You can bind the property you want to its own property; in your case push the button "Define Context Element" of the property Read Only and choose the second radio-button: Bind to the property of the selected attribute: R Read Only

Then you can use this code in order to change this attribute dinamically:

CALL METHOD lo_el_your_element->set_attribute_property

EXPORTING

attribute_name = lv_att_name

property = 3 """""" Read Only; prop 1= visible, prop 2=required, prop 4= enabled

value = 'X'.