‎2007 Feb 28 3:48 AM
Hi friends,
I have a small doubt. Can we user AT LINE-SELECTION & AT USER-COMMAND in one report..plz gimme an example.
Thanks is advance,
regards,
Ram
‎2007 Feb 28 3:53 AM
Hi,
Yeah you can use both of them together.
You can have a list output and when the user click on the list output you can do some call transaction. ( the code for this will be written in AT LINE-SELECTION )
You can also provide a download button to download the list output. ( The code for this will be writtin in AT USER-COMMAND)
Cheers
VJ
‎2024 Jan 05 11:48 AM
Hi,
please can you provide a sample code? both events in a single program.
Thank you
‎2007 Feb 28 3:59 AM
hi, try these with example i have given.
Write the set pf-status under start-of-selection,
In the set pf-status under the function keys give
F2 Pick Choose.
u can validate the at line-selection by taking..
At line-selection.
case sy-lsind.
when 1.
message....
when 2.
message....
endcase.
similarly, for At user-command.
case sy-ucomm.
when 'back'.
message...
when...
endcase.
____________________________________________________________________
Syntax
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
____________________________________________________________________
here is an example handling both the commands in a program.
EXAMPLE:
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.
Hope this may be helpful.
Sri.
pls:award points.
‎2007 Feb 28 4:21 AM
Hi Ram ,
Yes you can use both of them in a program.
At Line Selection is triggred when the user clicks on a line in the generated output , where as at user command when is triggred when the user performs some operation like clicking a button e.t.c
Regards
Arun
‎2007 Feb 28 4:34 AM
yes, we can use at line-selection and at user-command in a single report.
assign the function code PICK to CHOOSE( i.e., by default double click is assigned).
data:
begin of fs_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
end of fs_spfli,
t_spfli like standard table
of fs_spfli.
select *
from spfli
into corresponding fields
of table t_spfli.
loop at t_spfli into fs_spfli.
write:
/ fs_spfli-carrid,
fs_spfli-connid.
endloop.
set pf-status 'TEST'.
at line-selection.
write 'at line-selection'.
at user-command.
case sy-ucomm.
when 'CONNID'.
write 'connid'.
<some set of operations>
when 'CARRID'.
write 'carrid'.
<some set of operations>
endcase.
here's the example for ur ques...
‎2007 Feb 28 4:37 AM
REPORT demo_list_interactive_3 .
START-OF-SELECTION.
WRITE 'Basic List'.
AT LINE-SELECTION.
WRITE 'Secondary List'.
TOP-OF-PAGE DURING LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
WRITE 'First Secondary List'.
WHEN 2.
WRITE 'Second Secondary List'.
WHEN OTHERS.
WRITE: 'Secondary List, Level:', sy-lsind.
ENDCASE.
ULINE.refer
DEMO_LIST_AT_USER_COMMAND for user command u can get sample code in SE38,
DEMO_LIST_* then press F4 u will lots of code samples.
Hope this helsp.
Reward if u find helpful.