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
 

 

Why Alternate indexes are not supported for VSAM RRDS?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Asif Bhatkar

New User


Joined: 21 Dec 2009
Posts: 5
Location: India

PostPosted: Mon Nov 28, 2011 12:19 pm    Post subject: Why Alternate indexes are not supported for VSAM RRDS?
Reply with quote

Hi,

I was going through the manual and found that Alternate indexes are not supported for VSAM RRDS. I tried to find the reason as to why AIX is not supported for RRDS files (Google, Manuals, & Forum), but unable to find the reason for this.

Could you please help me understand as to why AIX is not supported for VSAM RRDS. Thanks for your help.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Mon Nov 28, 2011 3:26 pm    Post subject:
Reply with quote

Because IBM says they are not. That is all the reason you need to know. I'm sure IBM has its reasons for making this statement (not the least of which is an alternate index on an RRDS makes no sense at all), but whether or not you can find out anything more about their reasons -- good luck.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Tue Nov 29, 2011 12:51 am    Post subject:
Reply with quote

I guess I want to know: do RRDS's have any indexes at all?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Tue Nov 29, 2011 2:17 am    Post subject:
Reply with quote

That depends upon how you define "index". An RRDS is accessed by relative record number -- hence RRDS. In a sense, the relative record number is an index -- 0 refers to the first slot (block), 17 to the 18th slot (block), and so forth. The relative record number is NOT an index in the sense of a KSDS, especially since records can be inserted into a KSDS but not an RRDS, but if you want the record in the 79th slot (block) you can get to it quickly.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Nov 29, 2011 2:57 am    Post subject: Reply to: Why Alternate indexes are not supported for VSAM R
Reply with quote

To add to Robert's information, there is also the VRRDS, a much newer beast. An RRDS has traditionally always been a fixed-length record. Thus VSAM can calculate where to get the next record very easily.

A VRRDS is an RRDS with a variable-length record. Which then makes it tricky for VSAM to calculate where a record is. So, there is an index...

I've only used two RRDSs. Both held transaction data, referenced by a "master record" on a KSDS. Large number of transactions, 99+% new each day, small number of inserts for "master", would have "split" a KSDS to heck and back. Splitting the data across the two types gave a nice balance.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Tue Nov 29, 2011 3:02 am    Post subject:
Reply with quote

Thanks to you both. I've used relative record files sparingly and was not familiar with the new flavors. Most interesting.

Bill - is the index for the VRRDS just an index on the record#? What is the gain here?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Nov 29, 2011 5:10 am    Post subject: Reply to: Why Alternate indexes are not supported for VSAM R
Reply with quote

The gain is in being able to find the record. The old fixed-length type are easy. Like entries in a Cobol table accessed by an index. Record/slot number (given starting from zero) * record length = start byte in file. VSAM knows how much data is in the "control area" (CA), so knows by calculation which CA the record is in and the location of the record within that CA.

If the records are variable in length, that whole calculation thing goes to pot. So needs an index to the record numbers in the CA at the very least. I'd have to check up on the details. I've never used a VRRDS. Has anyone out there?
Back to top
View user's profile Send private message
Asif Bhatkar

New User


Joined: 21 Dec 2009
Posts: 5
Location: India

PostPosted: Tue Nov 29, 2011 11:52 am    Post subject:
Reply with quote

Thank you Robert and Bill for your help.

I did some more search and did try delete of a record in test VSAM RRDS file and found that after delete of a record the slot of a record remains as it is. It is not removed. VSAM writes all binary 0's in that slot. So suppose if we had an alternate key defined for this file (which in turn would point to RRN), the search of a record (deleted one) would not result in "INVALID KEY - RECORD NOT FOUND", but in turn would found the empty slot of binary 0's, and lead to unexpected data errors in our code.

In case of KSDS (AIX - NOUPGRADE option) we would surely get the INVALID KEY - RECORD NOT FOUND in above situation.

I believe this may be one of the reason why IBM says no AIX for RRDS. Please correct me if i am wrong.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Nov 29, 2011 1:04 pm    Post subject: Re: Reply to: Why Alternate indexes are not supported for VS
Reply with quote

The gain is in being able to find the record. The old fixed-length type are easy. Like entries in a Cobol table accessed by an index. Record/slot number (given starting from zero) * record length = start byte in file. VSAM knows how much data is in the "control interval" (CI), so knows by calculation which CI the record is in and the location of the record within that CI.

If the records are variable in length, that whole calculation thing goes to pot. So needs an index to the record numbers in the CI at the very least. I'd have to check up on the details. I've never used a VRRDS. Has anyone out there?

icon_redface.gif That woke me up early for this time of year.

As far as I got last night, the index of a VRRDS is the same structure as that of a KSDS, but don't quote me on that.

Like Robert, I can throw no light on why an AIX is not allowed. As Robert has said, the records/slots are always there. You can re-use an "old" one, but they are always there. I don't see why that would preclude an AIX in itself.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Tue Nov 29, 2011 4:05 pm    Post subject:
Reply with quote

Probably because it doesn't make logical sense; a (V)RRDS with an alternate index would be a KSDS with the primary index being a (perhaps virtual) sequence number.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Nov 29, 2011 4:14 pm    Post subject: Reply to: Why Alternate indexes are not supported for VSAM R
Reply with quote

So, including me, that makes three for "can't think why you'd need to do that".

I don't think this will ever be asked in an interview (the "why not" bit) as the interviewer will have no clue about it either. OK, maybe that doesn't preclude the question...
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Thu Dec 01, 2011 4:26 pm    Post subject:
Reply with quote

Robert Sample wrote:
That depends upon how you define "index". An RRDS is accessed by relative record number -- hence RRDS. In a sense, the relative record number is an index -- 0 refers to the first slot (block), 17 to the 18th slot (block), and so forth. .


I have to disagree with that. If you execute IDCAMS with :
PRINT IDS(your RRDS) FNUM(1) COUNT(1)
or REPRO for that matter, you will get the first record.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Dec 01, 2011 5:57 pm    Post subject: Reply to: Why Alternate indexes are not supported for VSAM R
Reply with quote

If zero refers to the first slot, then the first slot also refers to zero.

If you print/repro record one (for us humans) you are actually getting slot zero, as in it is zero displacement in the dataset. Record two is displacement of one x record-length in the dataset, three is two times record-length, etc.

Indexes in Cobol are analagous to this. You can't set an index to zero (in mainframe Cobol). Yet if you set it to one, the value of the index is zero. If you set an index to two, the value is one x the length of the occurs. Three, is two times the length of the occurs.

Doing it "offset" by a logical minus one saves the "system" (being whatever is responsible for idoing it, AMS or an application program at run-time) doing the "subtract one" for every access to the data (RRDS or Cobol table via index).
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: Thu Dec 01, 2011 10:50 pm    Post subject:
Reply with quote

The reality is that there is no such thing, logically, as relative block or slot or record or entry or field or byte number zero.
There IS such a thing, logically, as offset zero (which would be relative byte number 1, of relative field number 1, etc.).

In the "old days", before the actual record length of a variable record was returned during a read operation,
in order to obtain the actual length, we would actually FORCE the program to use an "illogical" relative value zero.
We did this by redefining the input record thusly

Code:
01 RDW-RECORD REDEFINES INPUT-RECORD.
  05  RDW-ENTRY   OCCURS NN TIMES.   where nn = int (max-record-length / 4)
    10 RDW        PIC XX.             
    10 FILLER     PIC XX.


Then, by 'forcing' the subscript (relative entry number) to be equal to zero,
we would be able to access the actual RDW (record descriptor word) of the record (which immediately preceeded the actual record) in the input buffer.
This worked because the RDW was in "illogical" relative entry number zero (that is, the 4 byte entry which preceded relative entry number 1 - which contained the first 4 bytes of the actual record).
The generated assembler code using a subscript of zero takes the form

ENTRY-ADDR = START-ADDR + ((entry-length * subscript) - entry-length)
or, in this specific case,
ENTRY-ADDR = RECORD-ADDR + ((4 * 0) - 4)
or
ENTRY-ADDR = RECORD-ADDR + (0 - 4)
or
ENTRY-ADDR = RECORD-ADDR - 4
or
ENTRY-ADDR = the address of the record's RDW,
the first half-word of which contains the actual record length.

Note: since COMP-5 had not yet been invented,
and the value of the first halfword could be greater than 9999, we would code:
Code:
in the WORKING-STORAGE SECTION

01  IPRL-WORK.
  05  IP-REC-LEN PIC 9(5) COMP SYNC.
  05  IPRL-RED   REDEFINES IP-REC-LEN.
    10  FILLER   PIC 9(4) COMP VALUE ZEROS.
    10  IPRL-X   PIC XX.

and in the PROCEDURE DIVISION following a READ

    MOVE RDW(0) TO IPRL-X
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Thu Dec 01, 2011 10:50 pm    Post subject: Re: Reply to: Why Alternate indexes are not supported for VS
Reply with quote

Bill Woodger wrote:
If zero refers to the first slot, then the first slot also refers to zero.

If you print/repro record one (for us humans) you are actually getting slot zero, as in it is zero displacement in the dataset. Record two is displacement of one x record-length in the dataset, three is two times record-length, etc.


We are not talking here about slots but about RRN's. And how VSAM computes something between the sheets is of no importance. Comparing things all the time how it works in cobol with indices etc. is b.s., you can also name a lot of other programming languages working with a zero relative indexing.

The point is RBA's work from zero, and RRN's from 1.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Dec 01, 2011 11:46 pm    Post subject: Reply to: Why Alternate indexes are not supported for VSAM R
Reply with quote

Quote:
And how VSAM computes something between the sheets is of no importance
If it happens between my sheets, i might find it important. . . icon_cool.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Dec 02, 2011 5:51 am    Post subject: Re: Reply to: Why Alternate indexes are not supported for VS
Reply with quote

PeterHolland wrote:


We are not talking here about slots but about RRN's. And how VSAM computes something between the sheets is of no importance. Comparing things all the time how it works in cobol with indices etc. is b.s., you can also name a lot of other programming languages working with a zero relative indexing.

The point is RBA's work from zero, and RRN's from 1.


Peter, as far as I can tell from research today, you are right. As I cannot locate the manual (which I assume no longer exists, something like DOS/VSE Access Method Services for Systems Programmers (we didn't have one at the time), or the person who possibily told me this (this would have been about 1984) I can't tell what it was I misunderstood, but I suspect it was the person as the CIs for an RRDS are not as simple as I thought they were either, they still have RIDFs (which here would be used to indicate the presence or absence of data in the slot) and a CIDF so the calculation can not be as straightforward as I made out anyway.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Fri Dec 02, 2011 12:36 pm    Post subject:
Reply with quote

Quote:

they still have RIDFs


It is RDF.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Dec 02, 2011 5:12 pm    Post subject: Reply to: Why Alternate indexes are not supported for VSAM R
Reply with quote

Yes. I also managed to get an "unbalanced left parenthesis". I have always had a blind-spot for whether "system programmer" in these manual titles is singular, plural, singular-possesive, plural-possesive, for either of the words. Same with the Programmer in Programmer Reference. Every time I write them, I feel I should check...

I also need to verify what I "know" about RBAs, same sources, same time :-)
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts BWO option in VSAM blayek CICS 3 Sat Nov 05, 2016 10:47 am
No new posts VSAM define for large file jerryte JCL & VSAM 9 Wed Oct 05, 2016 1:51 am
No new posts CICS VSAM RLS READ akodakka CICS 3 Tue Oct 04, 2016 3:09 pm
No new posts Several errors during building altern... Andi1982 JCL & VSAM 11 Wed Jul 06, 2016 7:39 pm
No new posts Drop building Alternate Index for a p... bhavin.mehta JCL & VSAM 6 Mon Jul 04, 2016 3:47 pm


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