Leaving Event Blocks Using EXIT 

If you use the STOP statement within an event block but not in a loop, the system stops processing the block immediately. The ABAP runtime environment triggers the next event according to the following diagram:

Before and during selection screen processing, the next event in the prescribed sequence is always called. From the START-OF-SELECTION event onwards, the system starts the list processor directly when the EXIT statement occurs, and displays the list.

If the EXIT statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.

The following program is connected to the logical database F1S.

REPORT EVENT_TEST.

NODES: SPFLI, SFLIGHT, SBOOK.

START-OF-SELECTION.
   WRITE 'Test Program for EXIT'.

GET SBOOK.
   WRITE: 'Bookid', SBOOK-BOOKID.
   EXIT.

END-OF-SELECTION.
   WRITE: / 'End of selection'.

This produces the following output:

Test Program for EXIT

Bookid 00010001

After the first line of SBOOK has been read, the list is displayed immediately.

The following program is connected to the logical database F1S.

REPORT EVENT_TEST.

NODES: SPFLI, SFLIGHT, SBOOK.

DATA FLAG.

AT SELECTION-SCREEN.
  IF CARRID-LOW IS INITIAL.
    FLAG = 'X'.
    EXIT.
  ENDIF.
  ........

START-OF-SELECTION.
  IF FLAG = 'X'.
    WRITE / 'No selection made for CARRID'.
    EXIT.
  ENDIF.

GET SPFLI.
  .........

GET SFLIGHT.
  .........

GET SBOOK.
  .........

END-OF-SELECTION.
   WRITE / 'End of Selection'.

If the user does not enter a value for CARRID-LOW, the output appears as follows:

No selection made for CARRID

After the first EXIT statement, the next event, namely the START-OF-SELECTION block, is processed. After the second EXIT statement, the output list is displayed.