SAP StackFICOHRMMSDPMPSABAPNetWeaverTablesTcodes ☰MENU

CHECK statement in ABAP

CHECK statement in ABAP is used for leaving a loop or processing block with some conditional check. If the conditional check with the CHECK statement is true, the process will continue the execution with the next statement. If the conditional check is false, the process will quit the current loop pass and will process the next loop. If CHECK statement is not within a loop, the false condition will terminate the current event.

Syntax Usages

Inside loops /bloks

CHECK <expr>

 

With Reports with logical databse

CHECK sel.

CHECK SELECT-OPTIONS

 

You will get clearer picture by seeing the following sample scenarios.

 

Check statement in a loop

We can use check statement within a loops like

 

In these loops, if the check statement returns the false, it will stop the current loop pass and start the next loop. Here is an example.

DATA: I =0,

J=0.

WHILE  J < 5.

J = J + 1.

CHECK J NE 2.

WRITE J.

ENDWHILE.

 

Its output will be

1345

 

Tip: You can see that check statement terminates the loop with value 2.In that loop check conditional statement return false and the loop pass terminated.

 

CHECK statement with logical databases

 

CHECK sel: Checks the selection criterion requested by the statement SELECT-OPTIONS sel. If the result of this check is negative, the processing in this event is terminated and the GET events for any subordinate database tables are not processed either.

CHECK SELECT-OPTIONS: checks all the selections for SELECT-OPTIONS where the reference field after FOR belongs to the current table dbtab. And it is calling only after GET event.

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

SAP ALECRMSCMSRMSAP Solutions SAP ReferencesSAP BasicsPP ModuleWMSAP Partners
HomeContact & Privacy PolicyTwitter
All of the product names here are trademarks of their respective companies. The site sapstack.com is not affiliated with SAP AG.
©2024 sapstack.com