How to read records from flat file in reverse order through
COBOL program?
Answers were Sorted based on User's Feedback
Answer / srini
Sort the file based on key in descending order. You can
read the file in reverse order.
Is This Answer Correct ? | 44 Yes | 27 No |
Answer / shrik
Reading the records into a buffer (array) and using it in
reverse order would be the first idea that comes to mind but
that way doesnt work for file with millions of records.
Is This Answer Correct ? | 18 Yes | 6 No |
Answer / satty
we can read file in reverse order by using a dynamic array.
first transfer the ps into array and read it by -1 from
counter = no of records in the file
Is This Answer Correct ? | 7 Yes | 3 No |
Answer / mahendra.ch
first we can move the records to an occurs
then
we can solve this problem by using perform varing 1 by -1
until i=0
hear i = number of racords.
iam shure it works.
thank you....
Is This Answer Correct ? | 8 Yes | 4 No |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR INPUT DATASET,DISP=SHR
//SORTOUT DD DSN=YOUR OUTPUT FILE IN REVERSE ORDER,
// DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
INREC FIELDS=(1,80,SEQNUM,8,ZD)
SORT FIELDS=(81,8,ZD,D)
OUTREC FIELDS=(1,80)
/*
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / laxmaiah
i have some knowledge in flat files,
(open input file-name reversed)
in this type use read the data in reverse order
AND write another file
Is This Answer Correct ? | 16 Yes | 13 No |
Answer / pa
Being a flat file, we cant be sure that it will have a unique key field. So, External to the cobol program , using SORT utility, we can add a serial no column, and then SORT it in descending order based on that column and read the file sequentially in COBOL program.
Is This Answer Correct ? | 2 Yes | 0 No |
1. Using FileAid
//STEP0100 EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//DD01 DD DSN=YOUR INPUT DATASET,DISP=SHR
//DD01O DD DSN=YOUR OUTPUT FILE IN REVERSE ORDER,
// DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
$$DD01 COPYBACK
/*
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sravani
using rrds it is possible. we can count the no of records using rrds key. by using if we can decrement from last to first
Is This Answer Correct ? | 0 Yes | 7 No |
if a file has 1000 recods how copy the records from 1 to 100 records using sort
what is the maximum error code in mainframe
what is the minimum number of lines a Cobol program should have to successfully compile and run
What is the maximum size of a 01 level item in COBOL I? in COBOL II?
in cobol i have one file it contains records like 10,4,23,98,7,90..... total records 100. iwant 10 to 20 in reverse order in cobol environ ment any one please give the answer......
what do you mean by copybook? and what is the difference between the copybook which we are using in working storage and procedure division.
how to convert the recors form vsam file to db2 table tru file aid
How did the release of cobol/370 version 1.3 improve the performance of release 1.1?
What is SET TO TRUE all about, anyway?
How to read a record from bottom of a file which is indexed by 'A'.
what is the minimum number of lines a Cobol program should have to successfully compile and run
11 Answers ABC, Societe Generale,
can we use variable picture clause as xx.99 in cobol.