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

Why Alternate indexes are not supported for VSAM RRDS?


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Mon Nov 28, 2011 3:26 pm
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

Senior Member


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

PostPosted: Tue Nov 29, 2011 12:51 am
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Nov 29, 2011 2:17 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 29, 2011 2:57 am
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

Senior Member


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

PostPosted: Tue Nov 29, 2011 3:02 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 29, 2011 5:10 am
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 29, 2011 1:04 pm
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: 1788
Location: Bloomington, IL

PostPosted: Tue Nov 29, 2011 4:05 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 29, 2011 4:14 pm
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Dec 01, 2011 4:26 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 01, 2011 5:57 pm
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Dec 01, 2011 10:50 pm
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

Moderator Emeritus


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

PostPosted: Thu Dec 01, 2011 11:46 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 02, 2011 5:51 am
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: 2481
Location: Netherlands, Amstelveen

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

Quote:

they still have RIDFs


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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 02, 2011 5:12 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts CVDA value for RRDS VSAM dataset. CICS 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Open VSAM File in IMS DC Region - DFS... IMS DB/DC 0
Search our Forums:

Back to Top