how to fetch the record before the last record in a cobol
file( its a huge file and if the key field is not known)
Answer Posted / lakshmi
1) iN WORKING STORAGE SECTION, Declare 2 variables HOLD-REC
and PRV-REC Equal to length of file and initialize them to
spaces
2) In Procedure divison, use the below logic and at the end
of the file read, PRV-REC contains the record before the
last record
READ <INFILE>
NOT AT END
MOVE HOLD-REC TO PRV-REC
MOVE INREC TO HOLD-REC
AT END
MOVE 'Y' TO EOF
END-READ
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
How to use the same COBOL program in Batch and CICS on lines? explain with an example
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
What are the different data types in cobol?
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc
How arrays can be defined in COBOL?
How do define dynamic array in cobol. how do you define single dimensional array and multidimensional array in your cobol?
What is the usage of comp fields in cobol?
what is the use of outrecord?
In which area will you utilize 88 level items in cobol?
What is the difference between binary search and sequential search?
i need a small 3d program using inline and outline.
Program A (Normal COBBAT) calling a B Program (DB2COBOL, COBBATDB which is using a VSAM file. its a dynamic call. How we will handle VSAM file decleration in our from JCL from where we are running A PGM. And should we have PLAN for A pGM also. if possible can some one post a sample JCL. Thanks for help in advance.
What is a SSRANGE and NOSSRANGE?
Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?
how do you reference the variable unblock file formats from cobol programs