cancel
Showing results for 
Search instead for 
Did you mean: 

Make input field read only dynamically

former_member184111
Active Contributor
0 Kudos

Hello Experts,

I created an enhancement for a standard WD application and created post exit for WDDOMODIFYVIEW method.

There are multiple inputfields in layout. Some of which has their read_only property bound to a context attribute of type wdy_boolean , I was abel to make these fields read only using SET_ATTRIBUTE method.

There are some input fields which do not have the read_only property bound to any context attribute.

How to make such fields read only?

I can not create binding for these input fields since its a standard component and I can not modify the view.

Thanks,

Anubhav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Anubhav,

Thanks,

Prashant

former_member184111
Active Contributor
0 Kudos

Hi Prashant,

I am trying to make the input field read only without static binding of read_only property.

The thread you mentioned did not deal in that.

But many thanks for the help,

Anubhav

gill367
Active Contributor
0 Kudos

use this code in post exit..

data input type ref to cl_wd_input_field.
  input ?= view->get_element( 'INPUT' ).   "GIve the id of the input field of the here ... in my case it is  'INPUT'
input->set_enabled( abap_false ).

thanks

sarbjeet

Former Member
0 Kudos

Hi,

One way i think of is to get the reference of the input fields which you want to control (enable/disable).

Loop through them and set the property.

For example you can define the string_table consisting the Input field id's. Get the reference of the view in domodifyview at first time flag.

based on your requirement loop through the string_table and fetch the input_element using if_wd_view->get_element( )

down cost to the input field and set_enabled( ).

former_member184111
Active Contributor
0 Kudos

Hi Sarbjeet,

The logic works great but the only issue is it also makes the label for that inputfield grayed out.

Any chance to avoid that?

If i use

data lr_inputfield TYPE REF TO cl_wd_input_field.

lr_inputfield ?= view->get_element( 'C_O_NAME' ).

lr_inputfield->SET_READ_ONLY( abap_false ).

I get an exception

UNCAUGHT_EXCEPTION
Could not find attribute C_O_NAME:READ_ONLY
Method: IF_WD_CONTEXT_NODE_INFO~GET_ATTRIBUTE of program
CL_WDR_CONTEXT_NODE_INFO==========================CP
.
.
.
.
.
.
.
.
.
.
Method: DO_MODIFY_VIEW of program CL_WDR_VIEW

Its a very long exception....that i could not copy and paste .

Any inputs on this issue?

Many thanks for the help,

Anubhav

Former Member
0 Kudos

>

> The logic works great but the only issue is it also makes the label for that inputfield grayed out.

> Any chance to avoid that?

I think the reason for that might be that the labels are associated with the UI element enable property. Since the input elements are disabled the labels are also inactive. I am afraid you cannot do anything about this. Personally i would not change this behavior as it would me an inconsistent look and feel with other SAP standard screens.

> I get an exception

> UNCAUGHT_EXCEPTION

> Could not find attribute C_O_NAME:READ_ONLY

> Method: IF_WD_CONTEXT_NODE_INFO~GET_ATTRIBUTE of program

> CL_WDR_CONTEXT_NODE_INFO==========================CP

Probably you already know that. a) C_O_NAME is not exists in the view as input element-id or b) you have some piece of code trying to set the context_ attribute_property for a non existing attribute c_o_name.

I think it is to do with a).

Edited by: Baskaran Senthivel on Jan 17, 2011 9:13 PM

gill367
Active Contributor
0 Kudos

>

> Hi Sarbjeet,

>

> The logic works great but the only issue is it also makes the label for that inputfield grayed out.

> Any chance to avoid that?

>

> If i use

>

data lr_inputfield TYPE REF TO cl_wd_input_field.
> 
> lr_inputfield ?= view->get_element( 'C_O_NAME' ).
> 
> lr_inputfield->SET_READ_ONLY( abap_false ).

>

> I get an exception

>

UNCAUGHT_EXCEPTION
> Could not find attribute C_O_NAME:READ_ONLY
> Method: IF_WD_CONTEXT_NODE_INFO~GET_ATTRIBUTE of program
> CL_WDR_CONTEXT_NODE_INFO==========================CP
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> Method: DO_MODIFY_VIEW of program CL_WDR_VIEW

> Its a very long exception....that i could not copy and paste .

>

> Any inputs on this issue?

>

> Many thanks for the help,

> Anubhav

HI

the code is fine.

check the ID of the input field once again.

and i guess that is also correct other wise "access null error" would have come.

here i guess problem is somewhere you are trying to access the attribute C_O_NAME which is not existing.

search for it and correct the code there.

otherwise readonly code that you have written will work.

thanks

sarbjeet

sahai
Contributor
0 Kudos

hi anubhav,

you wrote....

The logic works great but the only issue is it also makes the label for that inputfield grayed out.
Any chance to avoid that?

just check the enabled property of the label....is the checkbox clicked ....if not just click the checkbox ...your label wont be grayed out.

regards,

sahai.s

Former Member
0 Kudos

Hi Anubhav,

Its seems to me no issue with your code , sarbjeet is right.Just check the ID of the input field once again.

I have used used the same code written by you and its working fine even the lebel is not grayed out.

data lr_inputfield TYPE REF TO cl_wd_input_field.

lr_inputfield ?= view->get_element( 'INP_JOB_ID_CP' ).

lr_inputfield->SET_READ_ONLY( ABAP_TRUE ).

Thanks & Regards,

Monishankar C

Former Member
0 Kudos

Hi,

Check if any method is there to make the fields Disable in cl_fitv_wd_util class.

Regards,

Pankaj Aggarwal

Answers (1)

Answers (1)

sahai
Contributor
0 Kudos

hi ,

check out this class in se24 cl_wd_input_field.....

you will see a property set_enabled ..using this i hope you will be able to solve this problem.

data i_field type ref to cl_wd_input_field.
  i_field ?= view->get_element( 'I_field' ).   
i_field->set_enabled( abap_false ).

above is the piece of code you can use

regards,

sahai.s