Skip to content

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

CHECK - processing_block

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

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 on to the bound actual parameters.

  • The event block LOAD-OF-PROGRAM cannot be exited using CHECK.
  • After the reporting event block GET is exited using CHECK, any subordinate nodes in the hierarchy structure of the associated logical database are no longer processed. The logical database reads the next line of the current node or next higher node, if it has reached the end of the hierarchy level.

Programming Guideline

Only use RETURN to exit procedures


Notes

  • In a procedure (a method, function module, or subroutine), CHECK log_exp works outside a loop in the same way as the following:
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( ).