Professional Documents
Culture Documents
ABAP: Events: Applies To
ABAP: Events: Applies To
Applies to:
This document applies to SAP ECC 6.0, SAP Net weaver 2004s.
Summary
This article describes about the overview of events used in ABAP Reports. It also explains the functionality of
each event with illustration.
Author Bio
Renuka Srinivasan is working as SAP Technology Consultant with Applexus Software
Solutions (P) Ltd.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 1
Events in Reports
Table of Contents
Events in Report Program..........................................................................................................................3
Events...........................................................................................................................................................3
Usage of Events...........................................................................................................................................4
Top_of_Page................................................................................................................................................4
New_Page.....................................................................................................................................................4
End_of_Page................................................................................................................................................4
At PF<nn>.....................................................................................................................................................4
At Line-Selection <Statements>.................................................................................................................5
At User-Command<Statements>................................................................................................................5
Load-of-Program..........................................................................................................................................5
Initialization..................................................................................................................................................5
At Selection-Screen.....................................................................................................................................5
Start-of-Selection.........................................................................................................................................5
End-of-Selection..........................................................................................................................................5
Examples......................................................................................................................................................6
Related Content.........................................................................................................................................14
Copyright....................................................................................................................................................15
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 2
Events in Reports
Events
ABAP/4 report programs are event driven programs. Following events are triggered in a report.
Load of Program.
Initialization.
At Selection screen.
Start of Selection.
End of Selection.
At Line Selection.
At PF-key.
At User-command.
Top-of-Page.
End-of-Page.
At New.
After a user interaction on a displayed output list, the ABAP runtime environment checks whether it should
process the function code itself (for example, %EX or %PC) and triggers the relevant event. Unlike normal
screens, in which the PAI event is triggered, the runtime environment triggers three special events when list
events occur. You can use the corresponding event blocks in your ABAP program to react to the user action.
From within the program, you can use the SY-UCOMM system field to access the function code.
USAGE OF EVENTS
Using of events depends on Type of Report. We are having INTERACTIVE Report and CLASSICAL Report
in SAP.
In case of INTERACTIVE REPORT we can use :( used to create a detailed list from a basic list)
AT LINE-SELECTION
AT USER-COMMAND
TOP-OF-PAGE During Line-Selection
END-OF-PAGE During Line-Selection
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 3
Events in Reports
LOAD-OF- PROGRAM
Triggers the associated event in an internal session after loading a program of type ‘1’, ‘M’, ‘F’, or ‘S’. Also
runs the associated processing block once for each program and internal session. The processing block
LOAD-OF-PROGRAM has roughly the same function for an ABAP program of type 1, M, F or S as a
constructor has for classes in ABAP Objects.
INITIALIZATION
This event is executed before the selection screen is displayed. It initializes all the values.
You can assign different values other than the values defaulted on the selection screen .You can fill your
selection screen with some values at runtime.
AT SELECTION-SCREEN
The event is processed when the selection screen has been processed (at the begin of PAI).
Validation & Checks of inputted values happen here. Extras ON VALUE-REQUEST for psel_low_high.
The push button for F4 (Possible entries) appears beside the appropriate field.
... ON HELP-REQUEST FOR psel_low_high ( Upper and Lower Limits in Select Option )
. ... OUTPUT, this event is executed at PBO of the selection screen every time the user presses ENTER.
START-OF-SELECTION
Here the program starts selecting values from tables. Processing block is executed after processing the
selection screen. All the data is selected in this block. All the main processing on the data except for
interactive reporting is handled in this block.
END-OF-SELECTION
After all the data has been selected this event writes the data to the screen. Data which is selected and has
been processed is printed to the screen in this block. List Processing happens in this block
TOP-OF-PAGE
Triggered by the first write statement in the program .It is used to have a standard header in the program for
all the pages. TOP-OF-PAGE is only executed before outputting the first line on a new page.
NEW-PAGE
Can be used when to display different data on different pages. Terminates the current page and continues
output on a new page. It will not trigger the Top-of-Page or End-of-Page.
END-OF-PAGE
It is used to display the standard footer for all the pages. This event displays the footer details like page
number , Number of records displayed and date etc...
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 4
Events in Reports
AT PF<nn>
These event blocks are executed when the user chooses the corresponding function key. The position of the
cursor in the list is irrelevant.
If you use these event blocks at all, it should only be for temporary test versions. In production programs
(Real time Projects), you should only use AT USER-COMMAND with a dialog status of your own to assign
function codes to function keys. When you use your own interfaces, the system displays a function text
explaining what the function does. This does not happen when you use AT PF<nn> event blocks.
When the user triggers the function code PICK, AT LINE-SELECTION is always triggered if the cursor is
positioned on a list line. The function code PICK is, by default, always linked with function key F2 and hence
with the mouse double-clicks. Consequently, if you have a simple program that does not react to any further
user actions, you only need to write this event block.
AT LINE-SELECTION <Statements>
As described in the section Dialog Status for Lists, the function code PICK is always added to the standard
list status when you have an AT LINE-SELECTION event in your program.
If you assign PICK to other function keys or menu entries, AT LINE-SELECTION is also triggered when the
user chooses then. You should avoid this for the sake of the semantics.
Conversely, if you have a more extensive program that does not react to line selection, you should not use
the function code PICK. Instead you should assign a different function code to F2 , to ensure that as many
events as possible trigger the AT USER-COMMAND event.
If the user chooses a function code during list processing that is neither processed by the system, or PICK or
PF<nn>, the system triggers the event AT USER-COMMAND. For this event, you must define your own GUI
status for a list.
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.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 5
Events in Reports
EXAMPLES
FOR AT-LINE-SELECTION
When you run the program, the basic list appears with the standard list status. The detail list shows that SY-
UCOMM has the value PICK.
Basic list
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 6
Events in Reports
Secondary List
FOR AT-PF
After executing the program, the system displays the basic list. The user can press the function keys F5, F6,
F7 and F8 to create secondary lists. If, for example the 4tth key user presses is F6 the out on the displayed
secondary list looks as follows.
Secondary List by PF-Key Selection-Screen
SY-LSIND = 4, SY-UCOMM = PF06.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 7
Events in Reports
Basic List
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 8
Events in Reports
FOR AT USER-COMMAND
When you run the program, the system displays the following basic list with 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
assigned to push buttons 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 5 user-command push buttons. You can use these to trigger the AT USER-COMMAND event.
The CASE statement contains a different reaction for each push button.
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 over write it.
While the detail list is being created, SY-LSIND still has the value 1.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 9
Events in Reports
Basic List
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 10
Events in Reports
This program creates basic list and three detail lists. When the program starts, the third detail list is displayed
immediately, along with a dialog box for searching in the list. The dialog box is displayed by setting the
predefined function code %SC. To view the other lists, the user chooses back.
NOTE: In the event AT PF05, the SET CURSOR statement is used to position the cursor on a list in order to
support the function code PICK.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 11
Events in Reports
Basic List
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 12
Events in Reports
Related Content
http://forums.sdn.sap.com/message.jspa?messageID=7978455
https://forums.sdn.sap.com/thread.jspa?threadID=485760
http://forums.sdn.sap.com/thread.jspa?messageID=3322286
http://help.sap.com/saphelp_46c/helpdata/en/9f/dba3ae35c111d1829f0000e829fbfe/content.htm
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 13
Events in Reports
Copyright
© Copyright 2010 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9,
iSeries, pSeries, series, series, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server,
PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, Open Power, PowerPC, Batch Pipes, Blade
Center, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent
Miner, Web Sphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems
Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, Win Frame, Video Frame, and MultiWin are trademarks or registered trademarks of
Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts
Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by
Netscape.
SAP, R/3, SAP Net Weaver, Duet, Partner Edge, By Design, SAP Business By Design, and other SAP products and services mentioned
herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.
Business Objects and the Business Objects logo, Business Objects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and
other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.
All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document
serves informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP
Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the
express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an
additional warranty.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 14