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?
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.
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
WHEN FUNCTION LENGTH(WK-CUST) NOT = 14 AND WK-CITY = SPACES AND WK-NWRT-IND NOT = 'D' OR 'R'
WHEN WK-CUST = SPACES AND WK-CITY NOT = SPACES AND WK-NWRT-IND NOT = 'D' OR 'R'
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.