cancel
Showing results for 
Search instead for 
Did you mean: 

How can i change a selected table row at runtime that the selection get not lost?

Former Member
0 Kudos

Hi Experts,

How can i change a selected table row at runtime that the selection get not lost? (WebDynpro ABAP from UIELEMENT „TABLE“)

In my case i have a table with many rows and when i push on a row the WebDynpro method onSelect (names „SET_LOCK“) get started.

After bind_table the table lost the selection and the declareted attribute wd_this->vt_element_set get (type WDR_CONTEXT_ELEMENT_SET)

lost the reference of my context node and the Webdynpro Application get a dump by method wa_rows->set_selected( flag = 'X' ).

method ONACTIONSET_LOCK .

*//Declaration DATA ld_node TYPE REF TO if_wd_context_node.

DATA ld_element TYPE REF TO if_wd_context_element.

DATA: it_lock type STANDARD TABLE OF if_tabelle=>element_tb_view,      

          wa_lock like line of it_lock. DATA: wa_selrow like line of it_lock,      

          it_rows type WDR_CONTEXT_ELEMENT_SET,      

          wa_rows like line of it_rows, DATA h_tabix type sy-tabix.

DATA lv_icon TYPE wd_this->Element_tb_view-icon.

DATA lv_verarb_user TYPE wd_this->Element_tb_view-verarb_user.  

ld_node = wd_context->get_child_node( name = 'TB_VIEW' ). 

it_rows = ld_node->GET_SELECTED_ELEMENTS( ).

if it_rows is not initial.

 

    ld_element = wd_context->get_element( ).  

    READ TABLE it_rows INTO wa_rows INDEX 1.  

    READ TABLE wd_this->vt_element_set WITH KEY table_line = wa_rows TRANSPORTING NO FIELDS.  

IF sy-subrc EQ 0.    

     wa_rows->set_selected( flag = space ).    

     DELETE wd_this->vt_element_set WHERE table_line EQ wa_rows.  

ELSE.    

     APPEND wa_rows TO wd_this->vt_element_set.  

ENDIF.  

LOOP AT wd_this->vt_element_set INTO wa_rows.    

     wa_rows->set_selected( flag = 'X' ). 

      clear wa_selrow. 

CALL METHOD wa_rows->get_static_attributes IMPORTING static_attributes = wa_selrow.    

h_tabix = wa_rows->get_index( ).

*//Call Function Modules etc….  

wa_selrow-icon = 'ICON_LOCKED'.  

wa_selrow-verarb_user = sy-uname.  

MODIFY it_lock INDEX h_tabix FROM wa_selrow TRANSPORTING verarb_user icon.

ld_node = wd_context->get_child_node( 'TB_VIEW' ).

ld_node->BIND_TABLE( it_lock ).

ld_node = wd_context->get_child_node( name = 'TB_VIEW' ).

clear wa_rows.  

LOOP AT wd_this->vt_element_set INTO wa_rows.

     wa_rows->set_selected( flag = 'X' ).

***Get a dump!!!

***Message: The element is not bound to a node.       

ENDLOOP. endif.

ENDLOOP.

Thanks for any answer.

Regards,

Richard

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello back,

Unfortunately your solutions don't work.

Can you give me a source code for my example?

@Stefan:

These commands i try, but the modified values don't change the table content.

In my case, the icon column of the selected row must change into a lock symbol (Icon: ICON_LOCKED) and the user (sy-user) at runtime without selection get lost (see above source code).

@Kavin:

I have a multiple selection of the table.

@Chengalarayulu

All rows must be preserved after the selected row changed.

Best regards.   

chengalarayulu
Active Contributor
0 Kudos

Richard,

Please check the binding of node data, is it bound at right place or not. Node is bound inside the loop, is it really required, then.. set the initial elements as false.

If required binding inside the Loop..

ld_node->BIND_TABLE( it_lock ).

else.

ld_node->BIND_TABLE( new_items = it_lock set_initial_elements = abap_false ).

Former Member
0 Kudos

Hi Richard,

Get the Index of the selected element of table and store it in Variable and after binding to same table set lead selection to the particular Index stored in Variable.

Hope this Help you.

StefanRoesch
Active Participant
0 Kudos

Hi Richard,

after the "bind_table" you have completely "new" element objects within your node and can't use the old references.

If you what to change values within your table you better just work with the element objects and then set the modified values by "set_attribute" or  "set_static_attributes"

regards,

Stefan