cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Attribute Property of 'Read-Only'

Former Member
0 Kudos

Hello,

I have a web dynpro application that has two views.  The first view has an input field called 'MATNR'.  The second view also has this field, but I would like to make it 'Read-Only' in this view.  I cam up with a possible solution after searching SCN and the internet, but it doesn't work.  Can anyone help with this problem ?  My code is as follows inside the WDDOMODIFYVIEW method in the second view.

Data:  lr_node TYPE REF TO if_wd_context_node.

          lr_elem TYPE REF TO if_wd_context_element.

          lv_bool TYPE wdy_Boolean.

lr_node = wd_context->get_child_node( NAME = PRODUCT1NODE ).

lr_elem = lr_node->get_element( index = 1 ).

lv_bool = ABAP_TRUE.

CALL METHOD lr_elem->set_attribute_property

        EXPORTING

               attribute_name = 'MATNR'

               property            = lr_elem->e_property-read_only

               value                = lv_bool.

Thank you,

Mike

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Michael,

Have you created boolean attribute for readonly ( for ex : matnr_readonly type boolean) and have you binded that attribute to the readonly property of the attribute ?....

Just bind the readonly attribute of the matnr with boolean attribute and your issue will be resolved.

Thanks

KH

Former Member
0 Kudos

Hello KH,

Thank you.....I just checked the 'Read-Only' box on MATNR on the second view layout and it works.  Evidently I don't need the dynamic coding in the second view in WDDOMODIFYVIEW method. 

Thanks again,

Mike 

Former Member
0 Kudos

Hi Michael.

Pls close the thread as answered if your issue is resolved. Else revert , We are happy to help you.

Thanks

KH

Former Member
0 Kudos

Hi KH,

I'm sorry, but I don't use the SCN very often and I don't see where to close the thread.

MIke

Former Member
0 Kudos

Hi KH,

It looks like just marking an answer as "correct" will close it as "Answered".  Please let me know if I need to do anything else to close the thread.

Thanks,

Mike

ramakrishnappa
Active Contributor
0 Kudos

Hi Michael,

You are done , nothing else is required from your end.

i.e. you just pick the correct answer and mark it as CORRECT ANSWER and other replies as HELPFUL ANSWERS if those helped you in resolving your issue.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Thanks for your feedback.

Mike

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Michael,

If you always want to keep this field 'Read Only', checking the checkbox is sufficient as you did. You need to use variable only if you want to change this property dynamically based on some condition.

Regards,
Arpit Agarwal

former_member222068
Active Participant
0 Kudos

Hi Michael,

To set the Input field UI element to read only, there is propery called Readonly.

1. Create an attribute Read type wdy_booelan,

2. Define context binding with the read only property to the  Read attribute.

Based on the condition, write code and set the property ABAP_TRUE for non-editable and ABAP_FALSE for editable.

Thanks & Regards,

Sankar Gelivi

Former Member
0 Kudos

Hello Sankar,

Thanks for your feedback.....much appreciated.....I found that just checking the box for 'Read-Only' on MATNR on second view seems to work.

Thanks again,

Mike