如何逆序读取PS文件?
我有一个 PS 文件要以相反的顺序读取并进行相应的处理。我们有没有办法提到在COBOL模块的FD中以相反的顺序读取文件?或者我们是否可以使用 SORT 来实现相同的目标?
注意:将记录读入缓冲区(数组)并以相反的顺序使用它是第一个想到的想法,但这种方式不适用于具有数百万条记录的文件。
您的建议将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不相信 COBOL 中有执行此操作的标准方法。但是,如果文件包含固定长度记录,您可以尝试将其作为相对文件处理,并按记录号降序运行。正如您所建议的,另一种选择是按相反顺序对其进行排序,然后按“正常”处理。
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".
如果文件所在的设备支持它,则可以使用“OPEN INPUT fname REVERSED”。但该文件需要位于磁带或假装磁带的设备上。
If the device the file is on supports it, you can use "OPEN INPUT fname REVERSED". But the file will need to be on a tape or a device that is pretending to ba a tape.
COBOL 的某些版本支持 READ LAST 语句来获取文件的最后一条记录。然后使用 READ PRIOR 以相反的顺序读取文件。不确定您正在使用哪个 COBOL 版本。
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.