‎2008 Apr 04 12:49 PM
Hi all,
Where do we use At user command event,what is the role of this command
‎2008 Apr 04 12:51 PM
hi,
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.
Hope this helps, Do reward.
Edited by: Runal Singh on Apr 4, 2008 5:23 PM
‎2008 Apr 04 12:51 PM
Hi,
See the link
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba3ae35c111d1829f0000e829fbfe/content.htm
Regards,
Brown.
‎2008 Apr 04 12:52 PM
Hi,
Check the link below. It gives you detailed description.
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba34635c111d1829f0000e829fbfe/content.htm
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.
‎2008 Apr 04 12:54 PM
Hi,
At user-command is used when user wants to use any buttons,
means any menu painter options or applications toolbar options
Just have on look on example bellow.
In a Simple way to at the time of interactive reports.
Set pf-status asd.
Write: testing data with application toolbar components.
At user-command.
Case sy-ucomm.
When close or atc2.
Leave program.
When atc1.
Write: action is on application toolbar and we are in,sy-lsind,index report.
Endcase.
Reward,if useful.
Thanks,
Chandu
‎2008 Apr 04 12:56 PM
When a user chooses a function from a list, it triggers that function's function code. This function code, in
turn, triggers a corresponding event.
The system function codes are reserved and do not trigger an interactive event block. The system does
not go to the program, but instead executes a corresponding system function.
All function codes with the exception of "PICK" as well as all codes reserved for system use trigger the
event AT USER-COMMAND.
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.
Data is restored from the hide area to the corresponding global data fields for the line on which the
cursor was positioned.
example code
END-OF-SELECTION.
SET PF-STATUS 'S_BASE'.
SET TITLEBAR 'T_BASE'.
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.
...
User chooses a function
that you defined in the
program
(for example, by choosing
menu entry or pushbutton)
- F code sy-ucomm
- Hide data restored
- AT USER-COMMAND event
also follow the link
http://interviewhelper.blogspot.com/2008/02/sap-r3-interactive-reporting.html
do reward if helpful
Edited by: sharad narayan on Apr 4, 2008 1:56 PM
‎2008 Apr 04 1:18 PM
Hi,
One of the events of Interactive report is At user-command
We can add the push buttons will be added on the application toolbar and we can use menu items by using this user-command.
sample:
SET PF-STATUS 'ZSAMPLE'. " give the pf-status name
loop at itab.
hide itab-fieldname.
Endloop.
at user-command.
case sy-ucomm.
when EXIT'.
leave program.
when 'SELECT'.
select * from mara into jtab where fname = itab-fname.
Endcase.
This sample code deals with when we click EXIT button it will exit from the program and when we click select button it will select the data from the table.
‎2008 Apr 04 1:21 PM
hi there..
Executing User Commands (AT USER-COMMAND AND AT LINE-SELECTION)
AT USER-COMMAND event is used in interactive reporting. The code between the AT USER-COMMAND and the ENDAT command is executed when the user enters data into the OK code field(the upper-left entry field on the screen where you enter transactions). The data entered into the OK code field is stored in the system field SY-UCOMM.
Eg :
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'DETAIL'.
SELECT * FROM BSEG WHERE BELNR = BKPF-BELNR.
.....
ENDCASE.
The AT LINE-SELECTION comand defines the code thats executed after a user double-clicks a line or presses the F2 function key.
Eg :
AT LINE-SELECTION.
SELECT * FROM BSEG WHERE GJAHR = BKPF-GJAHR.
do reward if helpful.
‎2008 Apr 06 9:28 AM
at user command is the event in interactive report.
whenever the user perform the action on header area or menu area this event is triggered...
‎2008 Apr 06 11:45 AM
At user-command is the event used for secondary list.
If some action for example button click is performed on the secondary list,
the controls come to the at user-command in the prog.
So the code which to be executed for that coresponding action is written
inside the at user-command.
Reward if useful.
Edited by: bhavana gurajada on Apr 6, 2008 12:45 PM
‎2008 Apr 07 11:22 AM
Hi Naresh,
Example for AT USER-COMMAND.
REPORT demo_list_at_user_command NO STANDARD PAGE HEADING.
START-OF-SELECTION.
WRITE: 'Basic List',
/ 'SY-LSIND:', sy-lsind.
TOP-OF-PAGE.
WRITE 'Top-of-Page'.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.
CASE sy-pfkey.
WHEN 'TEST'.
WRITE 'Self-defined GUI for Function Codes'.
ULINE.
ENDCASE.
AT LINE-SELECTION.
SET PF-STATUS 'TEST' EXCLUDING 'PICK'.
PERFORM out.
sy-lsind = sy-lsind - 1.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'FC1'.
PERFORM out.
WRITE / 'Button FUN 1 was pressed'.
WHEN 'FC2'.
PERFORM out.
WRITE / 'Button FUN 2 was pressed'.
WHEN 'FC3'.
PERFORM out.
WRITE / 'Button FUN 3 was pressed'.
WHEN 'FC4'.
PERFORM out.
WRITE / 'Button FUN 4 was pressed'.
WHEN 'FC5'.
PERFORM out.
WRITE / 'Button FUN 5 was pressed'.
ENDCASE.
sy-lsind = sy-lsind - 1.
FORM out.
WRITE: 'Secondary List',
/ 'SY-LSIND:', sy-lsind,
/ 'SY-PFKEY:', sy-pfkey.
ENDFORM.
When you run the program, the system displays the following basic list with a the page header defined in the program:
You can trigger the AT LINE-SELECTION event by double-clicking a line. The system sets the status TEST and deactivates the function code PICK. The status TEST contains function codes FC1 to FC5. These are assigned to pushbuttons in the application toolbar. The page header of the detail list depends on the status.
Here, double-clicking a line no longer triggers an event. However, there is now an application toolbar containing five user-defined pushbuttons. You can use these to trigger the AT USER-COMMAND event. The CASE statement contains a different reaction for each pushbutton.
For each interactive event, the system decreases the SY-LSIND system field by one, thus canceling out the automatic increase. All detail lists now have the same level as the basic list and thus overwrite it. While the detail list is being created, SY-LSIND still has the value 1.
Regards,
Phani,
Points If Helpful.