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 statement, when-clause in conjunction with and

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Mon Jul 16, 2012 6:49 pm    Post subject: Evaluate statement, when-clause in conjunction with and
Reply with quote

Hello gent's

Me and my mate have a littel discussion about evaluate statement.

In his opinion one could use "and" to conbine to fields in a when clause.
Example:

EVALUATE TRUE
WHEN TFLD01-OK AND TFLD02-OK PERFORM A10-EXEC-STARTUP
WHEN TFLD01-OK AND TFLD02-NO PERFORM A10-EXEC-STARTUP
WHEN TFLD01-NO AND TFLD02-NO PERFORM A10-EXEC-STARTUP
WHEN TFLD01-NO AND TFLD02-OK PERFORM A10-EXEC-STARTUP
WHEN OTHER CONTINUE
END-EVALUATE

I be really convinced that this does not work. I just tested it via XPEDITER. The first time, when both fields meet the requirement, everything runs fine. After that nothing works any more, no matter whether the rule is true or not.

But he's still disbelieving cause i could not explain in detail the rason why.

Could anyone explain the rason ???

Thanks in advance
Back to top
View user's profile Send private message

Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Mon Jul 16, 2012 7:27 pm    Post subject: Reply to: Evaluate statement, when-clause in conjunction wit
Reply with quote

Code:
Evaluate True Also True
    WHEN TFLD01-OK Also TFLD02-OK
              PERFORM A10-EXEC-STARTUP 
    WHEN TFLD01-OK Also Any
              PERFORM A10-EXEC-STARTUP
    WHEN Any  Also TFLD02-OK
             PERFORM A10-EXEC-STARTUP
    WHEN OTHER
             CONTINUE
End-Evaluate
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Jul 16, 2012 7:32 pm    Post subject:
Reply with quote

Easy enough to check:
Code:
01  WS-VARS.
    05  WS-TFLD01       PIC X(02) VALUE 'OK'.
        88  TFLD01-OK             VALUE 'OK'.
        88  TFLD01-NO             VALUE 'NO'.
    05  WS-TFLD02       PIC X(02) VALUE 'OK'.
        88  TFLD02-OK             VALUE 'OK'.
        88  TFLD02-NO             VALUE 'NO'.

PROCEDURE DIVISION.
S1000-MAIN       SECTION.
    PERFORM 9999-CHECK.
    MOVE 'NO'           TO  WS-TFLD02.
    PERFORM 9999-CHECK.
    MOVE 'OK'           TO  WS-TFLD02.
    MOVE 'NO'           TO  WS-TFLD01.
    PERFORM 9999-CHECK.
    MOVE 'NO'           TO  WS-TFLD02.
    PERFORM 9999-CHECK.
    MOVE SPACES         TO  WS-TFLD01
                            WS-TFLD02.
    PERFORM 9999-CHECK.
    GOBACK.

9999-CHECK.
    EVALUATE TRUE
    WHEN TFLD01-OK AND TFLD02-OK
        DISPLAY '1 >' WS-TFLD01 '<>' WS-TFLD02 '<'
    WHEN TFLD01-OK AND TFLD02-NO
        DISPLAY '2 >' WS-TFLD01 '<>' WS-TFLD02 '<'
    WHEN TFLD01-NO AND TFLD02-NO
        DISPLAY '3 >' WS-TFLD01 '<>' WS-TFLD02 '<'
    WHEN TFLD01-NO AND TFLD02-OK
        DISPLAY '4 >' WS-TFLD01 '<>' WS-TFLD02 '<'
    WHEN OTHER
        DISPLAY '5 >' WS-TFLD01 '<>' WS-TFLD02 '<'
    END-EVALUATE.
gives output of
Code:
 1 >OK<>OK<
 2 >OK<>NO<
 4 >NO<>OK<
 3 >NO<>NO<
 5 >  <>  <
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Jul 16, 2012 7:43 pm    Post subject:
Reply with quote

without knowing what
TFLD01-OK
TFLD01-NO
TFLD02-OK
TFLD02-NO
represent,
can not give you an answer.

short answer though is that you can use "and" in a WHEN clause.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Jul 16, 2012 7:48 pm    Post subject: Reply to: Evaluate statement, when-clause in conjunction wit
Reply with quote

dbz got me beat. It's in the manual. A condition can be a compound, sorry, combined condition.

For the example not to be working, I'm afraid there is an error in the code, not the with the way EVALUATE works.

I hope for your sake it was only a small wager. A bottle of Red, not a Case...
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Mon Jul 16, 2012 8:08 pm    Post subject:
Reply with quote

Thank's guys !


Just to make shure, using the ALSO-clause is not the name of the game.

@ Peter cobolskolan: Ok, that's the way i would code that.

@Robert Sample: The thing is, is the use of combining fields in a when-clause using "and" or "or" legal or not.

In all the manuals you could not find something about the use of "and" or "or" in Evaluate-Statement.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Jul 16, 2012 8:17 pm    Post subject: Reply to: Evaluate statement, when-clause in conjunction wit
Reply with quote

...did you read mine? It is in the manual. May not be so explicit as giving examples, but it is all there. The condition can just be the same as any condition in an IF or whatever. AND, OR, whatever.

The ALSO could be used in combination with the combined conditions. Could be, but not sure I'd do it.

The ALSO segregates and matches for the EVALUATE rules. It would be, as Peter showed, possible to do the same with the ALSO ALSO.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Mon Jul 16, 2012 8:26 pm    Post subject:
Reply with quote

Why test in Expeditor rather than just run the code?
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Mon Jul 16, 2012 8:54 pm    Post subject:
Reply with quote

Thanks all !!!

I'll be reformed !!!

After my last post, i tried several exampels and it worked well.
I never saw a code line using the "and" in a when-clause before.

Seams that i had been along time away from Cobol, just using Assembler for the last 10 years.

@ Dick & Bill:
Ok, the condition can just be the same as any condition in an IF or whatever. AND, OR, whatever. That makes it clear.
A condition can be a combined condition.

And yes, it was a small wager, relative small. A dinner at McDonalds now after work.

@ Phrzby Phil:
Cause i can customize fields and the programm-flow as i need without editing and compiling.

So thank's for the quick response again.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Jul 16, 2012 9:07 pm    Post subject:
Reply with quote

UmeySan,

to follow-up on Bill's post:

within the EVALUATE discussion under 6.2.13.2 Determining values
the 4th point discussing Expression-1/Expression-2
provides a link to 6.1.6 Conditional expressions
which speaks of
Quote:
Conditional expressions are specified in EVALUATE, IF, PERFORM, and SEARCH statements.

which further expands to 6.1.6.13 Combined conditions

Unfortunately, IBM Manuals expects one to remember the definitions of terminology.
That way the manual does not have to continually provide full explanations of repeated terminology.

I also see that by the time I managed to cobble this together,
you have accepted the points brought to the table by others.

I have decided to leave this post for the benefit of those
who attempt to learn a language by just looking at the examples.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Mon Jul 16, 2012 10:41 pm    Post subject:
Reply with quote

Hi Dick !

Thank's a lot for this extraordinarydetailed description.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm


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