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

What is the difference between Call and a Link?

694


Have you used comp and comp-3 in your project? And how?

2003


Explain how you can characterize tables in cobol?

636


HOw can I get the negative sign while deduct high value from low value

1781


What is the difference between next sentence and continue in cobol programing language?

701






What is report-item in COBOL?

702


How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?

2091


Define cobol?

856


What are the different open modes available in cobol?

713


)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?

1518


how do you reference the rrds file formats from cobol programs

790


In which area will you utilize 88 level items in cobol?

709


How to find out the closest prime number of an input number? I believe it has something to do with SEARCH and COBOL Linear Array.

3711


When is inspect verb is used in cobol?

670


What is the default value(s) for an initialize? What keyword will allow for an override of the default?

651