EXIT in ABAP

EXIT statement is used for terminating the loops or exit from the current processing blocks.

Syntax:

EXIT.

Here are some important notes about ABAP EXIT statement

  • If EXIT statement is triggered outside the loop, it will terminate the current processing block.
  • If EXIT statement is triggered within a loop, it terminated the loop and program execution continues from the end of loop block.
  • We cannot exit LOAD-OF-PROGRAM event using EXIT statement.

Sample Program

DATA count TYPE i VALUE 100.

DO.

IF sy-index > count.

EXIT.

ENDIF.

WRITE / sy-index.

ENDDO.

In this program, the loop will terminate when the system field sy-index value greater than the count variable field (here it is 100).

Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes