cancel
Showing results for 
Search instead for 
Did you mean: 

Problem when Make a Table cell as read only?

Former Member
0 Kudos

Hi all,

I want to make a table cell as read only based on some condition, i tried with following code, when condition met its working fine,

when one of the row not met with that condition i want to make that row cell only as editable, but all rows are in edit mode.

Please check the code...

I am comparing two columns if both quantities are equal, i am making another cell as read only, but my problem is if in one row quantites are equal and in another row not equal means both are in edit mode, i want to make only when condition met..

here is the code.

DATA lo_nd_it_lips TYPE REF TO if_wd_context_node.

DATA lt_it_lips TYPE wd_this->Elements_it_lips.

DATA ls_it_lips TYPE wd_this->Element_it_lips.

  • navigate from <CONTEXT> to <IT_LIPS> via lead selection

lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).

lo_nd_it_lips->get_static_attributes_table( importing table = lt_it_lips ).

loop AT lt_it_lips into ls_it_lips.

if ls_it_lips-lfimg = ls_it_lips-picked_qty.

DATA lv_edit TYPE wd_this->Element_context-edit.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • set single attribute

lo_el_context->set_attribute(

EXPORTING

name = `EDIT`

value = ABAP_TRUE ).

else.

  • set single attribute

lo_el_context->set_attribute(

EXPORTING

name = `EDIT`

value = ABAP_FALSE ).

Thanks,

Venkat

Edited by: venkat1011 on Apr 30, 2011 6:50 AM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Venkat,

I think you have created 'EDIT' attribute under the root context node and bound that attribute to the read only property of table coulmn. Thats the reason its not working.

Instead of that, create the attribute 'EDITABLE' in your context node which you are binding it to the table (it_lips) and bind that to the read only property of the table column which you want to make as read-only based on a condition.

in you code you just need to change the code for setting 'EDITABLE' attribute as now it is under a different context node.

Hope this helps!

Best Regards,

Srilatha

Former Member
0 Kudos

Hi srilatha,

Still same problem, all rows cells are editing.

here the code..

DATA lo_nd_zreturn_del_change TYPE REF TO if_wd_context_node.

DATA lo_el_zreturn_del_change TYPE REF TO if_wd_context_element.

DATA ls_zreturn_del_change TYPE wd_this->Element_zreturn_del_change.

DATA lv_edit TYPE wd_this->Element_zreturn_del_change-edit.

  • navigate from <CONTEXT> to <ZRETURN_DEL_CHANGE> via lead selection

lo_nd_zreturn_del_change = wd_context->get_child_node( name = wd_this->wdctx_zreturn_del_change ).

  • get element via lead selection

lo_el_zreturn_del_change = lo_nd_zreturn_del_change->get_element( ).

loop AT lt_it_lips into ls_it_lips.

if ls_it_lips-lfimg = ls_it_lips-picked_qty.

  • set single attribute

lo_el_zreturn_del_change->set_attribute(

name = `EDIT`

value = ABAP_TRUE ).

else.

  • set single attribute

lo_el_zreturn_del_change->set_attribute(

name = `EDIT`

value = ABAP_FALSE ).

Thanks,

Venkat.

former_member184578
Active Contributor
0 Kudos

Hi Venkat.,

For U i created a simple application ., go through this code.,

I Created a node name table with one attribute ID., and make this ID as input field and bind the readonly property of ID to the same.

go through this code then.,

DATA lo_nd_table TYPE REF TO if_wd_context_node.
  DATA ls_table TYPE wd_this->Element_table.
  DATA lt_table TYPE wd_this->Elements_table.

  DATA lo_el_table TYPE REF TO if_wd_context_element.

  DATA count TYPE i.

*   navigate from <CONTEXT> to <TABLE> via lead selection
  lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).

  ls_table-id = '1'.
  APPEND ls_table to lt_table.


  ls_table-id = '2'.
  APPEND ls_table to lt_table.

  ls_table-id = '3'.
  APPEND ls_table to lt_table.

  lo_nd_table->bind_table( new_items = lt_table set_initial_elements = abap_true ).


* get element via lead selection
  lo_el_table = lo_nd_table->get_element( ).
*

  LOOP AT lt_table INTO ls_table.
    count = count + 1.
    lo_el_table = lo_nd_table->get_element( index = count ).
    IF ls_table-id = '3'.
      lo_el_table->set_attribute_property(
       attribute_name =  `ID`
       property  = 3
       value =  'X' ).

    else.
      lo_el_table->set_attribute_property(
       attribute_name =  `ID`
       property  = 3
       value =  ' ' ).

    ENDIF.

  ENDLOOP.
endmethod.

It is working ., hope this helps u.,

Thanks & Regards

Kiran

Former Member
0 Kudos

hi venkat,

I think the node which you are binding to the table UI element is IT_LIPS. Isnt it??

In the recent code you posted, you had created the attribute 'EDIT' under zreturn_del_change. AS the node zreturn_del_change is not the one which you are binding to the TABLE ui element, this is not working.

Create the attribute 'EDIT' under the same node which you are binding to the TABLE UI element.

Hope this helps!

Best Regards,

Srilatha

Former Member
0 Kudos

Hi,

It_lips node is creted using dictionaru structure, now it is not allowing to create attribute? how can i create attribute in that node?

thanks,

venkat.

former_member187977
Participant
0 Kudos

Hi,

delete structure binding and create a attribute in that node. If deleting structure binding deletes all the attributes in the node, You have to do that. no way out.

Regards

seventyros

Former Member
0 Kudos

Hi

All attributes in that node are from dictionary structure and EDIT which i created as wdy_boolean.

I am Getting dump - access null values -- lo_el_it_lips is initial? so that giving dump. where is he problem?

thanks,

venkat.

Former Member
0 Kudos

Hi Kiran,

I tried with your code, but read only is not working even if condition met.

DATA lo_nd_it_lips TYPE REF TO if_wd_context_node.

DATA lo_el_it_lips TYPE REF TO if_wd_context_element.

DATA lt_it_lips TYPE wd_this->Elements_it_lips.

DATA ls_it_lips TYPE wd_this->Element_it_lips.

  • navigate from <CONTEXT> to <IT_LIPS> via lead selection

lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).

lo_nd_it_lips->get_static_attributes_table( importing table = lt_it_lips ).

DATA count TYPE i.

loop AT lt_it_lips into ls_it_lips.

count = count + 1.

lo_el_it_lips = lo_nd_it_lips->get_element( index = count ).

if ls_it_lips-lfimg = ls_it_lips-picked_qty.

lo_el_it_lips->set_attribute_property(

attribute_name = `PICK_QTY`

property = 3

value = ABAP_TRUE ).

else.

lo_el_it_lips->set_attribute_property(

attribute_name = `PICK_QTY`

property = 3

value = ABAP_FALSE ).

endif.

endloop.

Thanks,

Venkat.

former_member184578
Active Contributor
0 Kudos

Hi.,

Did u created PICK_QTY as input field and did u bind the readonly property of PICK_QTY to the same(PICK_QTY).

if u did so it will work..

check whether u bind the read only property of PICK_QTY... if not while create binding to table at PICK_QTY instead of enter press context binding button and select readonly..

hope this will help u.,

Thanks & Regards

Kiran

former_member184578
Active Contributor
0 Kudos

Hi.,

Did u created PICK_QTY as input field and did u bind the readonly property of PICK_QTY to the same(PICK_QTY).

if u did so it will work..

check whether u bind the read only property of PICK_QTY... if not while create binding to table at PICK_QTY instead of enter press context binding button and select readonly..

hope this will help u.,

Thanks & Regards

Kiran

Former Member
0 Kudos

Hi Venkat,

I hope now you were able to create the required attributes.

The problem might be that theres no lead selection for that node and/or its parent context node so when you tried to get a element of that node, you dont get anything. By the way, i dont think you need to read one context element but you would have to read all the context elements of that node IT_LIPS and loop over that elements table, set the attribute value according to your condition.

it would be something like this:

get the node reference to IT_LIPS using get_child_node( ).

get all elements using this node reference into an internal table

loop over the table.

check your condition

if condition is true

set the 'EDIT' attribute on this element

else

set the 'EDIT' attribute on this element

endif

end loop.

Always use debugging to find out where the problem is. Only that way we actually get to know whats happening inside the code and where exactly we are doing wrong.

When we try to get the elements of a child node, it depends on the lead selected element of its parent node. So check if you have enabled the lead selection for the parent nodes of 'IT_LIPS'

Can you please post the code if you are still not able to get it working??

Hope this helps!

Best Regards,

Srilatha

former_member187977
Participant
0 Kudos

Hi Vankat,

I think this can be done by making slight change in the code written by you. Though this can be done by reading the table's index also but you need not do so here. I did slight modification in the code written by, to see, please visit :

http://learnsaponline.blogspot.com/2011/04/scenario-is-to-make-tables-rows.html

regards

seventyros

Edited by: seventyros on Apr 30, 2011 8:08 AM

Former Member
0 Kudos

Hi Troys,

I tried what u suggest, but its giving dump.. Unable to interpret X as a number.

EDIT is one attribute of type wdy_boolean, in your code you are trring to use table column, how can we assaign read only property here???

Thanks

Venkat.

former_member184578
Active Contributor
0 Kudos

Hi.,

Here., I think U binded the column readonly property to EDIT attribute., so when the condition satisfies the column is in display mode else it will change the entire to edit mode.

If u want to make the individual row in edit mode which doestnt satisfies condition read the table index and change accordingly.

One more suggestion: please dont declare data inside loop., u declare all data statement and node assignment statements ouside loop.

hope this helps u.,

Thanks & Regards

Kiran

Former Member
0 Kudos

Hi Krian,

Thanks for your reply,

Can you give me any example to make read only using index?

Thanks,

Venkat.

former_member184578
Active Contributor
0 Kudos

Hi.,

Check this thread:

Also this wiki: http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynproforABAPCellVariants

Thanks & Regards

Kiran

Former Member
0 Kudos

Hi,

I know using cell variants also we can do this, i already tried this but same problem, so that i am trying alternate method.

Thanks,

Venkat.