ABAP/4 is a fourth-generation language (4GL) but it is an event-driven language. It has a few events. But don’t confuse about ABAP Objects and events of them. Event blocks are introduced by an event keyword. They end when the next block begins. The following block can be another event block, introduced by a different keyword, or another processing block that is valid in the context, such as a subroutine or dialog module. Event keywords have the same name as the events to which they react.
The sequence in which processing blocks occur in the program is irrelevant. The actual processing sequence is determined by the external events. However, to make your programs easier to understand, you should include the event blocks in your program in approximately the samer order in which they will be called the system. Subroutines should be placed at the end of the program.
The following events occur at runtime of a typical report program with logical database:
INITIALIZATION
Point before the selection screen is displayed. When you start a program in which a selection screen is defined (either in the program itself or in the linked logical database program), the system normally processes this selection screen first. If you want to execute a processing block before the selection screen is processed, you can assign it to the event keyword INITIALIZATION. Mostly global variables, classes, internal tables declarations are made here.
AT SELECTION-SCREEN
Point after processing user input on the selection screen while the selection screen is active. It provides you with several possibilities to carry out processing blocks while the system is processing the selection screen.
START-OF-SELECTION
Point after processing the selection screen. It gives you the possibility of creating a processing block after processing the selection screen and before accessing database tables using a logical database. You can use this processing block, for example, to set the values of internal fields or to write informational statements onto the output screen. At the START-OF-SELECTION event, also all statements are processed that are not attached to an event keyword except those that are written behind FORM-ENDFORM block.
You can do select database tables data processing here. REPORT statement always execute a START-OF-SELECTION implicitly. Consequently all processing logic between the REPORT statement and the next event keyword is automatically processed in the START-OF-SELECTION event.
GET <table>
After the logical database has read an entry from the node <table>. The most important event for report programs with an attached logical database is the moment at which the logical database program has read a line from a database table. When many programmers learn how to write an ABAP program, they confuse about logical database concept and this GET events. At first glance GET looks like a normal statement, but it is event keyword. If you look at the source of the logical database program code, it is easier to understand the GET keyword, even when you see the opposite keyword PUT inside the logical database program.
GET <table> LATE
After the logical database has read an entry from the node <table>. The event is triggered when all of the records for a node of the logical database have been read. If you want to write, for example, a sub total for a field, you can use this event.
END-OF-SELECTION
To define a processing block after the system has read processed all selections. It is triggered in type 1 programs (reports). This is the last of the events called by the runtime environment occur. It is triggered after all of the data has been read from the logical database, and before the list processor started. You can use the corresponding event block to process and format the data that the program has stored in internal tables or extracts during the various GET events.
The following events occur during the processing of the output list of a report program:
TOP-OF-PAGE
In list processing when a new page starts.
END-OF-PAGE
In list processing when a page ends.
AT LINE-SELECTION
When the user triggers the predefined function code PICK.
AT PF<nn>
When the user triggers the predefined function code PF<nn>.
AT USER-COMMAND
When the user triggers a function code defined in the program.
The last three events are used when an interactive report program has been written.
PS. There are some other events and events have some extra usage options for different purposes; but major event are above as mentioned.
출처 : http://www.itcserver.com/blog/2006/06/26/events-in-abap/