How to read records from flat file in reverse order through
COBOL program?

Answers were Sorted based on User's Feedback



How to read records from flat file in reverse order through COBOL program?..

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

How to read records from flat file in reverse order through COBOL program?..

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

How to read records from flat file in reverse order through COBOL program?..

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

How to read records from flat file in reverse order through COBOL program?..

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

How to read records from flat file in reverse order through COBOL program?..

Answer / dimpy19

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

How to read records from flat file in reverse order through COBOL program?..

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

How to read records from flat file in reverse order through COBOL program?..

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

How to read records from flat file in reverse order through COBOL program?..

Answer / dimpy19

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

How to read records from flat file in reverse order through COBOL program?..

Answer / dimpy19

When REVERSED is specified, OPEN statement execution positions the QSAM file at its end. Subsequent READ statements make the data records available in reversed order, starting with the last record


Open INPUT filename REVERSED

Is This Answer Correct ?    0 Yes 0 No

How to read records from flat file in reverse order through COBOL program?..

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

Post New Answer

More COBOL Interview Questions

Please let me know how the Eject verb works for page break.. I want to know the code, how it is used.

3 Answers  


what are the diferences b/w sub-script and index?

4 Answers  


what is the advantage of using redefines instead of delaring the variables ?

5 Answers   HCL,


How can we know that cobol program is using report file or simple file....?

4 Answers  


What is 66 level number and where it is used in real time by software developers?

2 Answers   ITC Indian Tobacco Company, TCS,






is it possible to rename 01 level?

4 Answers  


how to display comp3 variables reply soon ?

4 Answers   Patni,


I have one column say 'X' defined as VARCHAR Can anyone tell me What are the different ways to update this column thru COBOL-DB2 program?

5 Answers  


01 text-data pic x(100). move 'xyzdbfrjjg u' to text-data. how to find the value of last index of text-data?

3 Answers   Mind Tree,


How does IDMS insure data integrity?

1 Answers  


Why there is no questions in this column?

6 Answers  


given the following piece of code: CALL SUB-PGM USING A, B, C. CALL SUB-PGM USING A, C, C. (a) Both CALL statements will always produce same result. (d) Both CALL statements may produce different result. (c) Compile-time error because SUB-PGM is a dataname. (d) Compile-time error because A, B, C are used twice.

2 Answers   TCS,


Categories