Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

EVALUATE going in wrong WHEN condition
Goto page 1, 2  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Mon Mar 22, 2010 5:24 pm    Post subject: EVALUATE going in wrong WHEN condition
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon Mar 22, 2010 5:35 pm    Post subject:
Reply with quote

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
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Mar 23, 2010 8:52 am    Post subject: Reply to: EVALUATE SYNTAX
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 23, 2010 9:48 am    Post subject:
Reply with quote

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
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Mar 23, 2010 9:56 am    Post subject:
Reply with quote

thanks Dick..!

Then is it using of NOT in when clause affecting the result of EVALUATE condition?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 23, 2010 10:17 am    Post subject:
Reply with quote

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
View user's profile Send private message
technut

New User


Joined: 27 Dec 2007
Posts: 73
Location: India

PostPosted: Tue Mar 23, 2010 10:29 am    Post subject: Reply to: EVALUATE SYNTAX
Reply with quote

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Mar 23, 2010 11:24 am    Post subject:
Reply with quote

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
Code:
1         
 2       
  3       
   4     


Please do let us know if there is anything wrong in the sample I have tried.. icon_smile.gif
Back to top
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Mar 23, 2010 11:54 am    Post subject:
Reply with quote

Binop,
This is exactly equal to what my scenario is. But still its not working properly for me. icon_sad.gif

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Mar 23, 2010 11:59 am    Post subject:
Reply with quote

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
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Mar 23, 2010 12:12 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Mar 23, 2010 1:02 pm    Post subject:
Reply with quote

icon_eek.gif
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... icon_cool.gif

Posting the whole EVALUATE statment might also help... ... icon_biggrin.gif
Back to top
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Mar 23, 2010 1:08 pm    Post subject:
Reply with quote

Quote:
Would like to know where the control is going from there...


After setting that flag, its going to END-EVALUATE.
Back to top
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Mar 23, 2010 4:02 pm    Post subject:
Reply with quote

I am sorry guys...! icon_sad.gif

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.. icon_biggrin.gif
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Wed Mar 24, 2010 5:53 pm    Post subject:
Reply with quote

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
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Sat Mar 27, 2010 6:41 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Apr 06, 2010 4:00 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 06, 2010 8:15 pm    Post subject:
Reply with quote

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
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Wed Apr 28, 2010 4:43 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon May 03, 2010 2:01 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am
No new posts 2 vsam file compare and update a fiel... ABINAYATHULASI DFSORT/ICETOOL 6 Sun May 29, 2016 11:15 am
No new posts File matching using specific condition mf_karthik DFSORT/ICETOOL 3 Fri Nov 20, 2015 11:04 pm
No new posts INCLUDE condition for 'Contains' krsenthil85 DFSORT/ICETOOL 4 Mon Oct 26, 2015 11:03 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us