Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Runtime

Former Member
0 Kudos

Q. If a system does not "catch" a function code, AT USER-COMMAND is triggered. What is the purpose of AT USER-COMMAND?

1 ACCEPTED SOLUTION

gopi_narendra
Active Contributor
0 Kudos

AT USER-COMMAND is an event in interactive reporting

This event is executed whenever the user presses a function key in the list or makes an entry in the command field. Some functions are executed directly by the system and thus cannot be processed by programs.

Regards

Gopi

3 REPLIES 3

gopi_narendra
Active Contributor
0 Kudos

AT USER-COMMAND is an event in interactive reporting

This event is executed whenever the user presses a function key in the list or makes an entry in the command field. Some functions are executed directly by the system and thus cannot be processed by programs.

Regards

Gopi

former_member194669
Active Contributor
0 Kudos

Hi,

at.user-command is mainly used while setting pf-status which means creating our own menu with function codes or creating function codes for execution.

Former Member
0 Kudos

USER-COMMAND ucom

Effect

Clicking the pushbutton triggers the function code ucom. You can change this from the original definition (see SELECTION-SCREEN PUSHBUTTON). If you do not use the addition, the function code from the 'original' definition is used.

You can change the list-specific template if you have other requirements. You can

replace function code PICK with your own function code to prevent the AT LINE-SELECTION event from being triggered in the report. You can then program all reactions to user actions in a single processing block (AT USER-COMMAND).

delete predefined function codes whose functionality you do not want to support. For example, this allows you to prevent the user from printing the list or saving it in a file on the presentation server.

modify the standard key settings. For example, you can assign your own function code to F3 to navigate within the lists according to your requirements, instead of returning one list level ( Back). This may be important if you keep several lists on the same logical level and therefore do not want to delete the displayed list as would the standard F3 setting. Or you may want to display a warning before leaving a list level.

Setting a Dialog

Example for dialog status in a list.

REPORT demo_list_menu_painter.

START-OF-SELECTION.

SET PF-STATUS 'TEST'.

WRITE: 'Basic list, SY-LSIND =', sy-lsind.

AT LINE-SELECTION.

WRITE: 'LINE-SELECTION, SY-LSIND =', sy-lsind.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'TEST'.

WRITE: 'TEST, SY-LSIND =', sy-lsind.

ENDCASE.

This program uses a status TEST, defined in the Menu Painter.

Function key F5 has the function code TEST and the text Test for demo.

Function code TEST is entered in the List menu.

The function codes PICK and TEST are assigned to pushbuttons.

The user can trigger the AT USER-COMMAND event either by pressing F5 , or by choosing List ® Test for demo, or by choosing the pushbutton Test for demo.The user can trigger the AT LINE-SELECTION event by selecting a line.

Example of setting a dialog status for the current list

REPORT demo_list_set_pf_status_1.

DATA: fcode TYPE TABLE OF sy-ucomm,

wa_fcode TYPE sy-ucomm.

START-OF-SELECTION.

wa_fcode = 'FC1 '. APPEND wa_fcode TO fcode.

wa_fcode = 'FC2 '. APPEND wa_fcode TO fcode.

wa_fcode = 'FC3 '. APPEND wa_fcode TO fcode.

wa_fcode = 'FC4 '. APPEND wa_fcode TO fcode.

wa_fcode = 'FC5 '. APPEND wa_fcode TO fcode.

wa_fcode = 'PICK'. APPEND wa_fcode TO fcode.

SET PF-STATUS 'TEST'.

WRITE: 'PF-Status:', sy-pfkey.

AT LINE-SELECTION.

IF sy-lsind = 20.

SET PF-STATUS 'TEST' EXCLUDING fcode.

ENDIF.

WRITE: 'Line-Selection, SY-LSIND:', sy-lsind,

/ ' SY-PFKEY:', sy-pfkey.

AT USER-COMMAND.

IF sy-lsind = 20.

SET PF-STATUS 'TEST' EXCLUDING fcode.

ENDIF.

WRITE: 'User-Command, SY-LSIND:', sy-lsind,

/ ' SY-UCOMM:', sy-ucomm,

/ ' SY-PFKEY:', sy-pfkey.

Suppose that the function codes FC1 to FC5 are defined in the status TEST and assigned to pushbuttons: The function code PICK is assigned to function key F2 .

When the program starts, the user can create detail lists by selecting a line or choosing one of the function codes FC1 to FC5. For all secondary lists up to level 20, the user interface TEST is the same as for the basic list:

On list level 20, EXCLUDING ITAB deactivates all function codes that create detail lists. This prevents the user from causing a program termination by trying to create detail list number 21.

Example of setting a dialog status for the current list

REPORT demo_list_set_pf_status_2.

START-OF-SELECTION.

WRITE: 'SY-LSIND:', sy-lsind.

AT LINE-SELECTION.

SET PF-STATUS 'TEST' IMMEDIATELY.

After executing the program, the output screen shows the basic list and the user interface predefined for line selection (with function code PICK).

When you choose Choose, the user interface changes. However, since the AT LINE-SELECTION processing block does not contain an output statement, the system does not create a detail list: The status TEST is defined as in the previous example.

Example: Titles of detail lists.

REPORT demo_list_title .

START-OF-SELECTION.

WRITE 'Click me!' HOTSPOT COLOR 5 INVERSE ON.

AT LINE-SELECTION.

SET TITLEBAR 'TIT' WITH sy-lsind.

WRITE 'Click again!' HOTSPOT COLOR 5 INVERSE ON.

In this program, a new title is set for each detail list. The title is defined as follows: "Title for Detail List &1".