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

What could be file status check if i read the file reversed?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Mon Dec 14, 2009 1:58 pm
Reply with quote

Dear all,

I want to read my tapefile in the reversed order using cobol program 'REVERSED'. If so, how can i identify & stop the read process if it reached the first record of my file? will it return '10' as file status as EOF?

Please clarify.

Thanks,
Murali.
Back to top
View user's profile Send private message
Pravesh

New User


Joined: 30 Jul 2009
Posts: 32
Location: Gurgaon

PostPosted: Mon Dec 14, 2009 3:14 pm
Reply with quote

Hi Murali,
If your purpose is to have a file in reverse order than you can use FileAid. Go to copy screen than give these options
Process online or batch ===> B (for tape file) and
Selection criteria usage ===> T

in next screen go to
1 OPTIONS than
SEQ/VSAM processing direction ===> B (read in backward)
than F3,F3 and submit batch job.
Sorry I am not sure regarding file status in cobol program if you want to read in reverese order.

Regards,
Pravesh
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Dec 14, 2009 4:33 pm
Reply with quote

HTF are you going to read a tape file in reverse?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Dec 14, 2009 6:04 pm
Reply with quote

The COBOL 85 standard states explicitly that the REVERSED option is obsolete. If you wish to use an obsolete function, be aware that it may not behave as you expect, may not work at all, and any problems you experience will not be addressed as issues by IBM as the REVERSED option should not be used in modern programming.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Dec 14, 2009 6:21 pm
Reply with quote

"OPEN...REVERSED" may be obsolete according to the ANSI COBOL 85 standard, but it IS still supported by IBM ENTERPRISE COBOL FOR z/OS.

"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
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Dec 14, 2009 8:34 pm
Reply with quote

Hello,

Quote:
will it return '10' as file status as EOF?
Suggest you create a test tape with a very small amount of data and run a test on your system. . .

This will confirm that you have both a successful compile/link and what happens when the read raises AT END. If my memory is working, the READ. . . AT END occurred when trying to read the record "before" the "first" record - just like when reading normally. Been a very long time. . . icon_wink.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Dec 14, 2009 10:46 pm
Reply with quote

And how about VB datasets?
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Dec 14, 2009 10:57 pm
Reply with quote

I don't know exactly how the access method works when reading VB/VBS datasets in reverse, but it does work. Perhaps the access method checks the BDW/RDW's starting from the beginning of each physical block to determine where each logical record starts within the block and keeps the actual buffer addresses/offsets in a table so that it can "read" records in reverse order, AND also maintains an indicator so that it knows whether the first RDW belongs to a segment other than the first segment of a spanned record, and therefore needs to read another previous block in order to find the beginning of that logical record.

At least, that's how I would go about trying to read records in reverse order, if I were to attempt to do so.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Dec 14, 2009 11:15 pm
Reply with quote

Ronald Burr wrote:
I don't know exactly how the access method works when reading VB/VBS datasets in reverse, but it does work. Perhaps the access method checks the BDW/RDW's starting from the beginning of each physical block to determine where each logical record starts within the block and keeps the actual buffer addresses/offsets in a table so that it can "read" records in reverse order, AND also maintains an indicator so that it knows whether the first RDW belongs to a segment other than the first segment of a spanned record, and therefore needs to read another previous block in order to find the beginning of that logical record.

At least, that's how I would go about trying to read records in reverse order, if I were to attempt to do so.


No way you could do that in COBOL, obsolete and all the stuff.
You could use ,for example, a BSAM functionality to accomplish that.
But that needs some assembler programming.
Or start at the beginning of the tape dataset, count the records and do
some reading backward decreasing the recno.
But now im going to loose my mind, of course after heavy boozing we IT
guys need to do in a while.
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 Dec 14, 2009 11:23 pm
Reply with quote

It's hard to believe that there are still Data Centers out there with drives that support reel tape. icon_biggrin.gif
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sun Dec 20, 2009 1:03 pm
Reply with quote

oh i dint see this comment

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."


Apologies.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Dec 21, 2009 5:35 am
Reply with quote

Also in General Rules (6.2.26.1) it states
Quote:
When OPEN REVERSED is specified, the record format must be fixed.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Mon Dec 21, 2009 10:28 pm
Reply with quote

Interesting. In my 40 years in IT, I've never had to read a data set in reverse sequence.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Dec 21, 2009 11:43 pm
Reply with quote

Terry,

maybe you did not take the appropriate classes resulting in such homework.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Dec 21, 2009 11:57 pm
Reply with quote

Terry Heinze wrote:
Interesting. In my 40 years in IT, I've never had to read a data set in reverse sequence.

Perhaps you've just never had to PROGRAM a reverse read yourself, but I'll bet you've done reverse reading lots of times - e.g. every time you scroll in reverse ( UP or PREV ) while browsing a dataset.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Tue Dec 22, 2009 3:39 am
Reply with quote

That reminds me of the only time, I'm aware of, that I had to read keys of an ISAM (the predecessor of VSAM) file in pseudo reverse sequence, the keys were inserted in 9s complement so that the last record read was actually the most current price in a price list file. Obviously, that was before reverse reading was available.
Back to top
View user's profile Send private message
CaptBill

New User


Joined: 28 May 2009
Posts: 20
Location: Oklahoma City, OK USA

PostPosted: Sat Jan 02, 2010 5:38 pm
Reply with quote

The only time I have seen REVERSE used was in a SORT using TAPE as the intermediate media.
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 Unable to interpret a hex value to De... COBOL Programming 7
No new posts how to eliminate null indicator value... DB2 7
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts Check if CICS is online in JCL CICS 10
No new posts Format Binary file to EBCDIC JCL & VSAM 4
Search our Forums:

Back to Top