‎2008 Apr 16 7:55 PM
Hi Friends, Pls reply me. What is the difference between Check statment and If statement?
‎2008 Apr 16 8:06 PM
hi check this..
Conditional exiting of a processing block was done by check statement . means if it is not true it will exit automatically ..requres no exit..
report message-id zmsg.
data: test type i value 10.
if test = 10 .
message i000 with 'this is equal to 10' .
endif.
or
report message-id zmsg.
data: test type i value 10.
check test eq 10.
message i000 with 'this is equal to 10' .
regards,
venkat .
‎2008 Apr 16 7:59 PM
if has a corresponding endif.
when condition is satisfied, then it will process the code between if and endif.
whereas if u write a check statement then it goes ahead only if the cocndition is satisfied.
if condition is not satisfied it goes out of processing block.
so if u want ur program to exit if the condition is not satisfied then better write check.
so a check statement is equivalent to :
check <condn>
if not<condn>
exit.
endif.
‎2008 Apr 16 8:02 PM
HI,
After check statement , if the condition is not satisfying, remaining code will not work and goes back to loop the other record.
After IF, if the condition is not satisfying, remaining code after endif will work.
Regards,
Santosh
‎2008 Apr 16 8:02 PM
Hello
If the logical expression of a check evaluates to true execution continues with the
next statement. If it is false then leave current processing block.
For an if statement, if the logical expression is true then execute the next statement in the if block. If it is false either execute the statement(s0 in eht else block or execute the statement after the end of the if-else-endif block.
Hope that helps a bit.
Regards
Greg Kern
‎2008 Apr 16 8:06 PM
hi check this..
Conditional exiting of a processing block was done by check statement . means if it is not true it will exit automatically ..requres no exit..
report message-id zmsg.
data: test type i value 10.
if test = 10 .
message i000 with 'this is equal to 10' .
endif.
or
report message-id zmsg.
data: test type i value 10.
check test eq 10.
message i000 with 'this is equal to 10' .
regards,
venkat .
‎2008 Apr 16 8:07 PM
Hi,
Adding to what our friend has said:
1) In general if the condition fails using CHECK , then it terminates the current processing block.
2)When you use 'CHECK' in LOOP and ENDLOOP , the statement CHECK immediately terminates the current loop pass and the program continues with the next loop pass.
Reward points if helpful.
Thanks and Regards.
‎2008 Apr 17 5:14 AM
hi,
check statement : The check statement is coded within a loop. It can act very much like continue, passing control immediately to the terminating statement of the loop and bypassing the statements between. Unlike continue, it accepts a logical expression. If the expression is true, it does nothing. If it is false, it jumps to the end of the loop.
Syntax for the check Statement
The following is the syntax for the check statement. It can be used within a do, while, select, or loop.
[do/while/select/loop]
---
check exp.
---
[enddo/endwhile/endselect/endloop]
where:
exp is a logical expression.
--- represents any number of lines of code.
If statement : The if statement in ABAP/4 has relational operators for equality and inequality and special relational operators for string comparisons and for bit masks.
Syntax for the if Statement
The following is the syntax for the if statement.
if [not] exp [ and [not] exp ] [ or [not] exp ].
---
[elseif exp.
---]
[else.
---]
endif.
where:
exp is a logical expression that evaluates to a true or false condition.
--- represents any number of lines of code. Even zero lines are allowed.
The following points apply:
Every if must have a matching endif.
else and elseif are optional.
Parentheses can be used. Each parentheses must be separated by a space. For example, if ( f1 = f2 ) or ( f1 = f3 ) is correct, and if (f1 = f2) or (f1 = f3) is incorrect.
Variables can be compared with blanks or zeros using the addition is initial. For example, if f1 is initial will be true if f1 is type c and is blank. If f1 is any other data type, the statement is true if f1 contains zeros.
To accomplish negation, not must precede the logical expression. For example, if not f1 is initial is correct. if f1 is not initial is incorrect.
Variables can be compared with nulls using the addition is null. For example, if f1 is null.
pls, reward if helpful.
Thanks,
rajyalakshmi.
Edited by: Rajyalakshmi Attili on Apr 17, 2008 9:44 AM
Edited by: Rajyalakshmi Attili on Apr 17, 2008 9:47 AM