Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to copy data from one node to another or fromone table to another table

Hi,

I have a two tables.I am populating data in first table and on the click of first table ,selected row data should be copied to the second table.

How do i achieve this requirement and what should be the cardinality of the second table

Thanks

Bala Duvvuri

Former Member
replied

Hello Bala,

I have 2 table UI elements. The user makes use of SELECTION to select desired row(s) & then presses on a "Copy" button in the tables toolbar. This would then copy the selected row(s) to the 2nd table ui element. Below is the coding for the same:

METHOD onactioncopy_selected_rows .
  DATA:  wd_node TYPE REF TO if_wd_context_node,
         ls_node1 TYPE ig_componentcontroller=>element_node1,
         lt_node1 TYPE ig_componentcontroller=>elements_node1,
         lt_node2 TYPE ig_componentcontroller=>elements_node2,
         wa_temp  TYPE REF TO if_wd_context_element,
         lt_temp  TYPE wdr_context_element_set.


  wd_node = wd_context->get_child_node( name = 'NODE1' ).

  CALL METHOD wd_node->get_selected_elements
    RECEIVING
      set = lt_temp.

  wd_node = wd_context->get_child_node( name = 'NODE2' ).

  LOOP AT lt_temp INTO wa_temp.
    CALL METHOD wa_temp->get_static_attributes
      IMPORTING
        static_attributes = ls_node1.
    APPEND ls_node1 TO lt_node1.
    CLEAR ls_node1.
  ENDLOOP.

  wd_node->bind_table( new_items = lt_node1 ).
ENDMETHOD.

NODE1:

Cardinality : 0..n

Selection : 0..n

Dictionary Structure: VBAK

Initialization Lead Selection is unchecked

NODE2:

Cardinality : 0..n

Selection : 0..n

Dictionary Structure: VBAK

Initialization Lead Selection is checked

Hope that this helps.

Regards,

Uday

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question