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

What is rmode(24)

0 Answers  


How to retain the Duplicates in the one records?

3 Answers   CS,


What are the pertinent COBOL

0 Answers   IBM,


What are the situations u have used in ur project for Subcript and Index ? 1.if u use Subscript why not Index,why u choose Subscript only? 2.if u use Index why not Subscript,what abt Displacement?

2 Answers   Cap Gemini,


In EBCDIC, how would the number 1234 be stored?

2 Answers   TCS,


What is report-item?

1 Answers   IBM,


What is the difference beetween Arrays and Tables in Cobol? please dont give the answer that arrays in cobol terminology is called tables......

3 Answers   BirlaSoft,


what is rediffine clause?in what situation it can use?give me real time example?

1 Answers   IBM,


What is Pic 9v99 Indicates in COBOL?

0 Answers   SwanSoft Technologies,


How to solve SOC7. I have the cobol coded as below 01 A PIC 9(4). 01 AIN REDEFINES A. 05 AIN1 PIC S9(4) 01 B PIC 9(4)V99. 01 BIN REDEFINES B. 05 BIN1 PIC S9(4)V99. PROCEDURE DIVISION. START-PARA. INITIALIZE A AIN B BIN. ACCEPT A B. DISPLAY 'VALUE OF A=' A. DISPLAY 'VALUE OF B=' B. DISPLAY 'VALUE OF BIN1=' BIN1. DISPLAY 'VALUE OF AIN1=' AIN1. COMPUTE AIN1 = BIN1 - AIN1. DISPLAY 'VALUE OF AIN1=' AIN1. When i'm executing this code i'm getting SOC7 for A = 12 & B=34. Can someone explain SDSF OUTPUT DISPLAY TCOM058R JOB05458 DSID 102 LINE 0 COLUMNS 02- 81 COMMAND INPUT ===> SCROLL ===> CSR ********************************* TOP OF DATA ********************************** VALUE OF A=12 VALUE OF B=34 VALUE OF BIN1=34 VALUE OF AIN1=12 CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit PROG1 at entry point PROG1 at statement 29 at compile +000004CE at address 00007ECE. Please address how to solve this issue Thanks in advance.

1 Answers  


record length in spool?

2 Answers   Infosys,


What is diff betn PS and ESDS file? What is the diffrent compiler options in cobol and there discription? What is retrive nth maximum salary from salary DB2 table. Can we redefine COM-3 variable with varchar variable?

4 Answers  


Categories