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: 

At user command

Former Member
0 Kudos

tell me more abot At -user- command

8 REPLIES 8

Former Member
0 Kudos

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.

Note

Self-defined function codes are all those that include character combinations, except for the following:

The function codes PICK and PF## ("##" stands for 01 to 24) do not cause the event AT USER-COMMAND, but the events AT LINE-SELECTION and AT PF##.

All function codes that start with the character "%" are interpreted as system functions and do not cause the event AT USER-COMMAND. The system functions for lists are listed in the following table 1.

The function codes in the following table 2, likewise, do not cause the event AT USER-COMMAND, but are handled by the list processor.

Former Member
0 Kudos

AT USER-COMMAND.

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. These include:

PICK

PFn

/...

System command

%...

System command

PRI

Print

BACK

Back

RW

Cancel

P...

Scroll function (e.g.: P+ , P- , PP+3, PS-- etc.)

Instead of this functions, you can use the SCROLL statement in programs.

Since many of these system functions begin with "P", you should avoid using this letter to start your own function codes.

Otherwise, the effect is as for AT LINE-SELECTION; also, the current function code is stored in the system field SY-UCOMM.

Example

DATA: NUMBER1 TYPE I VALUE 20,

NUMBER2 TYPE I VALUE 5,

RESULT TYPE I.

START-OF-SELECTION.

WRITE: / NUMBER1, '?', NUMBER2.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'ADD'.

RESULT = NUMBER1 + NUMBER2.

WHEN 'SUBT'.

RESULT = NUMBER1 - NUMBER2.

WHEN 'MULT'.

RESULT = NUMBER1 * NUMBER2.

WHEN 'DIVI'.

RESULT = NUMBER1 / NUMBER2.

WHEN OTHERS.

WRITE 'Unknown function code'.

EXIT.

ENDCASE.

WRITE: / 'Result:', RESULT.

After entry of a function code, the appropriate processing is performed under the event AT USER-COMMAND and the result is displayed in the details list.

Former Member
0 Kudos

hi kareem

see tis following code, now u hav some idea what s the of at user command

its similar like that of Process After Input in Dialog Programming

SELECTION-SCREEN BEGIN OF screen 100 as window.

SELECTION-SCREEN PUSHBUTTON 12(20) but1 USER-COMMAND CLK.

SELECTION-SCREEN end OF screen 100.

at SELECTION-SCREEN.

if sy-ucomm = 'CLK'.

message i000(zmsg).

endif.

START-OF-SELECTION.

call SELECTION-SCREEN 100 .

set PF-STATUS 'TEST'.

AT USER-COMMAND.

case sy-ucomm.

when 'BACK'.

leave to screen 0.

when 'TEST'.

message i000(zmsg).

endcase.

Former Member
0 Kudos

Hi,

AT USER-COMMAND.

<statements>.

In this event block, you can use an IF or CASE structure to tell the function codes apart. They are available in the system field SY-UCOMM. There are further system fields that are filled in list events, such as SY-LSIND and SY-PFKEY, that allow you to make further case distinctions.

The events START-OF-SELECTION, GET, END-OF-SELECTION, TOP-OF-PAGE and END-OF-PAGE

can be used only to create basic lists.

To create detail lists, use the events AT LINE-SELECTION and AT USER-COMMAND.

Use TOP-OF-PAGE DURING LINE-SELECTION for page headers on detail lists.

Each detail list event exists only once in the program and is shared by all detail lists. You must therefore

ensure yourself, within the processing block, that the correct list is created. To do this, use a CASE

structure that uses the system field sy-lsind. This system field contains the list index of the list that you

are currently generating.

When the user selects a line on an interactive list, all of the global data fields whose values you stored

using the HIDE statement while you were creating the basic list are filled with those values.

The line selection is based on the cursor position when the AT LINE-SELECTION and AT USERCOMMAND

events occur. (system field sy-lilli).

If you choose a line using the READ LINE... statement, . the values are placed back in the original fields

according to the line numbers.

AT USER-COMMAND.
 
CASE sy-ucomm.
WHEN 'FLGHT'.
SET TITLEBAR 'T_FLGHT'
WITH wa_spfli-carrid.
SET PF-STATUS 'S_FLGHT'.
...
WHEN 'BOOK'.
SET PF-STATUS 'S_BOOK' EXCLUDING 'BOOK'.
SET TITLEBAR 'T_BOOK'.
WITH wa_sflight-carrid wa_sflight-fldate.
...
ENDCASE.
...

You program AT USER-COMMAND as an interactive event and evaluate the system field sy-ucomm in a

CASE control structure. This field contains the current function code.

Thanks

Vikranth

Former Member
0 Kudos

Hi,

please refer to [Interactive Lists|http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba2c435c111d1829f0000e829fbfe/frameset.htm]

Regards Rudi

Former Member
0 Kudos

Hi,

At user command genrally we use to handle Function codes of the buttons and menu bar options.

Sy-Ucomm will give u the Function code at run time so that by using it u can perform some actions in ur program dynamically,

For more inforamtion

AT USER-COMMAND.

Effect

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.

Note

Self-defined function codes are all those that include character combinations, except for the following:

The function codes PICK and PF## ("##" stands for 01 to 24) do not cause the event AT USER-COMMAND, but the events AT LINE-SELECTION and AT PF##.

All function codes that start with the character "%" are interpreted as system functions and do not cause the event AT USER-COMMAND. The system functions for lists are listed in the following table 1.

The function codes in the following table 2, likewise, do not cause the event AT USER-COMMAND, but are handled by the list processor.

Table 1

Function code Function

%CTX Call a context menu

%EX Exit

%PC Save to file

%PRI Print

%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 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

Example

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.

Former Member
0 Kudos

hiii

AT USER COMMAND event provides different function keys.

AT USER COMMAND will b triggered when a button or any

element containing function code was clicked.That button or element is created by user.& we can give it a task after pressing it.So that task will come in this event.

reward if useful

thx

twinkal

Former Member
0 Kudos

this is used in all types of reports..

this will be used if you double click on a particular row or when any pushbutton pressed in the report or when enter or execure is pressed in the reports ...this is the basic thing of the interacative reports without this interactive reporting is not possible.....

this is used with the set pf-status ..

report.

start-of-selection .

set pf-status 'DEV'.

case sy-ucomm.

when 'ENTR'.

do some thing....

when 'BACK'.

leave to screen 0.

when 'PRN'.

print the following..

endcase .