Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 12, 2011 at 11:01 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 12, 2011 at 11:33 AM

    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'.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 12, 2011 at 12:05 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded