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

CHECK - processing_block

Quick Reference

Syntax

CHECK log_exp.

Effect

If the statement CHECK is located outside a loop and log_exp is false, this statement exits the current processing block. Any logical expression can be specified for log_exp.

After the processing block is exited, the runtime environment proceeds in the same way as when the processing block is exited in the regular way (with the exception of the event block LOAD-OF-PROGRAM and the reporting event block GET). In particular, the output parameters of procedures are passed to the bound actual parameters.

Programming Guideline

Only use RETURN to exit procedures

Notes

IF NOT log_exp.
  RETURN.
ENDIF.

Example

This example shows a case where CHECK can be used outside a loop. Right at the start of a procedure, a prerequisite for executing the procedure is checked (and the procedure exited if the check is not successful). In this case, the procedure cannot be executed in the background.

CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.
    CHECK sy-batch IS INITIAL.
    ...
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo=>main( ).