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

Can you please let me know the centre name of INS certification in Kolkata.

2239


Define cobol?

1394


Can we change the password using ALTER? anyone tried and changed?

2015


Explain about different table spaces.

1090


What is the use of intialize verb?

1246


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

1455


What is the problem of ordered sequential files access?

1159


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

2469


What is the difference between goback, stop run and exit program in cobol?

1583


how do you define single dimensional array and multidimensional array in your cobol?

1092


What is the difference between PIC 9.99 and PIC9v99?

1334


What is the Purpose of Pointer in the string?

1075


Name the sections present in data division.

1237


What is an in line perform? When would you use it? Anything else you wish to say about it.

1069


What happens when we move a comp-3 field to an edited (say z (9). Zz-)?

1401