SAP - ABAP EVENTS During Runtime Of A Report Program.


ABAP Programs are event driven and hence it’s important to have a proper upstanding of events to have a good understanding to ABAP programming. The general flow of an ABAP program is controlled by events.

Events are defined in an ABAP program using event keywords such as initialization, start-of-selection & end-of-selection. The event keywords are reserved words and no user can create can create a new event.

Events are tags that identify a block of codes. The block of code associated with an event begins with an event keyword and ends when the next event keyword is encountered.

The different events available are:

  • INITIALIZATION. - Used to set default Values
  • AT SELECTION-SCREEN OUTPUT.
  • AT SELECTION-SCREEN ON <FIELD>.
  • AT SELECTION-SCREEN ON BLOCK <blockname>.
  • AT SELECTION-SCREEN. - Used to validate the fields on selection screen.
  • START-OF-SELECTION.
  • TOP-OF-PAGE.
  • END-OF-SELECTION.
  • END-OF-PAGE.
  • AT PF<NN>.
  • AT LINE SELECTION.
  • AT USER COMMAND
  • TOP-OF-PAGE DURING LINE-SELECTION.


To bring clarity in code, it’s a common programming practice to code event processing blocks in the order in which they will be triggered during execution. But this practice is not mandatory.


SAMPLE PROGRAM - 1:

REPORT ztest.

TOP-OF-PAGE.
WRITE:/ 'TOP-OF-PAGE Event Trigerred'.

INITIALIZATION.
WRITE:/ 'INITIALIZATION Event Trigerred'.

START-OF-SELECTION.
WRITE:/ 'START-OF-SELECTION Event Trigerred'.

END-OF-SELECTION.
WRITE:/ 'END-OF-SELECTION Event Trigerred'.


OUTPUT:



Even if the events are not coded in a sequential order, the blocks are processed sequentially. There is no need to code the events in a sequential order because execution order will still be the same.


SAMPLE PROGRAM - 2:

REPORT ztest.

END-OF-SELECTION.
WRITE:/ 'END-OF-SELECTION Event Trigerred'.

TOP-OF-PAGE.
WRITE:/ 'TOP-OF-PAGE Event Trigerred'.

START-OF-SELECTION.
WRITE:/ 'START-OF-SELECTION Event Trigerred'.

INITIALIZATION.
WRITE:/ 'INITIALIZATION Event Trigerred'.


OUTPUT:



ALSO READ:

- ABAP EVENTS During Runtime Of A Report Program.

- INITIALIZATION Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN OUTPUT Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN ON VALUE REQUEST- Introduction With A Sample Code.

- AT SELECTION-SCREEN ON HELP REQUEST- Introduction With A Sample Code.

- AT SELECTION-SCREEN ON - Introduction With A Sample Code.


- Sample Program On AT SELECTION-SCREEN OUTPUT - 1.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 2.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 3.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 4.

- Sample Program On AT SELECTION-SCREEN ON VALUE REQUEST FOR field - 1.

- Sample Program On AT SELECTION-SCREEN ON VALUE REQUEST FOR field - 2.

- Sample Program On AT SELECTION-SCREEN ON HELP REQUEST FOR field- 1.