cancel
Showing results for 
Search instead for 
Did you mean: 

Readonly View

shankar_gomare
Explorer
0 Kudos

Hi All,

I want to make view readonly.. all elements on view should be ready only..any suggestions.

Thanks in advance.

Shankar Gomare

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi ,

the method Get_elements returns all elements of a context node .

so set the context attribute which is binded to the UI elements to ABAP_FALSE to make your view read only.

regards,

amit

shankar_gomare
Explorer
0 Kudos

Hi,

Thank you for your reply, I know we can bind individual elements to context and set them accordingly, however dynamicall we need to get list of all elements on the screen and set them as readonly.

Regards,

Shankar Gomare

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You should consider the context approach the norm and it should be used under all but the most extreme circumstances. Even if you are dynamically generating the UI elements, you can generate them with the bindings to the context attribute for their enabled/read-only property.

However I can see a situation where you are performing an enhancement to an SAP component and you want to force the readonly status via code.

In this situation you can do so using the WDDOMODIFYVIEW method. This method has an importing parameter of VIEW that is TYPE REF TO IF_WD_VIEW. From here you can follow the same approach that CL_WD_DYNAMIC_TOOL=>CHEDCK_MANDATORY_ATTR_ON_VIEW uses. Specifically have a look at the local class LCL_MANDATORY_CHECK=>GET_MANDATORY_ELEMENTS. This method uses the meta data tables (WDY_UI_PROP_DEF and WDY_UI_ELEM_DEF to recursively search through all the UI elements contained in the View. Once you have the IDs of all the UI elements, you can call the GET_ELEMENT method of the VIEW importing parameter. You then have an object reference to the UI element where you can call methods to change its property values.

phanir_mullapudi
Active Participant
0 Kudos

Hi Shankar,

Even I am looking for one single method.

Meanwhile., I did it by mapping the "Read-only" attribute of all editable view elements to a context attribute & setting it to 'X' or '' accordingly in a method & triggering it conditionally when i want( for eg. in view method WDDOINIT or WDDOMODIFY as per my requirement).

For elements like buttons, we can use the attribute "enabled" & map it to same context attribute (with inverse property, so that when an Input field is read-only ( read-only = X), then button is disabled (enabled = '' ) on the view & so on...

This works fine for me.

Thanks,

Phani