cancel
Showing results for 
Search instead for 
Did you mean: 

How can I make UI element as ReadOnly?

former_member194142
Participant
0 Kudos

Hello Experts,

In standard SAP's WD component, I need to make a field (in this case its LONG TEXT of type TEXT EDIT UI element) ReadOnly dynamically, meaning, for User_1 make the LONG TEXT field as ReadOnly and if its User_2 then make the same UI element as editable.


Already the UI element's ReadOnly property is bound with the VIEW's CONTEXT's ATTRIBUTE (in this case its LONGTEXT attribute again).

FYI: This VIEW's CONTEXT is mapped with the COMPONENT CONTROLLER's CONTEXT.

        And the UI element's VALUE property also bound w/ the same LONGTEXT attribute from the context.


Pls. check the below JPEG pic. by clicking it (also attached as file) and let us know how can we make ReadOny for User_1 and editable for User_2?

Accepted Solutions (0)

Answers (3)

Answers (3)

Gowtham
Contributor
0 Kudos

Hi ,

IF read only field is already used then check whether that attribute is used only for the require fields or any other fields also , If it used for only the required fields you can reuse the same attribute or else you can create one more same kind of attribute and control the property Enabled (Since read only property is already utilized).

- Gowtham

former_member197475
Active Contributor
0 Kudos

Hi,

Create a Post-Exit enhancement in your WDDOMODIFYVIEW.

Now check the logic w.r.t user.

If lv_user = 'User_1'.

{

* set single attribute

   lo_el_context->set_attribute_property(

     EXPORTING

       attribute_name = `LONGTEXT`  " Attribute Name

       property       3   " Property (See E_PROPERTY-*)

       value          =  abap_true   " Replacement for Real Boolean Type: 'X' == True '' == False

   ).

elseif lv_user = 'User_2'.

* set single attribute

   lo_el_context->set_attribute_property(

     EXPORTING

       attribute_name = `LONGTEXT`  " Attribute Name

       property       3   " Property (See E_PROPERTY-*)

       value          =  abap_false   " Replacement for Real Boolean Type: 'X' == True '' == False

   ).

Try it out

BR,

RAM.

former_member184741
Active Contributor
0 Kudos

hi,

create another attribute with char1 in the view context. bind that to the read only property of the ui elemnet. in modify method set the attribute with X or space as you need