‎2015 Apr 01 8:30 PM
Hi,
Please, need some help.
In my ALV report - Using CL_SALV classes, how can I process multiple lines?
For example: I've set to display "select all button".
Need select a few lines, in this case, has been selected 2 rows and executed a call transaction using two rows. But there's something else to do, 'cause all rows in ALV report executed the Call Transaction.
Just found the following:
layout-box_fname = "field name".
layout-sel_mode = 'A'.
But to use in CL_GUI_ALV_GRID, I DO NOT want to change it right now, 'cause the ALV report is almost done.
What's the corresponding for 'BOX_FNAME' and 'SEL_MODE' of CL_GUI_ALV_GRID inside CL_SALV classes?
Thanks and Regards.
‎2015 Apr 02 12:09 AM
Hi Bruno,
In the method where you handle the event you need to use cl_salv_selections to see which rows are selected. then you perform the action only for these rows, by reading your internal table with the indexes in the selection. something like this :
data: lo_selections type ref to cl_salv_selections.
data lt_rows type salv_t_row.
data ls_row type 1.
lo_selections = lo_alv->get_selections( ).
lt_rows = lo_selections->get_selected_rows( ).
loop at lt_rows into ls_row.
read table lt_alv_table_data index ls_row.
* do the action
endloop.
You can also have a look at program SALV_TEST_TABLE_SELECTIONS
Regards,
Custodio
‎2015 Apr 02 12:09 AM
Hi Bruno,
In the method where you handle the event you need to use cl_salv_selections to see which rows are selected. then you perform the action only for these rows, by reading your internal table with the indexes in the selection. something like this :
data: lo_selections type ref to cl_salv_selections.
data lt_rows type salv_t_row.
data ls_row type 1.
lo_selections = lo_alv->get_selections( ).
lt_rows = lo_selections->get_selected_rows( ).
loop at lt_rows into ls_row.
read table lt_alv_table_data index ls_row.
* do the action
endloop.
You can also have a look at program SALV_TEST_TABLE_SELECTIONS
Regards,
Custodio
‎2015 Apr 02 12:19 AM
Hi,
Custodio, thanks for reply.
Worked fine, exactly what I needed.
DATA: lt_rows TYPE salv_t_row,
ls_rows TYPE i.
lt_rows = o_selections->get_selected_rows( ).
LOOP AT lt_rows INTO ls_rows.
READ TABLE it_outtab ASSIGNING <fs_outtab> INDEX ls_rows.
Thanks a lot.
‎2020 Feb 17 11:10 AM
For future visitors, concerning the other part of the question: "What's the corresponding for 'BOX_FNAME' of CL_GUI_ALV_GRID inside CL_SALV classes?
(which corresponds to adding a selection column at the left of rows, it's like a selection button in front of each row)
Answer: this feature is not enabled with SALV; but the rows can be still selected by clicking any of their cells
NB: the default selection mode is NONE (which in fact acts like SINGLE - select one row only (!?)) and can be changed to other modes like multiple rows by calling:
lo_selections->SET_SELECTION_MODE( IF_SALV_C_SELECTION_MODE=>MULTIPLE ).
‎2021 Feb 26 8:04 AM
‎2021 Feb 26 8:51 AM
zebashah22 Thanks. Please use the vote button in the side bar to "like" or "dislike" 😉
‎2021 May 20 8:14 AM