Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / logeshwaran ravi

DATA DIVISION.
FILE SECTION.
FD WS-INFILE.
01 WS-INREC.
.
.
.
.

FD WS-OUTFILE.
01 WS-OUTREC.
.
.
.
.

WORKING-STORAGE SECTION.
77 INFS PIC XX.
77 OUTFS PIC XX.
77 CONT PIC 9(3).
77 NUM PIC 9(3).
PROCEDURE DIVISION.
001-OPEN-PARA.
OPEN INPUT WS-INFILE.
OPEN OUTPUT WS-OUTFILE.

002-READ-PARA.
READ WS-INFILE AT END PERFORM 003-WRITE-PARA.
COMPUTE CONT = CONT + 1.
003-WRITE-PARA.
COMPUTE CONT = CONT - 1.
READ WS-INFILE AT END PERFORM 009-CLOSE-PARA.
NUM = NUM + 1.
IF NUM = CONT THEN
MOVE WS-INREC TO WS-OUTREC
WRITE WS-OUTFILE
PERFORM 009-CLOSE-PARA
END-IF.
009-CLOSE-PARA.
CLOSE WS-INFILE WS-OUTFILE.
STOP RUN.

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the utilization of copybook in cobol? Could we utilize a similar copybook?

1233


how do you reference the esds vsam file formats from cobol programs

1222


What is the difference between Call and a Link?

1202


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

1126


Write some characteristics of cobol as means of business language.

1147


how to move the records from file to array table. give with code example

2682


Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc

1261


i want to learn mainframe..any websites and material to learn from basic..? my mail id : rajeswaribe2010@gmail.com

2227


Write a cobol program making use of the redefine clause.

1189


how do you reference the printer file formats from cobol programs

1227


What is perform what is varying?

1182


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.

2435


) how do u code after getting data?

2156


i want a program using by if, evaluate , string, unstring, perform, occurs?

4731


What is the utilization of copybook in cobol?

1199