ABAP Programming EVENTS in SAP



Below are some of the events avalable within ABAP programming

LOAD-OF-PROGRAM
First event to be called before any of the other ABAP code is processed

INITIALIZATION
Called after the abap selection screen code has been processed (i.e. parameters, select-options etc) but before these are displayed to the user. So you can use it to initialize input fields of the selection screen or change the default values of these before the user gets to enter data into them.

AT SELECTION SCREEN OUTPUT
This is called just before the selection screen is displayed and can be used to manipulate the actual selection screen attributes using teh loop at screen functionality. This allows you to do things like hide fields, grey them out so they are output only or make them intensified etc.

LOOP AT SCREEN.
  IF SCREEN-name = 'P_FIELd1'.
    SCREEN-INTENSIFIED = '1'.
    MODIFY SCREEN.
    CONTINUE.
  ENDIF.
ENDLOOP.

AT SELECTION-SCREEN.
This event is triggered when the user presses enter on the report selection screen and is mainly used to add processing related to screen validation. Within the AT SELECTION SCREEN event you have not left the selection screen, which allows you to manipulate the values contained within sel screen parameters or stop the program and return the user to the selection screen by displaying an error message.

AT SELECTION-SCREEN ON
This allows you to add processing to a selection screen field for when it is chnaged, user presses F1 or F4 etc using the following parameters

<parameter1>
AT SELECTION-SCREEN ON Block <block1>
AT SELECTION-SCREEN ON HELP-REQUEST for <parameter1> (i.e. When press F1)
AT SELECTION-SCREEN ON VALUE-REQUEST for <parameter1> (i.e. When press F4)
AT SELECTION-SCREEN ON RADIOBUTTON for <parameter1> (i.e. When press F4)

AT SELECTION-SCREEN ON P_FIELD1.
AT SELECTION-SCREEN ON help-request for P_FIELD1.

TOP-OF-PAGE
This is called when a new page is started with an ABAP list and is used to display a header for the list.

TOP-OF-PAGE During LINE_SELECTION
If you use the 'DURING LINE-SELECTION' addition this event is also triggered when creating detailed lists.

END-OF-PAGE
This is displayed at the end of each page if there is a line reservation in the addition LINE-COUNT of the initiating statement for a page footer.

REPORT demo_rep NO STANDARD PAGE HEADING
                            LINE-COUNT 0(1). 



START-OF-SELECTION
This event is called when . If the user executes the program either by pressing the execute button or F8 this is the first event triggered after all screen selection processing has been completed (AT Selection...). So pressing execute triggers both AT SELECTION and then START-OF-SELECTION

If no other events are declared then there is no need to manually code this event as all processing statements will be automatically assigned to an implicit START-OF-SELECTION block. It is a good ideal to put it in though as it separates the code and makes it easier to read. Generally you would put all you data selection ABAP code within this event.

END-OF-SELECTION
If your report is linked to a logical database this event is called after the logical database has completely finished its work. Otherwise this event is trigged after the START-OF-SELECTION event so you would generally use it to processes the data retrieved in that event.


Related Articles

Beginners Guide to learning SAP development starting with logging into SAP
ABAP Function Module basics in SAP
DATA and @DATA Inline ABAP declarations available from release 7.40 to help make your code cleaner and more readable
ABAP Workbench Programming Techniques - BC402
ABAP rules to consider before creating a bespoke abap report or program
ABAP Subroutine basics in SAP
Get access to an SAP system for individual needs
SAP Base 64 encoding and decoding using ABAP code
Call web URl from ABAP report or SAP help documentation
Direct download, downloading sap objects
SAP Icons
SAP icons and some ABAP code to display them
SAP icons list and their associated codes
Internal Program Environment diplays all internal/external objects and operations used by an SAP program
minisap installation on your local pc to allow ABAP development, your own local SE80
SAP minisap installation on your local pc to allow ABAP development for free
SAP module based information such FI, HR, MM, PM, BW etc
Need an SAP ABAP program created?
SAP repository objects - List of useful standard and bespoke SAP repository objects
Retrieve SAP objects using transport entry in SE10 to restore objects that have been deleted
SAP Help for all areas for SAP ABAP Development inc ABAP, ALV, Web dynpro, bsp, HR, BW
ABAP tutorial - Logging into an SAP system for the first time
Manage and delete SAP sessions using ABAP code
SAP module areas
Increase & Decrease size of SAP editor text
ABAP development information and code examples for producing be-spoke SAP functionality
ABAP Development Info - Example code and information on various areas of ABAP development
SAP command field entries - box in top left corner
Force new page when printing abap source code
ABAP FIELD SYMBOL - Techniques for manupulating data using the FIELD-SYMBOL statement
Hiding ABAP Source Code so that it can not be viewed by anyone
ABAP Internal table declaration - Various methods of creating internal data structures and tables
Parameter ID - ABAP code to demonstrate how to set and get a parameter ID
RANGE statement - Example ABAP code to demonstrate the RANGE command
Change SAP logo in top right hand corner of SAP client
ABAP SELECT statement within SAP - Example ABAP code to demonstrate the SELECT command
Create desktop Shortcut to SAP function
SAP Note assistant - Using transaction SNOTE to read and apply OSS note fix
VARYING command - Example ABAP code to demonstrate the VARYING command
Creating your first helloworld ABAP report in SAP