2

I've created an ALV with CL_GUI_ALV_GRID using the standard PBO/PAI but when I use the method I modify the layout to include checkboxes for every row by this way:

g_layout-zebra        = 'X'.
g_layout-cwidth_opt   = 'X'.
g_layout-cwidth_opt   = 'X'.
g_layout-sel_mode     = 'D'.
gv_variant-report     = sy-repid.
gv_variant-username   = sy-uname.

enter image description here

It shows as unchecked by default, how can I select all rows? And is it possible to select more than one row clicking the checkbox?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
usr1990
  • 21
  • 2
  • 7

2 Answers2

3

Manual way to select all rows

  1. Click the very first button in the header row. This will select all rows.
  2. Select the first row with the button, scroll to the very end and Shift+Click on the select button in the very last row

Via ABAP

Use the set_selected_rows method. Like

lo_alv->set_selected_rows(
  it_row_no = VALUE #( FOR i = 1 THEN i + 1 WHILE i <= lines( lt_sflight ) ( row_id = i ) )
).

(Assuming the displayed table is lt_sflight)

Additional documentation can be found here.

peterulb
  • 2,869
  • 13
  • 20
0

You can use set_selected_rows method like this.

  data: lr_selections type ref to cl_salv_selections,
        lt_rows       type salv_t_row,
        lv_count      type i.

  describe table gt_table lines lv_count.
  do lv_count times.
    append sy-index to lt_rows.
  enddo.

  lr_selections = gr_alv->get_selections( ).
  lr_selections->set_selected_rows( lt_rows ).
mkysoft
  • 5,392
  • 1
  • 21
  • 30