cancel
Showing results for 
Search instead for 
Did you mean: 

how to make fields uneditable at run time

Former Member
0 Kudos

Helllo,

I am working on a web dynpro application. In my application I have five fields on the screen g/l account, cost center, fund, date and amount. The requirement is, when a user enters cost center and hit enter all the fields but date should be non-editable at that time and the user should not be allowed to change anything after entering cost center and hitting enter (except cost center)... can you please let me know how can I made those fields uneditable.

Thank you.

Rajat

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Simply bind a context attribute to the readOnly property of all the fields you want to control. Then in the onEnter event of the main field, set the value of this bound context attribute to ABAP_TRUE to change the state of the corresponding UI elements.

Former Member
0 Kudos

Thanks for the reply , can you please explain a lil more on this as this is my first application and I am still learning.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

What I described is a really basic concept of Web Dynpro, so I guess I'm not sure what part you need further explanation on. You are famiilar with the concept of binding properties to the context right? Just like the value of your inputFields are bound to a context attribute, you can bind other properties of the UI elements as well. There is really no difference.

Former Member
0 Kudos

Hi Thomas,

I was clear with the first part, I created an attribute with type WDY_BOOLEAN and then I bound this to the readOnly property of all the fields you want to control. But I am not sure about the second part of your suggestion, I went to the onEnter event of the main field i.e. cost center in my case and after that I am not clear what I need to do.

I have written the following in the onenter event of the main field but it's not working:

DATA lo_el_context TYPE REF TO if_wd_context_element.
   DATA ls_context TYPE wd_this->element_context.
   DATA lv_editable TYPE wd_this->element_context-editable.

*  get element via lead selection
   lo_el_context = wd_context->get_element( ).

*  @TODO handle not set lead selection
   IF lo_el_context IS INITIAL.
   ENDIF.

*  @TODO fill attribute
*  lv_editable = 1.

*  set single attribute
   lo_el_context->set_attribute(
     name =  `EDITABLE`
     value = 'ABAP_TRUE' ).

Former Member
0 Kudos

Hi thomas,

I tried the following approach as well but this time I got another error:

DATA : lv_wdy_boolean TYPE wdy_boolean.
    DATA lo_el_context TYPE REF TO if_wd_context_element.
   DATA ls_context TYPE wd_this->element_context.

  lv_wdy_boolean = ''.
  CALL METHOD lo_el_context->set_attribute_property
    EXPORTING
      attribute_name = 'EDITABLE'
      property       = lo_el_context->e_property-read_only
      value          = lv_wdy_boolean.

I got this error "The following error text was processed in the system RD2 : Access via 'NULL' object reference not possible.

"

Thanks,

Rajat

Former Member
0 Kudos

I got rid of the error but both the approaches are not making the field cost center to be un editable.

any advise.

Former Member
0 Kudos

it's working now.,, I bounded the attribute incorrectly.

Edited by: rajatg on Feb 16, 2011 9:12 PM

Answers (0)