Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

reverse reading of a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sudhee_rb

New User


Joined: 29 Mar 2006
Posts: 34

PostPosted: Mon Apr 03, 2006 4:42 pm    Post subject: reverse reading of a file
Reply with quote

hi 2 all friends,
This is sudheer

I have a doubt regarding on reading a file

Can we read a file in reverse way?

Any body please clear my doubt.

thanks 4 before
Back to top
View user's profile Send private message

vikasc4

New User


Joined: 11 Dec 2005
Posts: 32

PostPosted: Mon Apr 03, 2006 4:48 pm    Post subject:
Reply with quote

Hi sudheer,

Yes u can read the file in reverse way, but there is a trick.............

and the trick is just first read the file in a table and then read that table in reverse order .

The size of table can be change dynamically by defining it with DEPENDING ON CLAUSE .

Regards
Vikas
Back to top
View user's profile Send private message
subramanianup
Warnings : 1

New User


Joined: 18 May 2005
Posts: 46
Location: Bangalore, INDIA

PostPosted: Fri Apr 07, 2006 2:13 pm    Post subject: Re: reverse reading of a file
Reply with quote

Hi sudheer and Vikas,
Reverse reading of file possible with some tricks.

For this you have to use SORT option, Introduce SEQNUM in that file and Sort the file in decending Order and then Remove Sequencial Nos and Now the File is in Reverse order

IN SORT

INREC FIELDS= < Here you have to INSERT Sequence No>
SORT FIELDS= < Here you have to Sort records on dec order of Seqnum>
OUTREC FIELDS = < After Sorting remove Sequence Number and write it in another file>

With Regards,
Subramanian UP
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Apr 07, 2006 2:24 pm    Post subject: Re: reverse reading of a file
Reply with quote

http://ibmmainframes.com/viewtopic.php?t=986

Regards,
Priyesh.
Back to top
View user's profile Send private message
winchaat

New User


Joined: 23 Mar 2005
Posts: 14

PostPosted: Fri Apr 07, 2006 3:05 pm    Post subject: hi
Reply with quote

We have to open the input file in reverse order as shown below:
OPEN INPUT file-name1 REVERSED
REVERSED positions the file at its end; subsequent READ statements retrieve the records in reversed order.


--------------->RAG
Back to top
View user's profile Send private message
ranga_subham

New User


Joined: 01 Jul 2005
Posts: 51

PostPosted: Fri Apr 07, 2006 8:47 pm    Post subject:
Reply with quote

Hmm.......not able to understand what benefits would it provide? I believe it just proves one's technical capability rather than achieving any purpose. Is it worth debatable?
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Fri Apr 07, 2006 10:48 pm    Post subject: Re: reverse reading of a file
Reply with quote

Ranga, I have seen this question asked many times before, usually as part of some Interview questions.

Most of the previous posts are accurate with the answer - No, not using COBOL if the data is on DASD (QSAM or VSAM). Yes, if the data is sorted in descending order first. Yes, using COBOL if the data is on TAPE. Yes, using REXX data stacks as previously shown. And finally, Yes using COBOL with the data on DASD if run within a CICS application.
Back to top
View user's profile Send private message
karthik1680
Warnings : 2

New User


Joined: 14 May 2005
Posts: 64
Location: chennai

PostPosted: Mon Apr 10, 2006 5:09 pm    Post subject: Re: reverse reading of a file
Reply with quote

hi sudheer ,
this may help you.

open-statement
______________________________________________________________________________
| |
| >>__OPEN___________________________________________________________________> |
| <__________________________________________________________________ |
| <________________________________________________ | |
| >________INPUT____file-name______________________________________|_____|__>< |
| | |_____REVERSED___________________| | |
| | |______________NO__REWIND__| | |
| | |__WITH__| | |
| | <__________________________________________ | |
| |__OUTPUT____file-name________________________________|_______| |
| | |______________NO__REWIND__| | |
| | |__WITH__| | |
| | <____________ | |
| |__I-O____file-name__|________________________________________| |
| | <____________ | |
| |__EXTEND____file-name__|_____________________________________| |
| |
|______________________________________________________________________________|
Back to top
View user's profile Send private message
karthik1680
Warnings : 2

New User


Joined: 14 May 2005
Posts: 64
Location: chennai

PostPosted: Mon Apr 10, 2006 5:12 pm    Post subject: Re: reverse reading of a file
Reply with quote

hi
check this link
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Mon Apr 10, 2006 5:43 pm    Post subject: Re: reverse reading of a file
Reply with quote

karthik1680, I wish you had posted ALL of the information regarding the OPEN statement, especially the footnote for the REVERSED and NO REWIND parameters, as documemted here:

Quote:

REVERSED

Valid only for sequential single-reel files. REVERSED is not valid for VSAM files.

If the concept of reels has no meaning for the storage medium (for example, a direct access device), the REVERSED and NO REWIND phrases do not apply.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us