Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

check.

Former Member
0 Likes
1,050

hi experts,

what is the deference bw check and continue .while using these all functionlatyies means loop,subroutines,modules.

thanks in advance.

radhakrishna.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,024

Hi

CHECK works like IF..ENDIF condition

if the CHECK fails the below code won't execute

CHECK ITAB_KUNNR <> '0010234876'.

CONTINUE skips that loop pass in the loop.

and goes to the next loop pass.

it is used in loop passes.

<b>Reward points for useful Answers</b>

Regards

Anji

7 REPLIES 7
Read only

Former Member
0 Likes
1,025

Hi

CHECK works like IF..ENDIF condition

if the CHECK fails the below code won't execute

CHECK ITAB_KUNNR <> '0010234876'.

CONTINUE skips that loop pass in the loop.

and goes to the next loop pass.

it is used in loop passes.

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
1,024

Hi,

CHECK log_exp.

If the statement CHECK is executed in a loop and log_exp is incorrect, the statement CHECK immediately terminates the current loop pass and the program continues with the next loop pass.

example :

DATA remainder TYPE i.

DO 20 TIMES.

remainder = sy-index MOD 2.

CHECK remainder = 0.

WRITE / sy-index.

ENDDO.

CONTINUE.

The CONTINUE statement can only be used in loops. If it is used, the current loop pass is ended immediately and the program flow is continued with the next loop pass.

Example

A loop pass is exited using CONTINUE if the loop index sy-index is an odd number.

DATA remainder TYPE i.

DO 20 TIMES.

remainder = sy-index MOD 2.

IF remainder <> 0.

CONTINUE.

ENDIF.

WRITE / sy-index.

ENDDO.

Read only

Former Member
0 Likes
1,024

Hi,

<b>CHECK</b> will skip all the code below this statement if the condition is FALSE in a loop and continues with the next loop pass.

<b>CONTINUE</b> will skip the current loop pass and continues with the next loop pass.

<b>CHECK</b> <logexp>.

CHECK evaluates the subsequent logical expression. If it is

true, the processing continues with the next statement.

In loop structures like

DO ... ENDDO

WHILE ... ENDWHILE

LOOP ... ENDLOOP

SELECT ... ENDSELECT

CHECK with a negative outcome terminates the current loop pass

and goes back to the beginning of the loop to start the next

pass, if there is one.

In structures like

FORM ... ENDFORM

FUNCTION ... ENDFUNCTION

MODULE ... ENDMODULE

AT events

GET events

CHECK with a negative outcome terminates the routine or

modularization unit.

If CHECK is neither in a loop nor a routine nor a

modularization unit, a negative logical expression terminates

the current event. In contrast, the statement REJECT terminates

the current event, even from loops or subroutines.

<b>CONTINUE.</b>

Within loop structures like

- DO ... ENDDO

- WHILE ... ENDWHILE

- LOOP ... ENDLOOP

- SELECT ... ENDSELECT

CONTINUE terminates the current loop pass, returns the

processing to the beginning of the loop and starts the nex

loop pass, if there is one.

DO loop: Omit an area (10 ... 20)

DO 100 TIMES.

IF SY-INDEX >= 10 AND SY-INDEX <= 20.

CONTINUE.

ENDIF.

...

ENDDO.

Regards,

Padmam.

Read only

Former Member
0 Likes
1,024

ABAP contains termination statements that allow you to terminate a loop prematurely. There are two categories of termination statement - those that only apply to the loop, and those that apply to the entire processing block in which the loop occurs. The STOP and REJECT statements belong to the latter group, and are described in more detail under Leaving Event Blocks.

The termination statements that apply only to the loop in which they occur are CONTINUE, CHECK, and EXIT. You can only use the CONTINUE statement in a loop. CHECK and EXIT, on the other hand, are context-sensitive. Within a loop, they only apply to the execution of the loop itself. Outside of a loop, they terminate the entire processing block in which they occur (subroutine, dialog module, event block, and so on).

CONTINUE, CHECK, and EXIT can be used in all four loop types in ABAP (DO, WHILE, LOOP, and SELECT).

To terminate a single loop pass immediately and unconditionally, use the CONTINUE statement in the statement block of the loop.

After the statement, the system ignores any remaining statements in the current statement block, and starts the next loop pass.

DO 4 TIMES.

IF SY-INDEX = 2.

CONTINUE.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 3 4

The second loop pass is terminated without the WRITE statement being processed.

Terminating a Loop Pass Conditionally

To terminate a single loop pass conditionally, use the CHECK <condition> statement in the statement block of the loop.

If the condition is not true, any remaining statements in the current statement block after the CHECK statement are ignored, and the next loop pass starts. <condition> can be any logical expression.

DO 4 TIMES.

CHECK SY-INDEX BETWEEN 2 and 3.

WRITE SY-INDEX.

ENDDO.

The output is:

2 3

The first and fourth loop passes are terminated without the WRITE statement being processed, because SY-INDEX is not between 2 and 3.

Exiting a Loop

To terminate an entire loop immediately and unconditionally, use the EXIT statement in the statement block of the loop.

After this statement, the loop is terminated, and processing resumes after the closing statement of the loop structure (ENDDO, ENDWHILE, ENDLOOP, ENDSELECT). In nested loops, only the current loop is terminated.

DO 4 TIMES.

IF SY-INDEX = 3.

EXIT.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 2

In the third loop pass, the loop is terminated before the WRITE statement is processed.

u can visit:

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3564358411d1829f0000e829fbfe/content.htm

for further info

Regards,

Pavan

Read only

Former Member
0 Likes
1,024

Hi,

ABAP contains termination statements that allow you to terminate a loop prematurely. There are two categories of termination statement - those that only apply to the loop, and those that apply to the entire processing block in which the loop occurs. The STOP and REJECT statements belong to the latter group, and are described in more detail under Leaving Event Blocks.

The termination statements that apply only to the loop in which they occur are CONTINUE, CHECK, and EXIT. You can only use the CONTINUE statement in a loop. CHECK and EXIT, on the other hand, are context-sensitive. Within a loop, they only apply to the execution of the loop itself. Outside of a loop, they terminate the entire processing block in which they occur (subroutine, dialog module, event block, and so on).

CONTINUE, CHECK, and EXIT can be used in all four loop types in ABAP (DO, WHILE, LOOP, and SELECT).

To terminate a single loop pass immediately and unconditionally, use the CONTINUE statement in the statement block of the loop.

After the statement, the system ignores any remaining statements in the current statement block, and starts the next loop pass.

DO 4 TIMES.

IF SY-INDEX = 2.

CONTINUE.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 3 4

The second loop pass is terminated without the WRITE statement being processed.

Terminating a Loop Pass Conditionally

To terminate a single loop pass conditionally, use the CHECK <condition> statement in the statement block of the loop.

If the condition is not true, any remaining statements in the current statement block after the CHECK statement are ignored, and the next loop pass starts. <condition> can be any logical expression.

DO 4 TIMES.

CHECK SY-INDEX BETWEEN 2 and 3.

WRITE SY-INDEX.

ENDDO.

The output is:

2 3

The first and fourth loop passes are terminated without the WRITE statement being processed, because SY-INDEX is not between 2 and 3.

Exiting a Loop

To terminate an entire loop immediately and unconditionally, use the EXIT statement in the statement block of the loop.

After this statement, the loop is terminated, and processing resumes after the closing statement of the loop structure (ENDDO, ENDWHILE, ENDLOOP, ENDSELECT). In nested loops, only the current loop is terminated.

DO 4 TIMES.

IF SY-INDEX = 3.

EXIT.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 2

In the third loop pass, the loop is terminated before the WRITE statement is processed.

Regards,

Younus

Read only

former_member196280
Active Contributor
0 Likes
1,024

CHECK evaluates the subsequent logical expressions,If it is true, the processing continues with the next statement.

Continue.

DO 1000 TIMES.

IF SY-INDEX >= 10 AND SY-INDEX <= 20.

CONTINUE.

ENDIF.

WRITE Sy-INDEX.

ENDDO.

It display 1 to 100 excluding 10 to 20.

Rgds,

Sairam

Read only

Former Member
0 Likes
1,024

Hi,

<u><b>CHECK</b></u>

Conditional termination of a loop pass or a processing block.

Syntax

CHECK <logexp>.

If the logical expression <logexp> is true, the program continues at the next statement. If, however, <logexp> is false, the current loop pass terminates and the next begins. If the program is not currently processing a loop, the current processing block terminates. There are special forms of the CHECK statement for use with selection tables and in GET event blocks.

<u><b>CONTINUE</b></u>

Ends a loop pass.

Syntax

CONTINUE.

Only possible within loops. This statement terminates the current loop pass and starts the next.

Regards,

Bhaskar