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 read records which is in sequential file in reverse
order ? Exp. 1 2 3 4 5 . i want 5 4 3 2 1?please clear my
doubt any one

Answers were Sorted based on User's Feedback



How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / abhishek

i am giving you pseudo code of same
suppose we have 5 records

rec-no 1-->10
rec-no 2-->1
rec-no 3-->25
rec-no 4-->35
rec-no 5-->20

read sequential file to get record count of file

close file

define an array whose size is equal to record count of file


open file

read file in loop

move current record of sequential file to last subscript of
array define above ( this can be taken care using perform
varying)

read the array starting from subscript 1 to record count

this will be similar to reading sequntial file in reverse
order.....


thanks,

Abhishek

Is This Answer Correct ?    23 Yes 0 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / mustafa i

Abhishekh your logic is correct
just to add to it
we can even do it by reading the file only once.

1)Read File & Move into an array until EOF also increment a
counter after every read.

3)By decrementing the Counter and using it as subscript
we can now read the array and hence the file in
reverse order.

Is This Answer Correct ?    10 Yes 4 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / chp

ok.. but if my file consists of the records 10 1 25 35 20??

Is This Answer Correct ?    6 Yes 3 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / sreejith

sort the file firt in decending order
and then read sequentially

Is This Answer Correct ?    12 Yes 10 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / rakesh

we dont know how many records in the file so how can u
declare the array ?

Is This Answer Correct ?    3 Yes 1 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / abhishek

@Rakesh You can define table occurs clause based on the No
of records that input file have.

All, You can reverse the file it self using external sort
before reading it.

Thanks,
Abhishek

Is This Answer Correct ?    1 Yes 0 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / gautam

Read file till end of the file and move the record to array.

Increase the counter.

Read the record from array until counter = 0.

Is This Answer Correct ?    1 Yes 0 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / mustafa i

@Rakesh ... you can then set it to a maximum.

Is This Answer Correct ?    1 Yes 1 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / mastan ummadisetti

First read the file and add a sequence number to it.
Then use sort for descending the records based on sequence numbers.

Is This Answer Correct ?    0 Yes 0 No

How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2..

Answer / gumba

Use Open Input file Reversed

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More COBOL Interview Questions

How can you pass values from COBOL program to non-COBOL programs?

2 Answers  


can we declare occurs in 01 level?

2 Answers   Temenos,


subscript and index r not coded in u r application program what will happen?

2 Answers  


If you were passing a table via linkage, which is preferable - a subscript or an index?

3 Answers   TCS,


what is s000 u4087 error? please give the all error codes in cobol,jcl.

0 Answers  


when iam reading a flat file which has 100 records through cobol program when iam reading 50th records it gets abends .. so when i run the program again it should read from 50th record .where it got abened ? how it is possible

1 Answers   Patni,


what is the result of the following? DIVIDE A INTO B GIVING C. a.C=A/B b.the reminder of B/A is stored in C c.C=B/A d.the reminder of A/B is stored in C

3 Answers   TCS,


study the data discriptions and answer the questions given below i)01 ORDER RECORD 05 OUT-HEADER PIC X(50) 05 ITEM-COUNT PIC 99 05 OUT-ITEM PIC X(20) OCCURS 1 TO 20 DEPENDING ON ITEM-COUNT ii)01 NAME-AND-ADDRESS 05 N-AND-A-LINE OCCURES 5 05 LINE-LENGTH PIC P9 05 N-AND-A-CHAR PIC X OCCURS 1 TO 20 DEPENDING ON LINE-LENGTH iii)01 SALES-LIST 05 SALESMAN-COUNT PIC 99 05 SALES PIC 9(6) OCCURS 1 TO 100 DEPENDING ON SALESMAN-COUNT iv)01 ORDER-RECORD 05 NO-OF-BRANDS PIC 99 05 BRAND-PURCHASED OCCURS 1 TO 15 DEPENDING ON NO-OF-BRANDS which of the following is true? a.i) and iii) are valid b.i) and iv) are valid c.i) and iii) are not valid d.all are valid

4 Answers   TCS,


Which Search verb is equivalent to PERFORM…VARYING?

0 Answers  


How can we increase the size of an existing PDS to include more no. of modules.

3 Answers  


How to change size of Initial number of records to *NOMAX for ALL PF files from perticular library, how can I do that

0 Answers  


What is EIBCALEN? Why it is used?

9 Answers   ADP,


Categories