When using an ALV control in Web Dynpro how to have multiple selection and the list of selected rows?

asked 19 Oct '11, 07:46

pedrolima's gravatar image

pedrolima ♦♦
accept rate: 32%

This answer from Uday Gubbala is good.

Steps to make multiple rows selectable in ALV:

1) Create the selection property of the node that you are binding to the DATA node as o..n

2) Un-check the, "Initialization Lead Selection" checkbox for the node which you are using to bind to the DATA node

3) In the WDDOINIT method specify the ALV's selection mode as MULTI_NO_LEAD. It is important that you set the selection mode to MULTI_NO_LEAD or else in the end you would be capturing 1 row lesser than the total number of rows the user has selected. This is because 1 of the rows would have the LeadSelection property & our logic wouldnt be reading the data for that row. Check the example code fragment as shown below:

DATA lo_value TYPE REF TO cl_salv_wd_config_table.
  lo_value = lo_interfacecontroller->get_model( ).

  CALL METHOD lo_value->if_salv_wd_table_settings~set_selection_mode
      value = cl_wd_table=>e_selection_mode-MULTI_NO_LEAD.

Steps to get the multiple rows selected by the user:

In order to get the multiple rows which were selected by the user you will just have to call the get_selected_elements method of if_wd_context_node. So as you can see its no different from how you would get the multiple rows selected by the user in a table ui element. First get the reference of the node which you have used to bind to the ALV & then call this method on it. Check the example code fragment below:

METHOD get_selected_rows .
  DATA: temp TYPE string.

  DATA: lr_node TYPE REF TO if_wd_context_node,
            wa_temp  TYPE REF TO if_wd_context_element,
            ls_node1 TYPE wd_this->element_node_flighttab,
            lt_node1 TYPE wd_this->elements_node_flighttab.

  lr_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' ).
" This would now contain the references of all the selected rows
  lt_temp = lr_node->get_selected_elements( ).

    LOOP AT lt_temp INTO wa_temp.
" Use the references to get the exact row data
      CALL METHOD wa_temp->get_static_attributes
          static_attributes = ls_node1.
      APPEND ls_node1 TO lt_node1.
      CLEAR ls_node1.
permanent link

answered 20 Oct '11, 04:26

cschand's gravatar image

accept rate: 25%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 19 Oct '11, 07:46

question was seen: 17,072 times

last updated: 20 Oct '11, 04:26