EXIT - loop

Syntax

EXIT.

Effect

If the EXIT statement is listed within a loop, it leaves the loop by ending the current loop process. Program execution is continued after the closing statement in the loop.

Note

Outside of a loop, the EXIT statement leaves the current processing block (see EXIT - Processing block). We recommend that you use EXIT within loops only.

Example

Leaving a loop with EXIT if the loop index sy-index is greater than a number limit.

DATA limit TYPE i VALUE 10.
DO.
  IF sy-index > limit.
    EXIT.
  ENDIF.
  WRITE / sy-index.
ENDDO.