‎2006 Sep 18 5:49 AM
Hello,
Can CASE be used in the following manner:
case true.
when expression1.
when expression2.
...
endcase.
Aside from functional methods can it be used for logical expressions? e.g.
case 1.
when a > b.
when a < b.
when a = b.
endcase.
Thanks,
John
‎2006 Sep 18 5:51 AM
‎2006 Sep 18 5:51 AM
Hi,
U cant use logical expressions in the when statement.
The CASE Control Structure
This control structure is introduced with the CASE statement. The CASE control structure allows you to control which statement blocks are processed based on the contents of a data object.
CASE <f>.
WHEN <f11> [OR <f 12> OR ...].
<Statement block>
WHEN <f21>.[OR <f 22> OR ...]
<Statement block>
WHEN <f31> [OR <f 32> OR ...].
<statement block>
WHEN ...
......
WHEN OTHERS.
<statement block>
ENDCASE.
The statement block following a WHEN statement is executed if the contents of <f> are the same as those of one of the fields <f ij >. Afterwards, the program carries on processing after the ENDCASE statement. The statement block after the optional WHEN OTHERS statement is executed if the contents of <f> does not equal any of the <f ij > contents. The last statement block must be concluded with ENDCASE.
The CASE control structure is a shortened form of the following IF structure:
IF <f> = <f11> OR <f> = <f 12> OR <f> = ...
<Statement block>
ELSEIF <f> = <f21> OR <f> = <f 22> OR <f> =...
<Statement block>
ELSEIF <f> = <f21> OR <f> = <f 22> OR <f> =...
<statement block>
ELSEIF <f> = ...
...
ELSE.
<statement block>
ENDIF.
You can nest CASE control structures and also combine them with IF structures. However, they must always end with an ENDCASE statement within the current processing block.
regards,
keerthi.
‎2006 Sep 18 5:52 AM
‎2006 Sep 18 5:53 AM
‎2006 Sep 18 5:58 AM
Hi,
No, CASE statement can not be used like that. WHEN statment can not have logical expression.
Regards,
Rahul
‎2006 Sep 18 6:03 AM