cancel
Showing results for 
Search instead for 
Did you mean: 

enable/disable input for Input Fields on a std. sap WD screen

Former Member
0 Kudos

Hi,

My requirement is to enable/disable the input on Input Fields on a std. sap WD screen. The approach that I followed --

-- Create an enhancement for the WD application.

-- Make change to the UI element property in the post-exit of WDDOMODIFYVIEW.

The problem is that I am not too sure of the code that I need to put in there in WDDOMODIFYVIEW..

I tried putting in the following code to modify attributes of input field 'COUNTRY'--


data: l_input type ref to cl_wd_input_field.
    l_input ?= view->get_element( 'COUNTRY' ).
    l_input->set_read_only( abap_true ).

But for some reasons this does not work. I get a dump related to READ ONLY .

Is there anything else which I need to do?

Thanks-

Harmeet.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Harmeet ,

Try using the method set_enable() of class CL_WD_INPUT_FIELD to enalbe/disable the UI element.

Also post some details of the dump you are getting.

Thanks,

Aditya.

Former Member
0 Kudos

Hi Aditya,

Using set_enabled() did solve my problem. Thanks for that. However, I am still wondering why set_read_only does not work.

I get the following dump when I use set_read_only() --

UNCAUGHT_EXCEPTION

Could not find attribute COUNTRY:READ_ONLY

Method: IF_WD_CONTEXT_NODE_INFO~GET_ATTRIBUTE of program CL_WDR_CONTEXT_NODE_INFO======CP

Method: IF_WD_CONTEXT_ELEMENT~SET_ATTRIBUTE of program CL_WDR_CONTEXT_ELEMENT========CP

Method: IF_WD_DATA_CONTAINER~SET_VALUE of program CL_WDR_DATA_CONTAINER=========CP

Method: SET_READ_ONLY of program CL_WD_ABSTRACT_INPUT_FIELD====CP

Method: PST4KXMI8SQG7W8CQ5JLARV8GQVR of program /1BCWDY/HKJZNBFJXTJO5PQ8RYVP==CP

Method: IF_WDR_VIEW_DELEGATE~WD_DO_MODIFY_VIEW of program /1BCWDY/HKJZNBFJXTJO5PQ8RYVP==CP

Method: DO_MODIFY_VIEW of program CL_WDR_DELEGATING_VIEW========CP

Method: MODIFY_VIEW of program CL_WDR_VIEW===================CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

If your requirement just needs to enable/disable the input fields,then rather than coding it you can go into input field's properties and uncheck "enable" which will disable input field on wd screen but will show the field.But if you uncheck the attribute's property(read only) at component controller context which will not only disable it rather will effect all the other views which are using this attribute getting disabled.So better go and uncheck enable property at view level itself.It has to work ,and if you want to change it in coding way go for "DashAbhilash" process as mentioned above,even that works based upon your requirement.

Thanks.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Why use a code based enhancement for such a change. You could have used component configuration or administrative personalizatoin to enable/disable or hide input fields without making any code changes.

former_member182500
Contributor
0 Kudos

Hi Thomas,

In my particular example, the input field I wanted to open up was an input field of a table column within a SAP standard component. The input field has it's read-only attribute set to "Bind to the property of the selected attribute" with property set to "Read Only". This context cannot be changed through customer enhancement directly in view layout maintenance.

Application CONFIGURE_COMPONENT for the input field within the table column only allows option Read-Only Access to be set to Yes, or Not Personalised, there isnt a NO option.

Hence needing the code to amend this SAP standard setting as far as I can see.

Kind regards,

JP.

Edited by: Jon-Paul Boyd on Apr 8, 2011 5:38 PM

Former Member
0 Kudos

Hi Harmeet,

For enabling or disabling input for input fields you can try the following.

1. Bind a context variable of type " WDY_BOOLEAN" to read only property of input field.

2. Set the value of context variable to ' X ' for enable and ' ' for disable.

write the code in wdDoModifyView method.

Try this because i used this process for my customized webDynpro and it worked. Same way you can also hide buttons.

Former Member
0 Kudos

Thought set_enabled() solved the issue. Still I am wondering why set_read_only does not work.

Dynpro Application -- /SAPSRM/WDC_UI_DO_SHIPTO

View -- V_DODC_SHIPTO

Former Member
0 Kudos

Hallo Harmeet,

How sure are you that 'Country' UI element is input field ?

Former Member
0 Kudos

Baskaran,

I am 100% sure that it is an Input Field .

If you can, you may validate it --

WD application -- /SAPSRM/WDC_UI_DO_SHIPTO

View -- V_DODC_SHIPTO

Country_Container -->Country.

Former Member
0 Kudos

Hi,

I trust you !!

what kind of attribute is 'COUNTRY' , can you please post the properties of COUNTRY attribute. Error message is saying that COUNTRY does not have the attribute read_only.

Former Member
0 Kudos

Country --

Properties -- Input Field

Read Only -- UNCHECKED

State -- Normal Item

ToolTip -- Binding exists

Value -- Binding Exists

Visible -- Yes

Former Member
0 Kudos

seems to me everything okay. Puzzling why it is not working for you. I shall post you when i have some solution.

Former Member
0 Kudos

Hi Harmeet ,

Can u please post the name of the Standard WD component?

Some components dont allow to some functionalites..

For Eg: I tried to hide the 'Next' and 'Previous' buttons of FPM component , FPM_GAF_COMPONENT and I got a very similar dump saying 'Could not find the attribute Visibility '

I then learnt that , its not possible to hide the buttons.

Thanks,

Aditya.

Former Member
0 Kudos

Hi Aditya,

/SAPSRM/WDC_UI_DO_SHIPTO -- standard WD component.

V_DODC_SHIPTO -- View.

COUNTRY -- Component.

former_member182500
Contributor
0 Kudos

Hi Harmeet,

Did you find a solution for this, as I get exactly the same issue, a dump stating the attribute "VOLUME:READ_ONLY" does not exist?

Kind regards, JP.

former_member182500
Contributor
0 Kudos

Hi Harmeet,

I found a solution to this. Like you I was getting a dump. The SAP standard input field element I was trying to open up into edit mode was set to read only mode via read only attribute bound to the property of the selected attribute with read only. I created a dummy boolean in my enhancement called INPUT_VOLUME_READ_ONLY and passed as per below. The field is now open for input, as method bind_read_only removes the existing binding.

DATA: lr_input_field TYPE REF TO cl_wd_input_field.

lr_input_field ?= view->get_element( id = 'INP_VOLUME' ).

lr_input_field->bind_read_only( 'INPUT_VOLUME_READ_ONLY' ).

Hope this helps,

JP.