on 04-03-2008 9:32 AM
hai sir
i want to know abt case manage ment...tel me abt this plz
Hi Venu,
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.
DATA: TEXT1 VALUE 'X',
TEXT2 VALUE 'Y',
TEXT3 VALUE 'Z',
STRING VALUE 'A'.
CASE STRING.
WHEN TEXT1 OR TEXT2.
WRITE: / 'String is', TEXT1, 'OR', TEXT2.
WHEN TEXT3.
WRITE: / 'String is', TEXT3.
WHEN OTHERS.
WRITE: / 'String is not', TEXT1, TEXT2, TEXT3.
ENDCASE.
The output is:
String is not X Y Z
Here, the last statement block after WHEN OTHERS is processed because the contents of STRING, A, does not equal X, Y, or Z.
Kindly Reward Points If You Found The Reply Helpful,
Cheers,
Chaitanya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is not the correct forum for your question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.