Skip to Content

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

binding multiple selected rows to table context

Hi friends,

Goodday. My requirement is in my first view i have a table with 10 fields and a button add. On clicking add button it shows a popup . In the popup a table with the same 10 fields will be displayed with datas. User selects multiple records and clicks on ok button in the popup and the records selected by the user alone goes to parent window (view1-table) .

Now I'm able to make user to select multiple rows. and in view2(popup view) in onactionok method i coded as below.

data: Node_Table_Popup type ref to if_wd_context_node,
        Elem_table_popup type ref to if _wd_context_element,
        Stru_Table_popup type if_vieew_popup=>Element_table_popup,
        lt_element type WDR_CONTEXT_ELEMENT_SET.

*navigate from <context> to <Table_popup> via lead selection
Node_table_popup = wd_context->get_childnode( Name = If_view_popup=>wdctx_table_popup ).

 lt_element = Node_table_popup->get_selected_elements(  ).

by coding as above i got the multiple selected rows in lt_elements. now friends can you tell me how to loop lt_element and bind this lt_elements into table_view1 context i.e first view table. i don know as lt_element is of type wdr_contex_element_set which is table type. Please do reply me.

Thanks,

Sudha.

Former Member
replied

Hi Sudha,

Please find the desired code snippet as shown below:

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.

You can also go through this [example|http://saptechnical.com/Tutorials/WebDynproABAP/Modalbox/page1.htm] in which the user enters a customer number in the main view & presses on a pushbutton. A popup is then displayed showing the list of all sales orders related to the customer in a table UI element. The user can then select a table row in the popup & click on a button to navigate back to the main view & display it in there. Hope that this resolves your problem.

Regards,

Uday

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question