Handling Keyboard Actions
Some keys on the keyboard have special meaning in ALV and you can assign specific functions to others:
·
F1 Function Key
The user calls a help text for the selected column using the F1 function key.
·
F2 Function Key
This key is always an alternative to double clicking. You determine which
function is triggered when the user double clicks or presses F2. You cannot change its meaning.
·
F4 function key
With the F4 function key, users call a value list with possible entries that
are possible and useful for their current situation.
You are able to make the following settings for key settings:
· Using an F1 Help Text for Another Data Element
· Assigning any functions to keys
In the tree structure, you are able to specify functions for a selection of keys and key combinations that are to be executed when the user presses these buttons.
Display type ALV Tool |
Classic ABAP list |
Full screen |
In the Container |
Simple, two-dimensional table |
No |
No |
No |
Hierarchical-sequential list |
No |
|
|
Tree structure |
|
Yes |
Yes |
You proceed in two steps:
· You specify which of the possible keys trigger the event KEYPRESS of class CL_SALV_EVENTS_TREE. You repeat this specification for every key that you wish to register for the event.
· You specify which function will be executed when the user presses the appropriate key. To do this, register the application for the event and program the desired event handler.
You can assign the following keys and key combinations in the tree structure with the desired functions:
· F1 function key
· F4 function key
· Remove
· Enter key
· Insert
· Control plus X
· Control plus C
· Control plus V

By default, each key listed here is used for very specific purposes (for example, with the F4 function key, the user calls a dialog box with a value list of the permitted or useful entries for the current column). Find out about the conventions in your company as to the meaning of the individual keys. SAP recommends that you do not change the original objectives of the keys.
Methods
Function |
Class |
Method |
Register the key for an event |
CL_SALV_EVENTS_TREE |
ADD_KEY_FOR_KEYPRESS |
Delete entire list of keys that trigger the event |
REMOVE_ALL_KEYS_ |