Try the below. READ-LAST-RECORD. READ INPUT-FILE AT END SET WS-END-OF-FILE TO 'Y' END-READ. READ-PREVIOUS-RECORD. READ PREVIOUS INPUT-FILE AT END SET WS-END-OF-FILE TO 'Y' END-READ. The above will read the last record in the input file using the "READ" statement in the READ-LAST-RECORD paragraph. It then reads the previous record in the file using the "READ PREVIOUS" statement in the READ-PREVIOUS-RECORD paragraph.
Sir , Could you also please make a video on COBOL batch Debugging.
How to read file in reverse order in COBOL program
Try the below.
READ-LAST-RECORD.
READ INPUT-FILE
AT END
SET WS-END-OF-FILE TO 'Y'
END-READ.
READ-PREVIOUS-RECORD.
READ PREVIOUS INPUT-FILE
AT END
SET WS-END-OF-FILE TO 'Y'
END-READ.
The above will read the last record in the input file using the "READ" statement in the READ-LAST-RECORD paragraph.
It then reads the previous record in the file using the "READ PREVIOUS" statement in the READ-PREVIOUS-RECORD paragraph.