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


Please Help Members By Posting Answers For Below Questions

Write the code implementing the perform … varying.

826


What is static and dynamic call in cobol?

793


EXPLAIN MAIN FRAME TESTING PROCESS...HOW TO FIX THE MAINFRAME BUGS?

2292


How do you define a variable of comp-1 and comp-2?

918


How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?

2235


Difference between cobol and cobol-ii?

949


What are declaratives and what are their uses in cobol?

951


What are the different types of condition in cobol and write their forms.

876


I have one ps file in which there are 3 fileds emp_no,emp_name and leave_app.this ps file information give the detail of employee which is going to apply for leave.suppose emp_no=113430,emp_name=ajay,leave_app=1 that means he is going to apply for 1 day leave.and accordingling the table in db2 will be updated means if he has that no of leave in his account then he will get dat leave and updated acc. in table(leave_balance=previous leave present in table-leave_app).Now i want to check whther the updated result is correct or not by comparing the two ps file using IEBCOMPARE or icetool so what is going to be the two ps file and how its is going to be compare.

2217


What are different data types in cobol?

916


What is perform what is varying?

920


System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..

1832


How do define dynamic array in cobol.

866


What is the difference between external and global variables in COBOL?

1052


What is the compute verb? How is it used?

856