views:

295

answers:

2

I have a PS file to be read in reverse order and process accordingly. Do we have a way to mention to read the file in reverse order in FD in COBOL module? OR do we have something to achieve the same using SORT?

Note: Reading the records into a buffer (array) and using it in reverse order would be the first idea that comes to mind but that way doesnt work for file with millions of records.

Your suggestions will be appreciated.

A: 

I do not believe there is a standard method for doing this in COBOL. However, if the file contains fixed length records you might try processing it as a relative file and just run thourgh it by descending record number. The other option is, as you suggest, sort it in reverse order then process as "normal".

NealB
Tried sorting it in the way you suggested, but didnt work. SORT didnt result the exact REVERSE of it. Still searching for options. Please lemme know if you found one.
Raja Reddy
A: 

Some versions of COBOL support a READ LAST statement to get the last record on the file. Then use READ PRIOR to read the file in reverse order. Not sure what COBOL version you're working with.

Paul Morgan