IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

reverse reading of a file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 1448
Location: Chicago, IL

PostPosted: Fri Apr 07, 2006 2:24 pm
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
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
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

Global Moderator


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

PostPosted: Fri Apr 07, 2006 10:48 pm
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
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
Reply with quote

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

Global Moderator


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

PostPosted: Mon Apr 10, 2006 5:43 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top