‎2007 Jun 13 12:20 PM
Hi,
Can anyone can tell me the difference about check , Continue & exit .
Vighnesh
‎2007 Jun 13 12:23 PM
Hi
CHECK ; checks for the condition like if statement
CONTINUE: skips that loop pass for which the condition was met
EXIT: skips that loop pass and come out
Reward points for useful Answers
Regards
Anji
‎2007 Jun 13 12:29 PM
Hi,
Please check before you provide answers, giving wrong answers will put the person who raised question in confusion.
CHECK will skip the code below that statement for the current loop pass if the check result is FALSE. Its different from IF.
CONTINUE does not have any condition associated with it you have to check the condition using IFand then use CONTINUE.
EXIT skips the loop not the loop pass.
Regards,
Sesh
‎2007 Jun 13 12:23 PM
Hi,
CHECK will skip all the code below this statement if the condition is FALSE in a loop and continues with the next loop pass.
CONTINUE will skip the current loop pass and continues with the next loop pass.
EXIT if in a loop endloop will come out of the loop, if in a procedure comesout of procedure, if in the program outside any loop exits the program.
Regards,
Sesh
‎2007 Jun 13 12:24 PM
Hi,
<b>EXIT.</b>
- Within a loop structure:
Terminates looop processing (DO, WHILE, LOOP, SELECT).
- Within subroutines and other modularization units (but not
in a loop structure):
Leaves the subroutine or modularization unit (FORM, MODULE,
FUNCTION, TOP-OF-PAGE, END-OF-PAGE).
- Outside loop structures and modularization units (report
processing):
Terminates report processing and triggers list display.
DATA: SAP_COUNT TYPE I,
WA_T100 TYPE T100.
SELECT * FROM T100 INTO WA_T100 WHERE SPRSL = SY-LANGU AND
ARBGB = 'DS'.
WRITE / WA_T100-TEXT.
IF WA_T100-TEXT CS 'SAP'.
ADD 1 TO SAP_COUNT.
IF SAP_COUNT = 3.
EXIT.
ENDIF.
ENDIF.
ENDSELECT.
<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.
‎2007 Jun 13 12:26 PM
hI,
COLLECT:COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab .
If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
If, besides its default key fields, the internal table contains number fields,the contents of these number fields are added together if the internal table already contains an entry with the same key fields.
If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab .
After COLLECT , the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed.
COLLECT can create unique or compressed datasets and should be used precisely for this purpose. If uniqueness or compression are unimportant, or two values with identical default key field values could not possibly occur in your particular task, you should use APPEND instead. However, for a unique or compressed dataset which is also efficient, COLLECT is the statement to use.
If you process a table with COLLECT , you should also use COLLECT to fill it. Only by doing this can you guarantee that the internal table will actually be unique or compressed, as described above and COLLECT will run very efficiently.
If you use COLLECT with an explicitly specified work area, it must be compatible with the line type of the internal table.
CONTINUE will skip that Loop pass.
STOP will go to the end of selection
STOP
Effect
The statement STOP is only to be used in executable programs and in the following event blocks:
AT SELECTION-SCREEN (without additions)
START-OF-SELECTION
GET
You leave these event blocks via STOP, and the runtime environment triggers the event END-OF-SELECTION.
Note
The statement STOP is forbidden in methods and, since Release 6.10, leads to an uncatchable exception during the processing of screens called with CALL SCREEN and in programs not called with SUBMIT.
Example
Ending the event blocks GET sbook after max postings have been issued, and branching to END-OF-SELECTION.
CONTINUE
Effect
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.
<b>*Reward points</b>
REGARDS
‎2007 Jun 13 12:26 PM
Hi,
Continue-
The continue statement is coded within a loop. It acts like a goto, passing control immediately to the terminating statement of the loop and beginning a new loop pass. In effect, it causes the statements below it within the loop to be ignored and a new loop pass to begin.
Check-
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.
Exit-
Exit statement means coming out of a loop when ever certain conditon sastisfies
do.
count = count + 1.
if count = '5'.
EXIT.
endif.
enddo.
***do rewards if usefull
Regards,
vijay
‎2007 Jun 13 12:27 PM
Hi Vighnesh,
CHECK checks a condition and leaves the current processing block (a LOOP or a FUNCTION) if the condition is not true.
EXIT works similar to CHECK except that it doesn't check a given condition. Usually you would place it in some IF ENDIF clause.
CONTINUE works a bit different by that it only work in loops. When CONTINUE got hit in a loop the loop starts the next iteration.
Example:
DATA remainder TYPE i.
DO 20 TIMES.
remainder = sy-index MOD 2.
IF remainder <> 0.
CONTINUE.
ENDIF.
WRITE / sy-index.
ENDDO.
Best regards,
ok
‎2007 Jun 13 12:27 PM
hi,
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. For log_exp, you can specify any logical expression.
Outside a loop, the statement CHECK exits the current processing block (see CHECK Processing Block).
Example
Termination of the loop pass using CHECK when the loop index sy-index is odd-numbered.
DATA remainder TYPE i.
DO 20 TIMES.
remainder = sy-index MOD 2.
CHECK remainder = 0.
WRITE / sy-index.
ENDDO.
2)
If the EXIT statement is listed within a loop, it leaves the loop by ending the current loop process. Program execution is continued after the closing statement in the loop.
Note
Outside of a loop, the EXIT statement leaves the current processing block (see EXIT - Processing block). We recommend that you use EXIT within loops only.
Example
Leaving a loop with EXIT if the loop index sy-index is greater than a number limit.
DATA limit TYPE i VALUE 10.
DO.
IF sy-index > limit.
EXIT.
ENDIF.
WRITE / sy-index.
ENDDO.
3)
CONTINUE.
Effect
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.
Reward points if helpful,
Regards,
Imran
‎2007 Jun 13 12:47 PM
Hi,
<b>CHECK</b>
If you use the CHECK <expr> statement within an event block but not within a loop, and the condition <expr> is not fulfilled, the system exits the processing block immediately.
If the CHECK statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.
<b>CONTINUE</b>
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.
<b>EXIT</b>
A subroutine normally ends at the ENDFORM statement. However, you can terminate them earlier by using the EXIT.
the EXIT statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.
regards,
Ashokreedy.