Akshay vijayan
Akshay vijayan

Reputation: 31

Multiple selection of rows in ALV Grid

I need to enable multiple selection of rows in ALV grid (especially REUSE_ALV_GRID_DISPLAY). Currently to select more than one row, I'm using Ctrl + select rows. Is there any other way we can use? I'm using ABAP on ECC.

Upvotes: 0

Views: 12610

Answers (2)

Sandra Rossi
Sandra Rossi

Reputation: 13628

With REUSE_ALV_GRID_DISPLAY, you need to have a dedicated field in the ALV table to contain whether the line is selected or not, and the framework will understand that the ALV must enable the feature "multiple row selection":

TYPES: BEGIN OF ty_alv_line,
         selected TYPE abap_bool,
         carrid   TYPE scarr-carrid,
         carrname TYPE scarr-carrname,
       END OF ty_alv_line.
DATA(layout) = VALUE slis_layout_alv(
    box_fieldname = 'SELECTED' ).
SELECT 'X' AS selected, carrid, carrname FROM scarr INTO TABLE @DATA(scarr_table).
DATA(field_catalog) = VALUE slis_t_fieldcat_alv(
    ( col_pos = 1 fieldname = 'SELECTED' tech = 'X' )
    ( col_pos = 2 fieldname = 'CARRID'   ref_fieldname = 'CARRID'   ref_tabname = 'SCARR' )
    ( col_pos = 3 fieldname = 'CARRNAME' ref_fieldname = 'CARRNAME' ref_tabname = 'SCARR' ) ).
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    is_layout   = layout
    it_fieldcat = field_catalog
  TABLES
    t_outtab    = scarr_table
  EXCEPTIONS
    OTHERS      = 1.

NB: the example doesn't demonstrate the processing of selected lines (could be done by adding both a custom button and a subroutine to handle when it's pressed) ; the syntax above needs at least ABAP 7.40.

REUSE_ALV_GRID_DISPLAY multiple row selection

Upvotes: 0

mkysoft
mkysoft

Reputation: 5758

You need to SEL_MODE parameter during ALV creation.

  • A Multiple columns, multiple rows with selection buttons.
  • B Simple selection, listbox, Single row/column
  • C Multiple rows without buttons
  • D Multiple rows with buttons and select all ICON

Source: https://keremkoseoglu.wordpress.com/2009/06/29/cl_gui_alv_grid-line-selection-modes-in-abap/

Upvotes: 1

Related Questions