on 11-04-2008 10:53 AM
Hi,
How can i get values of selected rows from ALV that has selection '0..n' (multiple selection) ?
Can somebody help me pls?
Thanks.
Hi Nurullah,
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
EXPORTING
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
IMPORTING
static_attributes = ls_node1.
APPEND ls_node1 TO lt_node1.
CLEAR ls_node1.
ENDLOOP.
ENDMETHOD.
Hope this helps resolve your problem.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rustam,
When you want to work with multiple selection on a table/ALV then you will have to go for a concept called SELECTION because using LeadSelection you can only always select 1 element (row). So there is a methog get_selected_elements in the interface if_wd_context_node. Whenever you make any multiple selection in an table/ALV the system would change the corresponding properties in the attached context node. So you first need to get a reference of the node that you have bound to your ALV like as shown below.
DATA: lr_node TYPE REF TO if_wd_context_node.
lr_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' ).
You then need to call the method get_selected_elements using this node reference.
lt_temp = lr_node->get_selected_elements( ).
This method returns back the selected rows in the format of CL_WDR_CONTEXT_ELEMENT. You need to convert it into the normal data format using the get_static_attributes method of if_wd_context_node as shown below:
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.
When you complete with the loops execution lt_node1 will contain the information from all the rows selected by the user. Hope that helps resolve your doubt.
Regards,
Uday
Hi Nurullah,
i have a table, which is not an ALV table. It should be possible to multiple select the rows, after selecting rows, the checkboxes on thiese rows should be selected automatcally.
So i want to do these in my onselect event of my table:
1- get the selected rows from the context node
2- a certain checkbox on each of these selected rows should be checked (this should be visible on the Browser).
Thanx and regards
Haleh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I think I understand where you mean. I am working on it. Thanx for your reply. Also these advices in this thread are good. If I can not get through, then i will post my question an a seperate question.
Maybe you can tell me how can i post a new question, still i couldn't see any Button or Icon on the forum page.
thanx
Haleh
the reason for the dump was "get_static_attributes" (created code by wizard fpr reading the contxt node).
Should I continue the steps from DOINIT event? Is the process just the same as ALV table?
Thank you
Haleh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry forgot something, i didn't do anything in the DOINIT event till now.
Regards, Haleh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Experts,
is there any differences between Multiple Selection Moder for ALV Table and normal table?
My table is not a ALV table. I did the steps up to the third step suggested by Uday in this thread. I did the 3.d step only by the table properties and changed the selection mode property from suto to muliNoLead. Now I get a dump each time i selected a row in the table.
The text of the error is something like this: access over 'NULL' object reference not possible
Would you help me in this issue please?
Thank you and regards
Haleh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much Uday,
i define lt_temp with WDR_CONTEXT_ELEMENT_SET type and it is solved.
Thanks again.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.