Difference between CONTINUE, CHECK and EXIT statement in ABAP/4

  • CONTINUE
    When you apply this statement, system will pass a current loop. System  ignores any statements after CONTINUE statement and start to the next loop.

Example

DO 4 TIMES.
WRITE:/ sy-index.
IF sy-index <= 2.
CONTINUE.

ENDIF.
WRITE: ’After’.
ENDDO.

The output is

1  
2
3  After
4  After
  • CHECK
    This statement will apply if you want to check condition before go to next statement. If the result of checking is ’TRUE’, system will go to next step as normally. If the result of checking is ’FALSE’, system will operate look like CONTINUE statement.

Example

DO 4 TIMES.
WRITE:/ sy-index.
CHECK sy-index > 2.

WRITE: ’After’.
ENDDO.

The output is

1  
2
3  After
4  After
  • EXIT
    When you apply this statement, system will exit from loop. System  ignores any statements after EXIT statement and go to after LOOP command.

Example

DO 4 TIMES.
WRITE:/ sy-index.
IF sy-index > 2.
EXIT.

ENDIF.
WRITE: ’After’.
ENDDO.

The output is

1  After
2 After

Post new comment