View previous topic :: View next topic
|
Author |
Message |
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
My code is :
Code: |
EVAUATE TRUE ALSO TRUE ALSO TRUE
WHEN
A=B ALSO
C=D ALSO
E=F
MOVE A TO F
WHEN...
.....
...
END-EVALUATE
|
My code is not working properly. It is going in wrong WHEN condition.
Thanks.... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
How do you know it is going to the wrong WHEN statement? To prove this, you need to DISPLAY the values of A, B, C, D, E, and F before the EVALUATE statement and show us the values (and the full EVALUATE). And you should be aware that moving A to F in your WHEN statement will have absolutely no impact upon the EVALUATE -- if the first WHEN triggers, the next statement to be executed will be END-EVALUATE. |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Code: |
EVALUATE TRUE ALSO TRUE ALSO TRUE
WHEN A= SPACE ALSO
B = SPACE ALSO
C = SPACE
SET WS-COND1 TO TRUE
WHEN A NOT = SPACE ALSO
B = SPACE ALSO
C = SPACE
SET WS-COND2 TO TRUE
WHEN A = SPACE ALSO
B NOT = SPACE ALSO
C = SPACE
SET WS-COND3 TO TRUE
..............................
END-EVALUATE.
|
In this way I need to validate 3 fields with spaces for all possible combinations (i.e. 8 cases).
My query is: do I need to put these conditions in when clause in single line? I am asking this because in all examples and in the standard IBM syntax manual it is given in that way.
The code is not working properly when I am testing it in XPED. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
My query is: do I need to put these conditions in when clause in single line? |
No. Not that i'm aware of. Besides, the length may exceed one line.
You do however need to post the actual code, some sample data values, and what you see in xped when you run the code with that sample data. |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
thanks Dick..!
Then is it using of NOT in when clause affecting the result of EVALUATE condition? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Then is it using of NOT in when clause affecting the result of EVALUATE condition? |
It should, but we can all be more sure when you post the requested info. . . What you have posted is confusing as it is "alphabet soup" and we (people) work better with "real" fields and data.
To repeat:
Quote: |
You do however need to post the actual code, some sample data values, and what you see in xped when you run the code with that sample data. |
|
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
Hi Abdul,
Giving the WHEN is seperate lines also is not any issue. I dont think giving 'NOT =' also would be a problem.
Pls explain the issue.... |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Abdul,
I have tested the same here and the output looks satisfactory for me...
Code: |
WORKING-STORAGE SECTION.
01 WS-WORKING-VARIABLES.
05 WS-WORK-A PIC X(01).
05 WS-WORK-B PIC X(01).
05 WS-WORK-C PIC X(01).
05 WS-COND-VAR.
10 WS-WORK-1 PIC X(01).
10 WS-WORK-2 PIC X(01).
10 WS-WORK-3 PIC X(01).
10 WS-WORK-4 PIC X(01).
*
PROCEDURE DIVISION.
*
MAIN-LINE-PARA.
*
MOVE SPACES TO WS-WORK-A
WS-WORK-B
WS-WORK-C.
INITIALIZE WS-COND-VAR.
*
PERFORM VALIDATE-PARA THRU VALIDATE-PARA-EXIT.
DISPLAY WS-COND-VAR.
*
MOVE 'X' TO WS-WORK-A.
MOVE SPACES TO WS-WORK-B
WS-WORK-C.
INITIALIZE WS-COND-VAR.
*
PERFORM VALIDATE-PARA THRU VALIDATE-PARA-EXIT.
DISPLAY WS-COND-VAR.
*
MOVE SPACES TO WS-WORK-A
WS-WORK-C.
MOVE 'X' TO WS-WORK-B.
INITIALIZE WS-COND-VAR.
*
PERFORM VALIDATE-PARA THRU VALIDATE-PARA-EXIT.
DISPLAY WS-COND-VAR.
*
MOVE 'X' TO WS-WORK-A
WS-WORK-B
WS-WORK-C.
INITIALIZE WS-COND-VAR.
*
PERFORM VALIDATE-PARA THRU VALIDATE-PARA-EXIT.
DISPLAY WS-COND-VAR.
*
STOP RUN.
*
VALIDATE-PARA.
EVALUATE TRUE ALSO TRUE ALSO TRUE
WHEN WS-WORK-A = SPACE ALSO
WS-WORK-B = SPACE ALSO
WS-WORK-C = SPACE
MOVE '1' TO WS-WORK-1
WHEN WS-WORK-A NOT = SPACE ALSO
WS-WORK-B = SPACE ALSO
WS-WORK-C = SPACE
MOVE '2' TO WS-WORK-2
WHEN WS-WORK-A = SPACE ALSO
WS-WORK-B NOT = SPACE ALSO
WS-WORK-C = SPACE
MOVE '3' TO WS-WORK-3
WHEN OTHER
MOVE '4' TO WS-WORK-4
END-EVALUATE.
*
VALIDATE-PARA-EXIT.
EXIT.
* |
Output
Please do let us know if there is anything wrong in the sample I have tried.. |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Binop,
This is exactly equal to what my scenario is. But still its not working properly for me.
I tried with the IF ELSE logic as well, in this case also it is not working. I changed the data many times, the data looks good, but still the problem persists.
Do you have any suggestions?
Do you think SPACES and SPACE will make a difference? |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Quote: |
Do you think SPACES and SPACE will make a difference? |
No...
Quote: |
Do you have any suggestions? |
Yes... Provide the info what Dick has asked... It would make our life much easier if we could see your actual code along with the DISPLAY statements you have used to do the verification.... and since you have mentioned even IF .. ELSE-IF .. is also not working... my assumption is data problem.. |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Code: |
--------------------- XPEDITER/CICS - SOURCE LISTING (2.L) ----------------GD1D
COMMAND ===> SCROLL ===> CSR
MODULE: CMOCTMZ1 ****** STATEMENT 002348 EXECUTED STEP=00001 *******
LV ---- COBOL DATANAME KEEPS ---- -- ATTRIBUTES -- ----+---10----+---20--->
K 03 WS-TODO-ITEM-CDE X(10) ITEM567890
K 03 WS-TODO-ITEM-LVL-CDE X(10) LVLCDE7890
K 03 WS-TODO-PROC-CDE X(03) PRO
02 WSF-FUNCTION X(08) READ0003
88 WSF-UPDATE6 VALUE UPDATE06
------ ---------------------------------------------- Before CMOCTMZ1.2352 ->
002345
002346 ********START*********
002347 EVALUATE TRUE ALSO TRUE ALSO TRUE
002348 WHEN
002349 WS-TODO-ITEM-CDE = SPACE ALSO
002350 WS-TODO-ITEM-LVL-CDE = SPACE ALSO
002351 WS-TODO-PROC-CDE = SPACE
=====> SET WSF-UPDATE6 TO TRUE
002353 * MOVE SPACES TO ZUT33O-PITM-CDE
002354 * MOVE SPACES TO ZUT33O-PITM-LVL-CDE
002355 * MOVE SPACES TO ZUT33O-MSTR-PROCESS-TYPE
002356 WHEN
002357 WS-TODO-ITEM-CDE NOT = SPACE ALSO
002358 WS-TODO-ITEM-LVL-CDE = SPACE ALSO |
as you can see here: the values are not spaces but still it is going in the WHEN cond where it is saying all flds are spaces..
Please advice |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
I got to say I am baffled...
Abdul, would like to know one information... Would like to know where the control is going from there...
its been sometime since I have worked in Xpediter... but I have a vague memory that even though the cursor is showing in SET statement, like in your case, its acutally executing the WHEN statement... I could be very well wrong... but you could just check...
Posting the whole EVALUATE statment might also help... ... |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Quote: |
Would like to know where the control is going from there... |
After setting that flag, its going to END-EVALUATE. |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
I am sorry guys...!
It was a mistake from my side....
In the XPED I was skipping some code prior to this EVALUATE, which was causing this issue.
Now its working fine.. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Ok Abdul,
I would suggest an alternative way of writing the EVALUATE statment in question, eliminating all the negated WHEN expressions:
Code: |
VALIDATE-PARA.
EVALUATE WS-WORK-A = SPACE ALSO
WS-WORK-B = SPACE ALSO
WS-WORK-C = SPACE
WHEN TRUE ALSO TRUE ALSO TRUE
MOVE '1' TO WS-WORK-1
WHEN FALSE ALSO TRUE ALSO TRUE
MOVE '2' TO WS-WORK-2
WHEN TRUE ALSO FALSE ALSO TRUE
MOVE '3' TO WS-WORK-3
WHEN OTHER
MOVE '4' TO WS-WORK-4
END-EVALUATE.
*
VALIDATE-PARA-EXIT.
EXIT. |
You can actually implement your decision table directly that way. |
|
Back to top |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
Code: |
EVALUATE TRUE
WHEN WS-WORK-A = SPACE and WS-WORK-B = SPACE and WS-WORK-C = SPACE
MOVE '1' TO ...
WHEN WS-WORK-A NOT = SPACE and WS-WORK-B = SPACE and WS-WORK-C = SPACE
MOVE '2' TO ...
WHEN WS-WORK-A = SPACE and WS-WORK-B NOT = SPACE and WS-WORK-C = SPACE
MOVE '3' TO ...
WHEN OTHER
MOVE '4' TO ...
END-EVALUATE.
|
Hi,
Is there any reason not to use the code above? Is the original code posted (with the "also" option) more efficient than this?
Thanks. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
jctgf wrote: |
Code: |
EVALUATE TRUE
WHEN WS-WORK-A = SPACE and WS-WORK-B = SPACE and WS-WORK-C = SPACE
MOVE '1' TO ...
WHEN WS-WORK-A NOT = SPACE and WS-WORK-B = SPACE and WS-WORK-C = SPACE
MOVE '2' TO ...
WHEN WS-WORK-A = SPACE and WS-WORK-B NOT = SPACE and WS-WORK-C = SPACE
MOVE '3' TO ...
WHEN OTHER
MOVE '4' TO ...
END-EVALUATE.
|
Hi,
Is there any reason not to use the code above? Is the original code posted (with the "also" option) more efficient than this?
Thanks. |
I have been offline (on vacation) the last week, hence the late reply.
One reason for not using the code as written is for clarity and ease of maintanance, as you have negated logical statements put in, where you could as well evaluate the condition as FALSE. Performancewise, I would recon that this construct where you compute the compound logical expression at each WHEN statement takes more processing power than specifying and executing the individual logical expressions at the EVALUATE statement separated by ALSO, and comparing the boolean results in each WHEN statements.
On the other hand this form of EVALUATE can only be used if the conditions involved can easily be formulated as one expression. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
efficient
Definition:
performing or functioning in the best possible manner with the least waste of time and effort;
having and using requisite knowledge, skill, and industry; competent; capable
sure is an overworked and miss-understood word.
key part of the definition:
the least waste of time and effort
and everyone who uses the word efficient seems to think that it only
applies to machine cycles.
as Kjeld so apply phrased: clarity and ease of maintanance
which is as important as saving the nano seconds.
also, if there are worries about efficiency of coded instructions,
why don't the posters of these suspected lack of efficient coding, code and test instead of voicing opinion? |
|
Back to top |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
Hi,
I know it's a little off the topic, but just for the sake of curiosity I compared the EVALUATE command with and without the use of ALSO and I couldn't see any difference in the elapsed time.
Each WHEN clause of both EVALUATE executed 900 milion times.
Follows the code:
Code: |
01 W-RESULT PIC S9(04) COMP VALUE 0.
01 A PIC X(10) VALUE ' '.
01 B PIC X(10) VALUE ' '.
01 C PIC X(10) VALUE ' '.
LINKAGE SECTION.
01 LK-PARM.
03 FILLER PIC XX.
03 LK-OPC PIC 9.
03 LK-TIMES PIC 9(09).
PROCEDURE DIVISION USING LK-PARM.
DISPLAY 'PARM=' LK-PARM
PERFORM AAA LK-TIMES TIMES.
MOVE 'X' TO A
PERFORM AAA LK-TIMES TIMES.
MOVE ' ' TO A
MOVE 'X' TO B
PERFORM AAA LK-TIMES TIMES.
STOP RUN.
AAA.
IF LK-OPC = 1
EVALUATE TRUE ALSO TRUE ALSO TRUE
WHEN A= SPACE ALSO B = SPACE ALSO C = SPACE
MOVE 1 TO W-RESULT
WHEN A NOT = SPACE ALSO B = SPACE ALSO C = SPACE
MOVE 2 TO W-RESULT
WHEN A = SPACE ALSO B NOT = SPACE ALSO C = SPACE
MOVE 3 TO W-RESULT
END-EVALUATE
ELSE
EVALUATE TRUE
WHEN A= SPACE AND B = SPACE AND C = SPACE
MOVE 1 TO W-RESULT
WHEN A NOT = SPACE AND B = SPACE AND C = SPACE
MOVE 2 TO W-RESULT
WHEN A = SPACE AND B NOT = SPACE AND C = SPACE
MOVE 3 TO W-RESULT
END-EVALUATE
END-IF.
|
Code: |
CSV016I REQUESTED MODULE IRXFUSER IS NOT EXECUTABLE
- -----TIMINGS (MINS.)------
-STEPNAME PROCSTEP RC EXCP CONN TCB SRB CLOCK SERV
-EVTPTSTB 00 285 3943 .87 .00 1.0 406
IEF451I J948T01 EVTPTSTB - ENDED BY CC 0000 - TIME=07.59.04 |
Code: |
CSV016I REQUESTED MODULE IRXFUSER IS NOT EXECUTABLE
- -----TIMINGS (MINS.)------
-STEPNAME PROCSTEP RC EXCP CONN TCB SRB CLOCK SERV
-EVTPTSTB 00 286 3730 .86 .00 1.0 423
IEF451I J948T02 EVTPTSTB - ENDED BY CC 0000 - TIME=07.59.01
|
Thanks. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
jctgf wrote: |
Hi,
I know it's a little off the topic, but just for the sake of curiosity I compared the EVALUATE command with and without the use of ALSO and I couldn't see any difference in the elapsed time.
Each WHEN clause of both EVALUATE executed 900 milion times.
|
I admit there is no significant difference in processing these statements, but the compiler optimisation does a great job in jumping out of a boolean expression with ANDs when it is clear that the result cannot be changed by subsequent subexpressions, ie. after the first subexpression that evaluates FALSE.
My point where not as much using ALSO or AND between sub expressions but more avoiding interspersed negated expressions in multiple WHEN statements for clarity's sake.
You didn't test my suggested EVALUATE statement, now you were at it? |
|
Back to top |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
hi there,
i ran the comparison 4 times.
each time runs a pair of jobs.
job 1 has the poster original evaluate.
job 2 has the avaluate you suggested.
1st comparison:
original:
Code: |
-----TIMINGS (MINS.)------ -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
.87 .00 2.0 435 BATCH 0 0 0 0
0000 - TIME=09.42.56
TOTAL TCB CPU TIME= .87 TOTAL ELAPSED TIME= 2.0
|
suggested:
Code: |
-----TIMINGS (MINS.)------ -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
.86 .00 2.0 440 BATCH 0 0 0 0
0000 - TIME=09.43.02
TOTAL TCB CPU TIME= .86 TOTAL ELAPSED TIME= 2.0
|
2nd comparison:
original:
Code: |
--TIMINGS (MINS.)-- -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
224.17 .00 1.0 1343K BATCH 0 0 0 0
0000 - TIME=09.45.18
TOTAL TCB CPU TIME= .87 TOTAL ELAPSED TIME= 1.0
|
suggested:
Code: |
--TIMINGS (MINS.)-- -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
221.95 .00 1.0 1330K BATCH 0 0 0 0
0000 - TIME=09.45.14
TOTAL TCB CPU TIME= .86 TOTAL ELAPSED TIME= 1.0
|
3rd comparison:
original:
Code: |
-----TIMINGS (MINS.)------ -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
.87 .00 2.0 384 BATCH 0 0 0 0
0000 - TIME=09.49.47
TOTAL TCB CPU TIME= .87 TOTAL ELAPSED TIME= 2.0
|
suggested:
Code: |
-----TIMINGS (MINS.)------ -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
.86 .00 2.1 383 BATCH 0 0 0 0
0000 - TIME=09.49.58
TOTAL TCB CPU TIME= .86 TOTAL ELAPSED TIME= 2.1
|
4th comparison:
original:
Code: |
-----TIMINGS (MINS.)------ -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
.87 .00 1.5 403 BATCH 0 0 0 0
0000 - TIME=09.54.35
TOTAL TCB CPU TIME= .87 TOTAL ELAPSED TIME= 1.5
|
suggested:
Code: |
-----TIMINGS (MINS.)------ -----PAGING COUNTS----
TCB SRB CLOCK SERV WORKLOAD PAGE SWAP VIO SWAPS
.86 .00 1.5 410 BATCH 0 0 0 0
0000 - TIME=09.54.34
TOTAL TCB CPU TIME= .86 TOTAL ELAPSED TIME= 1.5
|
the result is the same, except for comparison 3. it may be due to the machine load situation at the moment of the execution.
each evaluate is tested 900 million times and the jobs ran at the same time to ensure they were under the same conditions.
the program:
Code: |
> APPLID(ROS0P03) USER(HB1,E817252)
> LIB(HB1.EVTPTST0) SCRL CSR COLS 00001 00072 LINE 000062
> <...+....1....+....2....+....3....+....4....+....5....+....6....+....7..
000062 000790 PROCEDURE DIVISION USING LK-PARM.
000063 DISPLAY 'PARM=' LK-PARM
000064
000065 PERFORM AAA LK-TIMES TIMES.
000066
000067 MOVE 'X' TO A
000068 PERFORM AAA LK-TIMES TIMES.
000069
000070 MOVE ' ' TO A
000071 MOVE 'X' TO B
000072 PERFORM AAA LK-TIMES TIMES.
000073
000074 STOP RUN.
000075
000076
000077
000078 AAA.
000079 IF LK-OPC = 1
000080 EVALUATE TRUE ALSO TRUE ALSO TRUE
000081 WHEN A= SPACE ALSO B = SPACE ALSO C = SPACE
000082 MOVE 1 TO W-RESULT
000083 WHEN A NOT = SPACE ALSO B = SPACE ALSO C = SPACE
000084 MOVE 2 TO W-RESULT
000085 WHEN A = SPACE ALSO B NOT = SPACE ALSO C = SPACE
000086 MOVE 3 TO W-RESULT
000087 END-EVALUATE
000088 ELSE
000089 EVALUATE A = SPACE ALSO B = SPACE ALSO C = SPACE
000092 WHEN TRUE ALSO TRUE ALSO TRUE
000093 MOVE 1 TO W-RESULT
000094 WHEN FALSE ALSO TRUE ALSO TRUE
000095 MOVE 2 TO W-RESULT
000096 WHEN TRUE ALSO FALSE ALSO TRUE
000097 MOVE 3 TO W-RESULT
000098 WHEN OTHER
000099 MOVE 4 TO W-RESULT
000100 END-EVALUATE
000101 ******* EVALUATE TRUE
000102 ******* WHEN A= SPACE AND B = SPACE AND C = SPACE
000103 ******* MOVE 1 TO W-RESULT
000104 ******* WHEN A NOT = SPACE AND B = SPACE AND C = SPACE
000105 ******* MOVE 2 TO W-RESULT
000106 ******* WHEN A = SPACE AND B NOT = SPACE AND C = SPACE
000107 ******* MOVE 3 TO W-RESULT
000108 ******* END-EVALUATE
000109 END-IF.
SPACE |
Thanks. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Thanks jctgf for your effort,
I think the only conclusion for this is: What form of evaluate statement you use is not significant to processing time and resources. |
|
Back to top |
|
|
|