cancel
Showing results for 
Search instead for 
Did you mean: 

WDA SALV copy-function

davidwallner
Participant
0 Kudos

Hi,

i implemented an editable salv-list in my webdynpro for abap. So far the standard functions insert, delete and append work fine.

my question: is there a copy function in sap-standard or do i have to implement it by myself? if so, has anyone an idea how to implement it?

thx for any comments and best regards

david

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You would need to create one copy button to copy a particular row.

Write following code in copy button's action to copy selected records

DATA lt_el_records TYPE wdr_context_element_set.  
  DATA lo_nd_records TYPE REF TO if_wd_context_node.
  DATA lo_el_records TYPE REF TO if_wd_context_element.
  DATA ls_records TYPE wd_this->element_records.
  DATA lt_records_cpy TYPE TABLE OF z_struc_records.


*   navigate from <CONTEXT> to <records> via lead selection
  lo_nd_records = wd_context->get_child_node( name = wd_this->wdctx_records ).


*   get element via lead selection
  lo_el_records = lo_nd_records->get_element(  ).

*   @TODO handle not set lead selection
  IF lo_el_records IS NOT INITIAL.
    lo_el_records->set_selected(               "set lead selected element to selected true since it does not happen directly
                          flag = abap_true ).
  ENDIF.

* get all the elements*****************************************************
  lt_el_records = lo_nd_records->get_elements( ).

  
  LOOP AT lt_el_records INTO lo_el_records.
    IF lo_el_records->is_selected( ) EQ abap_true.

      lo_el_records->get_static_attributes(
      IMPORTING
        static_attributes = ls_records ).

      APPEND ls_records TO lt_records_cpy.
    ENDIF.
  ENDLOOP.


* append copied records
    lo_nd_records->bind_elements(
    EXPORTING
      new_items = lt_records_cpy
      set_initial_elements = abap_false ).

Regards,

Feroz

Edited by: Feroz Khan Pathan on Aug 7, 2009 11:06 AM