AT USER-COMMAND.
This statement defines an event block whose event is triggered by the
ABAP runtime environment if, during the display of a screen list, a function with a self-defined function code was chosen.
Self-defined function codes are all those that include character combinations, except for the following:
Table 1
Function code | Function |
%CTX | Call a context menu |
%EX | Exit |
%PC | Save to file |
%PRI | |
%SC | Search for ... |
%SC+ | Find next |
%SL | Search in office |
%ST | Save to report tree |
Table 2
Function code | Function |
BACK | Back |
P- | Scroll to previous page |
P-- | Scroll to first page |
P+ | Scroll to next page |
P++ | Scroll to last page |
PFILE name | Store list lines in a text file named abap.lst in standard character representation in the standard directory of the application server. If a name is entered using name, this is converted to lowercase letters and used as the file name. |
PL- | Scroll to first line of the page |
PL-n | Scroll n lines back |
PL+ | Scroll to last line of the page |
PL+n | Scroll n lines up |
PNOP | No effect |
PP- | Scroll back one page |
PP-n | Scroll n pages back |
PP+ | Scroll one page forward |
PP+n | Scroll n pages forwad |
PPn | Scroll to beginning of page n |
PRI, PRINT | |
PS-- | Scroll to first column |
PS++ | Scroll to last column |
PS- | Scroll one column to the left |
PS-n | Scroll n columns to the left |
PS+ | Scroll one column to the right |
PS+n | Scroll n columns to the right |
PSn | Scroll to column n |
PZn | Scroll to line n |
RW | Cancel |
This program works with a self-defined GUI status MYLIST. The function that is linked there with the function code MY_SELECTION causes the event AT USER-COMMAND during list display and also creates details lists.
REPORT demo_at_user_command.
START-OF-SELECTION.
SET PF-STATUS 'MYLIST'.
WRITE 'List line'.
AT USER-COMMAND.
IF sy-lsind = 20.
SET PF-STATUS 'MYLIST' EXCLUDING 'MY_SELECTION'.
ENDIF.
CASE sy-ucomm.
WHEN 'MY_SELECTION'.
WRITE: / 'You worked on list', sy-listi,
/ 'You are on list', sy-lsind.
...
ENDCASE.