Defining the Selection of Rows and Columns 
You can determine whether and how many rows or columns the user can select at a time.
Enabling selection of columns
Using the selection status, you specify whether and how many columns the user can select at a time.
Enable selection of rows
Using the selection type, you specify whether and how many rows the user can select at a time and whether a lead selection exists (see Context Node: Properties, under Lead Selection).
Note
The user can also change the selection of rows in a write-protected ALV output if the selection type allows this. However, if you deactivate the ALV output, the user cannot select any rows, regardless of the selection type.
More information: Controlling Write-Protection of the ALV Output
You can also prevent the user from selecting specific cells or all cells.
You can specify the selection status separately for each column. You can use the following selection statuses:
Not selected
Any existing selections are removed.
Selected
The column is selected.
Not selectable
The user cannot select the column.
To fix columns, use the methods of the class CL_SALV_WD_COLUMN.
Methods for Selection Status
Function |
Method |
Specify selection status |
SET_SELECTION_STATE |
Get selection status |
GET_SELECTION_STATE |
You can use the following selection types:
Automatic
The settings from the context node are applied.
No selection possible (NONE)
No pushbuttons for selecting rows are displayed at the start of the rows.
Single rows (SINGLE)
Pushbuttons are displayed at the start of the rows. The user can only select one row at a time. This row is displayed as the lead selection. If a user selects another row, the lead selection is also changed.
Single rows without lead selection (SINGLE_NO_LEAD)
Pushbuttons are displayed at the start of the rows. The user can only select one row at a time. If a user selects another row, the selection is also changed. The ALV output has no lead selection.
Multiple rows (MULTI)
Pushbuttons are displayed at the start of the rows. The user can select multiple rows by pressing the CTRL key. The first row selected is the lead selection.
Multiple rows without lead selection (MULTI_NO_LEAD)
Pushbuttons are displayed at the start of the rows. The user can select multiple rows by pressing the CTRL key. The ALV output has no lead selection.
Caution
You use the SELECTION property of your context node to specify how many data records can be selected.
Example: If you select the value 1..1 for SELECTION, one entry must always be selected. If the value is 0..n, it is possible to select no entries at all, or as many as required.
Using the selection type, you cannot allow the selection of more entries than the number defined in the context node. If you try to do this, a runtime error occurs and the application terminates.
Example: If you specified 1..1 for SELECTION in the context node, you cannot use the selection types MULTI and MULTI_NO_LEAD.
To define the selection type, you use the methods of interface class IF_SALV_WD_TABLE_SETTINGS (implementing class CL_SALV_WD_CONFIG_TABLE).
Methods for Selection Type
Function |
Method |
Specify selection type |
SET_SELECTION_MODE |
Get selection type |
GET_SELECTION_MODE |
There are two different events available to react to a selection of the user:
ON_LEAD_SELECT
The application reacts to a lead selection change of the end user.
For more information, see the documentation on the interface controller WD_SALV_TABLE in the system.
ON_SELECT
The application reacts to a lead selection or a selection change of the end user.
The system can raise only one of the above mentioned events. With the method IF_SALV_WD_TABLE_SETTINGS~SET_ON_SELECT_ENABLED you enable the event handler of the event ON_SELECT and deactivate the event handler of the event ON_LEAD_SELECT.
Note that, if the ON_SELECT event is enabled, a roundtrip is executed for each selection the end user is making. This event should only be enabled if it is necessary to get notified on selections, not only lead selections.
You can prevent users from selecting ALV output rows.
In contrast to the NONE selection type, the pushbuttons are not hidden; they are only deactivated. This enables you to prevent the user from selecting rows.
You can decide whether you want to prevent selection for all ALV output rows, or just for specific rows.
To do this, you use the methods of interface class IF_SALV_WD_TABLE_SETTINGS (implementing class CL_SALV_WD_CONFIG_TABLE).
Function |
Method |
|---|---|
Disallow selection for all rows in ALV output |
SET_ROW_SELECTABLE |
Check whether selection is disallowed for all rows |
GET_ROW_SELECTABLE |
Disallow selection for specific rows in ALV output |
SET_ROW_SELECTABLE_FIELDNAME |
Get name of field that controls whether individual rows can be selected |
GET_ROW_SELECTABLE_FIELDNAME |
For more information on using individual fields to control the behavior of rows or cells: Assigning Properties to Columns and Cells.