IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Using evaluate to replace a nested if structure


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Sat Mar 10, 2007 10:17 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts To replace jobname in a file with ano... SYNCSORT 12
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
Search our Forums:

Back to Top