View previous topic :: View next topic
|
Author |
Message |
PRABHATH Warnings : 1 New User
Joined: 08 Jun 2006 Posts: 28 Location: hyderabad
|
|
|
|
We're having a problem coding an EVALUATE statement in place of
nested IFs.
Working Storage looks something like:
01 .....
05 WS-EIBCPOSN PIC S9(4) VALUE ZEROS.
88 FUNC-SET VALUES 241, 242, 243, 244.
88 FUNC-IGEN VALUES 241, 242.
The Procedure Division code that works:
IF FUNC-SET
IF FUNC-IGEN
MOVE .....
The Procedure Division code that doesn't work:
-------
IF FUNC-SET
EVALUATE WS-EIBCPSON
WHEN FUNC-IGEN
MOVE ....
We get a compile error IGYPA3009-S that says:
"The selection object at position 1 in the "WHEN" phrase did not
match the type of the corresponding selection subject in the
"EVALUATE" statement. The selection object was discarded."
So what's wrong here? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Use EVALUATE TRUE when your WHENs are 88 levels.
WHEN FUNC-IGEN only returns true or not true.
But if your EVALUATE interrogates the value of a data-element, your WHENs must return equal lt,gt. |
|
Back to top |
|
|
gixcng
New User
Joined: 26 Oct 2007 Posts: 15 Location: chennai
|
|
|
|
hi prabhath,
can you be more clear. what is the group variable here,under which the condition names are defined?
if at all the condition constants were to be
checked , their condition variables should be set.
if iam not wrong,you have not set the condition variable.
for ex:
WORKING-STORAGE SECTION.
01 CONDSCHE PIC 9(2).
88 EVENM VALUE 04,06,08,10,12.
88 ODDM VALUE 01,03,05,07,09,11.
88 FEB VALUE 02.
PROCEDURE DIVISION.
ACCEPT DAT.
MOVE MT TO CONDSCHE. //*setting the CONDSCHE
DIVIDE YR BY 4 GIVING YR1 REMAINDER YC.
IF YC = 0
IF (MT < 01) OR (MT > 12)
DISPLAY "INVALID MONTH"
ELSE
IF EVENM AND (DAYM > 30)
if iam not answering the question you are referring to,please let me know.
regards |
|
Back to top |
|
|
PRABHATH Warnings : 1 New User
Joined: 08 Jun 2006 Posts: 28 Location: hyderabad
|
|
|
|
Hi ,
For example:
IDENTIFICATION DIVISION.
PROGRAM-ID. EVALEX.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 REG PIC X(2).
88 C1 VALUE 'R1'.
88 C2 VALUE 'R2'.
88 C3 VALUE 'R3'.
PROCEDURE DIVISION.
MAIN-PARA.
ACCEPT REG.
EVALUATE REG
WHEN C1 DISPLAY 'WELCOME TO REGION 1'
WHEN C2 DISPLAY 'WELCOME TO REGION 2'
WHEN C3 DISPLAY 'WELCOME TO REGION 3'
WHEN OTHER DISPLAY 'THERES NO REGION DEFINED'
END-EVALUATE.
STOP RUN.
This would return the same result as before. |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hi Prabhath,
Could you tell me, What u r doing here
Code: |
IF FUNC-SET
EVALUATE WS-EIBCPSON
WHEN FUNC-IGEN
MOVE .... |
See, In above code FUNC-SET and FUNC-IGEN are the conditional data item for WS-EIBCPSON variable so Both variable will going to have same value so you can use below code
EVALUATE WS-EIBCPSON
WHEN FUNC-SET
WHEN FUNC-IGEN
MOVE ............. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Prabhath,
Code: |
This would return the same result as before. |
Ru still facing problem? |
|
Back to top |
|
|
PRABHATH Warnings : 1 New User
Joined: 08 Jun 2006 Posts: 28 Location: hyderabad
|
|
|
|
Thanx Dick,
that worked for me...EVALUATE TRUE did well here. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Thanks for sharing the solution Prabath. This is a good practice to complete the thread. |
|
Back to top |
|
|
gixcng
New User
Joined: 26 Oct 2007 Posts: 15 Location: chennai
|
|
|
|
hi everyone,
ya EVALUATE TRUE did work
if we have several condition variables:
01 cond_che1
88....
88...
01 cond_che2
88...
88...
procedure division.
accept cond_che1
accept cond_che2
evaluate true...
(now,what variable will it check for?)
for me,
evaluate cond_che1 true dint work!! |
|
Back to top |
|
|
PRABHATH Warnings : 1 New User
Joined: 08 Jun 2006 Posts: 28 Location: hyderabad
|
|
|
|
Hi Gayathri,
I did try out an example for such a case...
For example in the following program:
IDENTIFICATION DIVISION.
PROGRAM-ID. EVALEX.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 T1 PIC 9(2).
01 REG PIC X(2).
88 C1 VALUE 'R1'.
88 C2 VALUE 'R2'.
88 C3 VALUE 'R3'.
01 REF PIC 9(2).
88 C5 VALUE 80.
88 C6 VALUE 90.
01 MONTH PIC 9(2).
PROCEDURE DIVISION.
MAIN-PARA.
ACCEPT REF.
ACCEPT T1.
ACCEPT REG.
DISPLAY T1.
EVALUATE TRUE
WHEN C1 DISPLAY 'WELCOME TO REGION 1'
WHEN C2 DISPLAY 'WELCOME TO REGION 2'
WHEN C3 DISPLAY 'WELCOME TO REGION 3'
WHEN OTHER DISPLAY 'THERES NO REGION DEFINED'
END-EVALUATE.
EVALUATE TRUE
WHEN C5 DISPLAY 'VALUE IS 80'
WHEN C6 DISPLAY 'VALUE IS 90'
WHEN OTHER DISPLAY 'WRONG ENTRY'
END-EVALUATE.
ACCEPT MONTH.
EVALUATE MONTH
WHEN 11 DISPLAY 'THIS IS NOVEMBER'
WHEN 12 DISPLAY 'THIS IS DECEMBER'
WHEN 1 THRU 10 DISPLAY 'VALUES OF LAST MONTHS' MONTH
WHEN OTHER DISPLAY 'WRONG ENTRY'
END-EVALUATE.
STOP RUN.
run this out...and you would come to know.... |
|
Back to top |
|
|
PRABHATH Warnings : 1 New User
Joined: 08 Jun 2006 Posts: 28 Location: hyderabad
|
|
|
|
the above example shows the usage of EVALUATE in 2 different ways... |
|
Back to top |
|
|
gixcng
New User
Joined: 26 Oct 2007 Posts: 15 Location: chennai
|
|
|
|
ya prabhath, it did work!
so the condition variables are set,in a way letting EVALUATE true.
thank you |
|
Back to top |
|
|
|