Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Calling and leaving program units →  Exiting Program Units →  Exiting Loops 

EXIT - loop

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


EXIT. 

Effect

If the EXIT statement is specified within a loop, it exits the loop by ending the current loop pass. The program flow resumes after the closing statement in the loop.


Note

Outside of a loop, the statement EXIT exits the current processing block (see EXIT - Processing Block). EXIT, however, should only be used within loops.


Example

Exits a loop using 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. 
  cl_demo_output=>write( |{ sy-index } | ). 
ENDDO. 
cl_demo_output=>display( ).