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 / krishna

<PROCEDURE DIVISION>
OPEN INPUT <INFILE>.
OPEN OUTPUT <OUTFILE>.
PERFORM <READ-PARA-NAME> UNTILL EOF='Y'.
PERFORM <CLOSE-PARA-NAME>.
================================
READ-PARA-NAME.
READ <INFILE> AT END MOVE 'Y' TO EOF
IF EOF NOT = 'Y'
MOVE INREC TO OUTREC
WRITE OUTREC.
================================
CLOSE-PARA-NAME.
CLOSE INFILE.
CLOSE OUTFILE.
STOP RUN.

Is This Answer Correct ?    4 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When is inspect verb is used in cobol?

922


can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

2141


What is the usage of comp fields in cobol?

878


if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.

6097


Have you used the sort in your project?for this type of questions any working on real time project give the eg. with real time scenario.

2240


IF I mention stop run in CICS what happens?

2094


Write the code implementing the perform … varying.

822


What are different data types in cobol?

915


What is amode(31)

915


How to remove the spaces at the end of each record in the output file of variable length, via cobol program?

889


What is the use of intialize verb?

982


Name some of the examples of COBOl 11?

2884


What is difference between static and dynamic call in cobol?

1036


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.

2213


What is cobol?

951