View previous topic :: View next topic
|
Author |
Message |
adarsh444
New User
Joined: 02 Nov 2006 Posts: 17
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|