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
 

 

Using evaluate to replace a nested if structure

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

New User


Joined: 02 Nov 2006
Posts: 17

PostPosted: Sat Mar 10, 2007 9:09 pm    Post subject: Using evaluate to replace a nested if structure
Reply with quote

I am using evaluate to replace a nested if structure
Can i find an efficient way to replace the below scenario


PERFORM VARYING WS-L-CNT FROM 1 BY 1 UNTIL WS-L-CNT > 12
EVALUATE TRUE

WHEN FUNCTION LENGTH(WS-CUST(WS-L-CNT)NOT = 14 AND WS-CITY(WS-L-CNT) = SPACES AND WS-NWRT-IND(WS-L-CNT) NOT = 'D' OR 'R'
PERFORM 0900-RTN

WHEN WS-CUST = SPACES AND WS-CITY(WS-L-CNT) NOT = SPACES AND WS-NWRT-IND(WS-L-CNT) NOT = 'D' OR 'R'
PERFORM 0800-RTN

WHEN ...


WHEN OTHER
CONTINUE

END-EVALUATE
END-PERFORM
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Mar 10, 2007 10:17 pm    Post subject: Re: condition check
Reply with quote

adarsh444 wrote:
I am using evaluate to replace a nested if structure
Can i find an efficient way to replace the below scenario
Showing a snippet of code and asking for recommendations for efficiency will not give you the best results.
What little code you did provide leads me towards the feeling that maybe an evaluate might not be more efficient that nested ifs.
To speculate beyond this without the complete structure would be foolish.
BTW, if you do provide the structure, feel free to shorten the data names and subscripts for brevity.
And why are you using the FUNCTION LENGTH() intrinsic instead of the LENGTH OF special register?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Mar 11, 2007 1:53 am    Post subject:
Reply with quote

The typical way to make access to subscripted/indexed fields more efficeint is to move the SSed entry to a wrk area and access the wrk fields.

For example:
Code:
PERFORM VARYING WS-L-CNT FROM 1 BY 1 UNTIL WS-L-CNT > 12
   MOVE WS-CUST-ENT (WS-L-CNT) TO WK-CUST-ENT
   EVALUATE TRUE
   WHEN FUNCTION LENGTH(WK-CUST) NOT = 14 AND WK-CITY = SPACES AND WK-NWRT-IND NOT = 'D' OR 'R'
        PERFORM 0900-RTN
   WHEN WK-CUST = SPACES AND WK-CITY NOT = SPACES AND WK-NWRT-IND NOT = 'D' OR 'R'
        PERFORM 0800-RTN


What this does is eliminate the processing required to to find each element referenced in the table. Your ocde requires it to be done 5 times. By moving the entry it's done only once. The perfomance gain will be a function of the I/P vol, assuming the routine is driven by the I/P.

PS the length of the variable should be calculated outside of any loop. I'm assuming you know that its value is a constant throughout execution of the pgm.
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
No new posts Copybook structure in Load module Vai123 COBOL Programming 7 Fri Sep 16, 2016 8:29 pm
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm


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