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 statemet in cobol

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

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Fri Aug 28, 2009 9:14 am    Post subject: Evaluate statemet in cobol
Reply with quote

Hello

can we use if statement while using evaluate statement in cobol???
Back to top
View user's profile Send private message

Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 9:16 am    Post subject:
Reply with quote

Show us what you propose, and then we can answer. Your question is a bit vague.
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Fri Aug 28, 2009 9:23 am    Post subject: Reply to: evaluate statemet in cobol
Reply with quote

i have 8 conditions to be checked
like if TYP-CLM= 'A' or 'B' or 'C' or 'D' till 'H'

and inside every if condition i have to check for
if WS-TOTH-UP Not = 0

so for all 8 conditions i have to check the second condition.

i want to apply evaluate condition so can u please tell me whether i can apply if condition inside evaluate??
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 9:31 am    Post subject:
Reply with quote

IFs can be inside EVALUATEs and EVALUATEs can be inside IFs, so yes, you can do what you want. Depending on what exactly you want to do when these conditions are met, there may be more than one way to word your statement. Can you be even more specific?
Back to top
View user's profile Send private message
steve6

New User


Joined: 10 Jul 2007
Posts: 7
Location: Chennai

PostPosted: Fri Aug 28, 2009 9:46 am    Post subject:
Reply with quote

I would suggest the following;

EVALUATE TYP-CLM ALSO WS-TOTH-UP NOT = 0

WHEN 'A' ALSO TRUE
......


WHEN 'B' ALSO TRUE
......

END-EVALUATE

_______________________________________
Stephan
Knowledge grows when shared
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Fri Aug 28, 2009 10:25 am    Post subject:
Reply with quote

Hi Veena,
Check for the WS-TOTH-UP in the IF condition and then check for the other condition in the evaluate condition.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 10:39 am    Post subject:
Reply with quote

Given your initial post, I'd assign a condition name (88 level) to TYP-CLM, then have an IF within an IF. Unless you can be more specific about the conditions you are checking for, that's all we can suggest.
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Fri Aug 28, 2009 10:52 am    Post subject: Reply to: evaluate statemet in cobol
Reply with quote

Hi... I got the logic.. thnks for the suggestions

I have used evaluate and if together its running fine
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 11:10 am    Post subject:
Reply with quote

Can you show us the code you decided on? As I said earlier, there are probably several ways to accomplish the end result and some are easier to maintain than others.
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Fri Aug 28, 2009 11:32 am    Post subject: Reply to: evaluate statemet in cobol
Reply with quote

Code:
EVALUATE TYP-CLM-TOT                                     
WHEN 'A'                                                 
  ADD   WS-TOTAL-COUNT  TO WS-TCLN-AE                     
  IF WS-TCLN-AE NOT = ZEROES                             
     DIVIDE WS-TCLN-AE    INTO DAYS30-TOT                 
     GIVING W-PCT-DAYS30                                 
     COMPUTE WS-PCT-DAYS30 ROUNDED =  W-PCT-DAYS30 * 100 
                                                       
     END-IF                                                 
 WHEN 'B'                                                 
    ADD  WS-TOTAL-COUNT TO WS-TCLN-AP                   
     if WS-TCLN-AP NOT = ZEROES
        DIVIDE WS-TCLN-AP    INTO DAYS30-TOT                 
        GIVING W-PCT-DAYS30                                 
        COMPUTE WS-PCT-DAYS30 ROUNDED =  W-PCT-DAYS30 * 100   
     end-if

....

this is the code i ve implemented
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Fri Aug 28, 2009 11:53 am    Post subject:
Reply with quote

Hi Veena,
Both of the if condtion in each of the case is diff so , i dont think so that u can check for the if condtion before the evaluate you need to check inside the case statement.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 12:02 pm    Post subject:
Reply with quote

Given the fact that the 8 different values of TYP-CLM-TOT deal with 8 different fields, your solution is what I would've written too, except that what happens if WS-TCLN-AE = zero? It's okay if WS-PCT-DAYS30 has been previously initialized to zero. If not, it will not have a valid value. You could eliminate the IF by replacing the DIVIDE statement by:
Code:
DIVIDE WS-TCLN-AE INTO DAYS30-TOT GIVING W-PCT-DAYS30
    ON SIZE ERROR
        MOVE ZERO TO W-PCT-DAYS30
END-DIVIDE
Also, please use BBCode for readability. See FAQ.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Fri Aug 28, 2009 12:29 pm    Post subject:
Reply with quote

I would have stored WS-TCLN-AE ..WS-TCLN-AP in an array

Code:

Evaluate TYP-CLM-TOT
when 'A' move 1 to ws-ix
when 'B' move 2 to ws-ix
...
otherwise display 'houston we have a problem'
               move 9 to ws-ix
END-EVALUATE

ADD WS-TOTAL-COUNT TO WS-TCLN (ws-ix)
IF WS-TCLN (ws-ix) NOT = ZEROES
DIVIDE WS-TCLN (ws-ix) INTO DAYS30-TOT
GIVING W-PCT-DAYS30
COMPUTE WS-PCT-DAYS30 ROUNDED = W-PCT-DAYS30 * 100


if you need some meaningful names for each total, you can use redefines or 88-levels on ws-IX

Code:
01 TAB-TCLN.
     03 WS-TCLN-AE           PIC s9(9)v9(2) comp-3.
     03 WS-TCLN-AP           PIC s9(9)v9(2) comp-3.
     ...
     03 WS-TCLN-Grbg         PIC s9(9)v9(2) comp-3.
01 TAB-TCLN2 redefines TAB-TCLN.
    03  WS-TCLN              PIC s9(9)v9(2) comp-3 occurs 9.


01 WS-Indexes.
     03  WS-IX                PIC s9(4) comp.
           88 WS-IX-AE        VALUE 1.
           88 WS-IX-AP        VALUE 2.
           ...
           88 WS-IX-grbg      VALUE 9.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 7:18 pm    Post subject:
Reply with quote

veena,
As you can see, there are usually many variations that will yield the correct result. Try to pick one that is flexible enough for future changes and is easily understood by the next person who maintains the code. Because of CPU speeds these days, worry less about performance of an individual statement (there are exceptions of course) and more about maintainability.
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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