Object Oriented ALV using CL_SALV_TABLE also provide the factility to the programmer to determine whether and in which situation the user can select areas of the ALV output .it is possible to programmatically determine which area needs to be selected and which areas are not required to select. The user can select multiple columns and multiple rows in an Object Oriented ALV .
Similar to all other ALV applications , in order to achive this functionality you need to follow only 2 steps :Step 1 : Get the object reference of class CL_SALV_SELECTIONS by calling the method get_selections( ) of class CL_SALV_TABLE.
DATA : lo_selections TYPE REF TO cl_salv_selections.
lo_selections = lo_alv->get_selections( ).
STEP 2 : Call the set_selection_mode( ) method of class CL_SALV_SELECTIONS
CALL METHOD lo_selections->set_selection_mode
EXPORTING
value = if_salv_c_selection_mode=>multiple.
Please refer to the following source codes :
REPORT ztestr_alv_9.
TYPES : BEGIN OF gy_bseg,
bukrs TYPE bukrs,
belnr TYPE belnr_d,
gjahr TYPE gjahr,
buzei TYPE buzei,
wrbtr TYPE wrbtr,
END OF gy_bseg.
DATA : gt_bseg TYPE STANDARD TABLE OF gy_bseg INITIAL SIZE 1.
REFRESH : gt_bseg[].
SELECT bukrs belnr gjahr buzei wrbtr
FROM bseg
INTO TABLE gt_bseg
UP TO 10 ROWS.
IF sy-subrc IS INITIAL.
SORT gt_bseg BY bukrs belnr gjahr buzei .
ENDIF.
DATA : lo_alv TYPE REF TO cl_salv_table.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = gt_bseg.
CATCH cx_salv_msg .
ENDTRY.
*-- Enabling Selection Mode logic starts
DATA : lo_selections TYPE REF TO cl_salv_selections.
lo_selections = lo_alv->get_selections( ).
CALL METHOD lo_selections->set_selection_mode
EXPORTING
value = if_salv_c_selection_mode=>multiple.
*-- Enabling Selection Mode logic end
lo_alv->display( ).