Alternate Index and ESDS.
Alternate Index and ESDS.
Hi
Mostly I've worked with KSDS and AIX, however, I came to kwno that we can create AIX on ESDS also. I'm confused ESDS does not have any INDEX then how it supports AIX?
Thanks
Mostly I've worked with KSDS and AIX, however, I came to kwno that we can create AIX on ESDS also. I'm confused ESDS does not have any INDEX then how it supports AIX?
Thanks
- Robert Sample
- Global Moderator
- Posts: 1900
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Alternate Index and ESDS.
Physically, an alternate index is a complete different pair of files than the base cluster. There is no requirement to have an index before you can have an alternate index. I've never used an ESDS with an alternate index, so I'm not sure of the advantages.
-
- Former Team Member
- Posts: 62
- Joined: Wed Aug 07, 2013 6:43 pm
Re: Alternate Index and ESDS.
Possibly to provide the ability to directly access info rather than having to find it serially.
For example - read all info for a particular account or department or whatever.
For example - read all info for a particular account or department or whatever.
Hope this helps,
d
d
-
- Former Team Member
- Posts: 62
- Joined: Wed Aug 07, 2013 6:43 pm
- Anuj Dhawan
- Founder
- Posts: 2816
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Alternate Index and ESDS.
I've an odd habit to take people to their past since the time I happened to be in U.S. during Halloween...
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
- Anuj Dhawan
- Founder
- Posts: 2816
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Alternate Index and ESDS.
And I'm sure, you'll not be "this" for so long...
And yes, Welcome to the Forums, it's nice to see you here!
Regards,
And yes, Welcome to the Forums, it's nice to see you here!
Regards,
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Re: Alternate Index and ESDS.
Here is a complete example (code, JCL and data) using an Alternate Index with ESDS. A fixed-length ESDS base cluster is created, then loaded with 80-byte records having an 8-byte "key" (sequence number) in position 1, then an alternate index is built, keyed on that sequence number and pointing to the corresponding ESDS RBA. You can then read the ESDS directly, or use the Path to read exactly the same records, just as if it were a KSDS:
Here is the sample COBOL code:
And the JCL:
http://www.jaymoseley.com/hercules/vstutor/vstutor.htm - Not having much experience with Alternate Indices, I found the section of Jay Moseley's VSAM Tutorial on the subject (near the bottom) to be very helpful. The trickiest part for me was understanding the Record Size for the Alternate Index. With unique keys (as in this example) the AIX records are fixed length. The record size of 17 (for this example) was then calculated as follows (a+b+c):
(a) 5 bytes for control information
(b) Key length (8 bytes in this case)
(c) RBA length (4 bytes)
Code: Select all
// EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER (NAME(VSAM.ESDS) RECSZ (80 80) TRK (1) NONINDEXED)
REPRO INFILE (INFILE) OUTDATASET (VSAM.ESDS)
DEFINE AIX (NAME (VSAM.RBAKEYS) RELATE (VSAM.ESDS) KEYS (8 0) -
RECSZ (17 17) TRK (1) UNIQUEKEY UPGRADE)
BLDINDEX INDATASET (VSAM.ESDS) OUTDATASET (VSAM.RBAKEYS)
DEFINE PATH (NAME (VSAM.KSDS) PATHENTRY (VSAM.RBAKEYS))
/*
//INFILE DD *
00000100 THIS IS THE FIRST RECORD
00000200 THIS IS THE SECOND RECORD
00000300 THIS IS THE THIRD RECORD
etc.
/*
Code: Select all
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT KSDS ASSIGN KSDS
ORGANIZATION INDEXED RECORD KEY IS RECORD-KEY.
SELECT ESDS ASSIGN AS-ESDS
ORGANIZATION SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD KSDS.
01 KSDS-RECORD.
05 RECORD-KEY PIC X(8).
05 FILLER PIC X(72).
FD ESDS.
01 ESDS-RECORD PIC X(80).
WORKING-STORAGE SECTION.
01 FILLER PIC X.
88 NOT-EOF VALUE 'N'.
88 EOF VALUE 'Y'.
PROCEDURE DIVISION.
OPEN INPUT ESDS SET NOT-EOF TO TRUE
PERFORM UNTIL EOF READ ESDS
AT END SET EOF TO TRUE CLOSE ESDS
NOT AT END DISPLAY ESDS-RECORD END-READ END-PERFORM
CLOSE ESDS
OPEN INPUT KSDS SET NOT-EOF TO TRUE
PERFORM UNTIL EOF READ KSDS
AT END SET EOF TO TRUE CLOSE KSDS
NOT AT END DISPLAY KSDS-RECORD END-READ END-PERFORM
CLOSE ESDS
GOBACK.
Code: Select all
// EXEC PGM=SAMPLE
//SYSOUT DD SYSOUT=*
//ESDS DD DISP=SHR,DSN=VSAM.ESDS <- Base Cluster
//KSDS DD DISP=SHR,DSN=VSAM.KSDS <- Path (to the RBAKEYS Alt Index)
(a) 5 bytes for control information
(b) Key length (8 bytes in this case)
(c) RBA length (4 bytes)
- Anuj Dhawan
- Founder
- Posts: 2816
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Alternate Index and ESDS.
Hi ApexNC,
Welcome to the Forum and Thanks for posting in the detailed explanation, appreciate it.
Request you to please use BBcode Tags by enclosing the "your code" inside the
Welcome to the Forum and Thanks for posting in the detailed explanation, appreciate it.
Request you to please use BBcode Tags by enclosing the "your code" inside the
Code: Select all
Tags, like this: (// Please remove the space after code ]):
[quote][code ]
// your code
[/code ] [/quote]
I've edited your post to add the Code Tags... :). Hope it looks fine, the way you wanted to convey it.
Regards,
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Re: Alternate Index and ESDS.
Thanks, looks great! I should mention that this is a copy of something I posted to LinkedIn, which is the reason for the leading "_" characters. LinkedIn removes leading spaces so you lose all indentation without them. If this site preserves leading spaces, those could be removed.
- Anuj Dhawan
- Founder
- Posts: 2816
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Alternate Index and ESDS.
Have done the editing, took a bit but I think it looks neat now.ApexNC wrote:this is a copy of something I posted to LinkedIn, which is the reason for the leading "_" characters. LinkedIn removes leading spaces so you lose all indentation without them. If this site preserves leading spaces, those could be removed.
Thanks,
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Re: Alternate Index and ESDS.
Thanks ApexNC and Enrico - this is a great help and gives me a direction.
Much appreciate your inputs...
Much appreciate your inputs...
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute