cancel
Showing results for 
Search instead for 
Did you mean: 

Changle fields dynmically editable to non-ediatble

tarangini_katta
Active Contributor
0 Kudos

Hi All,

I am working on webdynpro application.I have 3 fields and two buttons called 'create' and 'display'.

Intially my fields are in editable mode

1) .If i click on 'Display' on all fields should come to 'No-Editable' Mode.Please let me know how cani do this.

When i am clicking on 'display' my data is poulated perfectly.

2) When i click on 'create' all the data should be cleared or refreshed.

Can you please let me know how can i achieve this.

Thanks,

Taragini

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

1)Bind ur fields with the context attribute of type WDY_BOOLEAN. There is a value propery of ur field. Bind that property.

2) Now create a action for ur button . In the method OnAction of the button , u need to set the attribute , to '01' or ABAP_FALSE to make the field non editable

3) for this, u can go to code wizard. press control+f7. choose the radio button to read/set the attribute



  DATA lo_nd_cn_editable TYPE REF TO if_wd_context_node.
  DATA lo_el_cn_editable TYPE REF TO if_wd_context_element.

* navigate from <CONTEXT> to <CN_EDITABLE> via lead selection
  lo_nd_cn_editable = wd_context->get_child_node(
  name = wd_this->wdctx_cn_editable ).

* get element via lead selection
  lo_el_cn_editable = lo_nd_cn_visiblesuper->get_element(  ).

* set single attribute
  lo_el_cn_editable->set_attribute(
    EXPORTING
      name =  `CA_EDITABLE`
*    IMPORTING
      value = '01' ).
// context attribute ca_editable under the context node cn_editable
// set the attribute to '01' for dispaly mode

Similarly in the OnAction method of ur Create button , u can go to the code wizard and choose to read the context node , which is having all the attributes . there u can choose the method invalidate()


        lr_node = wd_context->get_child_node( name = lv_node ).
        lr_node->invalidate( ).

regards,

Amit

Former Member
0 Kudos

hi

when i use the code it is giving abap_false cant be changed when i write in display action .

Abap_true cant be changed when i write in doint( ).

could please clarify me why this errors is getting

Thanks & Regards

Deepika

Former Member
0 Kudos

Hello Deepika,

Please share your piece of code which you are writing in display action.

Regards

Pradeep

Former Member
0 Kudos

hi,

when using the set_attribute method don't use the IMPORTING parameter ..

for the WDY_BOOLEAN attribute , use the value ' ' for non editable and 'X' for editable..

instead of '01' and '02' as it is used for visibility and is a correction to the earlier post ..

regards,

Amit

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

First declare an attribute of type char1 with a default value as X.

Go to the input field. In the properties tab you can set the visibility of the field. Bind that field with the created attribute.

As the default value is X, initially all the fields will be editable.

When you click on display button, write the below code.

DATA lo_nd_nd_vis1 TYPE REF TO if_wd_context_node.
  DATA lo_el_nd_vis1 TYPE REF TO if_wd_context_element.
  DATA ls_nd_vis1 TYPE wd_this->element_nd_vis1.
  DATA lv_vis LIKE ls_nd_vis1-vis.

 lo_nd_nd_vis1 = wd_context->get_child_node( name =
wd_this->wdctx_nd_vis1 ).


  lo_el_nd_vis1 = lo_nd_nd_vis1->get_element(  ).


  lo_el_nd_vis1->set_attribute(
      name =  `VIS`
      value = ' ' ).

Former Member
0 Kudos

Hello,

First of all to make a field editable or display only You need to bind the read only property not the visiblity.

Visiblity property takes value '01' or '02'.

Regards

Pradeep

Former Member
0 Kudos

Ya sorry. Just misunderstood with the requirement.

@Tarangini

Please check the below link.

[Webdynpro ABAP - Sample Code|http://wiki.sdn.sap.com/wiki/display/WDABAP/SimpleapplicationtochangepropertiesofUIElementsduringruntimeinWebDynpro+ABAP]

It will give you the step by step procedure in using the visibility and enable property.

Former Member
0 Kudos

Hi Taragini,

This can be done easily with the following steps:

1. Create a view context attribute READ_ONLY_FLAG with type boolean.

2. For the input fields of your interests, associate the context attribute with the "readOnly" property.

3. In the action for Display button, set the value of READ_ONLY_FLAG contribute to 1. Vice versa, set READ_ONLY_FLAG to 0 in onActionCreate. Also clear the data in the same action.

Regards,

Min

tarangini_katta
Active Contributor
0 Kudos

Hi Min,

Thank u so much for your reply.Can you please let me know what is statement do i need to write to set the read flag.

Thanks,

taragini

Former Member
0 Kudos

Tarangini,

use the code wizard and set the context attribute which will give you all the code

Thanks

Bala Duvvuri