ESDS VSAM dataset and alternate INDEX.

This Forum is for the guests or the users who are not registered on this board. This part allows guests to post in.
Previous topicNext topic

Topic Author
ESDSIndex

ESDS VSAM dataset and alternate INDEX.

Post by ESDSIndex » Sun Dec 06, 2015 5:28 pm

We can create an Alternate Index of a ESDS file that's what I have read (though I don't know how to create one. If someone knows and can share a method, it will be great). Confusing part is for creating an Alternate Index we require a Primary key and an Alternate key but ESDS file does not have a Key then how and why it allows an Alternate INDEX? Please help I am confused with the concept. :unknown:



User avatar

Akatsukami
Global Moderator
Global Moderator
Posts: 119
Joined: Tue Oct 20, 2015 3:20 am
Location: Bloomington, IL

Re: ESDS VSAM dataset and alternate INDEX.

Post by Akatsukami » Sun Dec 06, 2015 7:14 pm

The alternate keys for an ESDS do not relate to primary keys (which you correctly state do not exist for ESDS) but to RBAs. You may benefit from reading VSAM Demystified.


"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli


enrico-sorichetti
Global Moderator
Global Moderator
Posts: 892
Joined: Wed Sep 11, 2013 3:57 pm

Re: ESDS VSAM dataset and alternate INDEX.

Post by enrico-sorichetti » Sun Dec 06, 2015 7:19 pm

Confusing part is for creating an Alternate Index we require a Primary key
NO

here are two JCLs and the relative output to show how it works

the first JCL
defines an ESDS cluster
loads some data into it
prints the ESDS
defines the AIX
build the AIX
defines the PATH
prints the PATH ( the records are ordered on the alternate key

the second JCL
prints the AIX to show that each record has the rba of the base
(to demonstrate the logic to somebody unable to understand it by himself)

first JCL

Code: Select all

//ENRICO@A JOB (H001),'ZESDS1',NOTIFY=ENRICO, 
//             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1) 
//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//* 
//AMS      EXEC PGM=IDCAMS 
//SYSPRINT   DD SYSOUT=* 
//ESDSDATA   DD * 
9999999999 
7777777777 
5555555555 
3333333333 
1111111111 
8888888888 
6666666666 
4444444444 
2222222222 
0000000000 
//* 
//SYSIN      DD * 
  DELETE (ENRICO.MF.ESDS.CL) CLUSTER PURGE 
  SET LASTCC=0 
  SET MAXCC=0 

  DEFINE CLUSTER( - 
                NAME(ENRICO.MF.ESDS.CL) - 
                NONINDEXED SHR(2 3) CYL(2 2) VOL(xxxxxx) ) - 
            DATA(    - 
                RECSZ(80 80) CISZ(4096) FREESPACE(0 0) ) 

  IF MAXCC  = 0 THEN - 
     REPRO INFILE(ESDSDATA) OUTDATASET(ENRICO.MF.ESDS.CL) 

  IF MAXCC  = 0 THEN - 
     PRINT INDATASET(ENRICO.MF.ESDS.CL) 

  IF MAXCC  = 0 THEN - 
     DO 
        DEFINE   AIX( - 
                    NAME(ENRICO.MF.ESDS.AIX) - 
                    RELATE(ENRICO.MF.ESDS.CL) - 
                    KEYS(10 0) UNIQUEKEY - 
                    SHR(2 3) CYL(2 2) VOL(xxxxxx) ) - 
                DATA(    - 
                    RECSZ(10 2048) CISZ(4096) FREESPACE(0 0) ) 
     END 

  IF MAXCC  = 0 THEN - 
     DO 
        BLDINDEX  INDATASET(ENRICO.MF.ESDS.CL) - 
                 OUTDATASET(ENRICO.MF.ESDS.AIX) 
     END 

  IF MAXCC  = 0 THEN - 
     DO 
        DEFINE PATH( - 
                   NAME(ENRICO.MF.ESDS.PATH) - 
                   PATHENTRY(ENRICO.MF.ESDS.AIX) ) 
     END 

  IF MAXCC  = 0 THEN - 
     PRINT INDATASET(ENRICO.MF.ESDS.PATH) 
/*
//

first output

Code: Select all

IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 

DELETE (ENRICO.MF.ESDS.CL) CLUSTER PURGE 
IDC0550I ENTRY (D) ENRICO.MF.ESDS.AIX.DATA DELETED 
IDC0550I ENTRY (I) ENRICO.MF.ESDS.AIX.INDEX DELETED 
IDC0550I ENTRY (G) ENRICO.MF.ESDS.AIX DELETED 
IDC0550I ENTRY (D) ENRICO.MF.ESDS.CL.DATA DELETED 
IDC0550I ENTRY (C) ENRICO.MF.ESDS.CL DELETED 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 

SET LASTCC=0 

SET MAXCC=0 


DEFINE CLUSTER( - 
NAME(ENRICO.MF.ESDS.CL) - 
NONINDEXED SHR(2 3) CYL(2 2) VOL(xxxxxx) ) - 
DATA(    - 
RECSZ(80 80) CISZ(4096) FREESPACE(0 0) ) 
IDC0508I DATA ALLOCATION STATUS FOR VOLUME xxxxxx IS 0 
IDC0512I NAME GENERATED-(D) ENRICO.MF.ESDS.CL.DATA 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 


IF MAXCC  = 0 THEN - 
REPRO INFILE(ESDSDATA) OUTDATASET(ENRICO.MF.ESDS.CL) 
IDC0005I NUMBER OF RECORDS PROCESSED WAS 10 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 


IF MAXCC  = 0 THEN - 
PRINT INDATASET(ENRICO.MF.ESDS.CL) 
IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 
LISTING OF DATA SET -ENRICO.MF.ESDS.CL 
RBA OF RECORD -                0 
000000  F9F9F9F9 F9F9F9F9 F9F94040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -               80 
000000  F7F7F7F7 F7F7F7F7 F7F74040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -              160 
000000  F5F5F5F5 F5F5F5F5 F5F54040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -              240 
000000  F3F3F3F3 F3F3F3F3 F3F34040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -              320 
000000  F1F1F1F1 F1F1F1F1 F1F14040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -              400 
000000  F8F8F8F8 F8F8F8F8 F8F84040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -              480 
000000  F6F6F6F6 F6F6F6F6 F6F64040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -              560 
000000  F4F4F4F4 F4F4F4F4 F4F44040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 
LISTING OF DATA SET -ENRICO.MF.ESDS.CL 
RBA OF RECORD -              640 
000000  F2F2F2F2 F2F2F2F2 F2F24040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

RBA OF RECORD -              720 
000000  F0F0F0F0 F0F0F0F0 F0F04040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

IDC0005I NUMBER OF RECORDS PROCESSED WAS 10 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 
IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 


IF MAXCC  = 0 THEN - 
DO 

DEFINE AIX( - 
NAME(ENRICO.MF.ESDS.AIX) - 
RELATE(ENRICO.MF.ESDS.CL) - 
KEYS(10 0) UNIQUEKEY - 
SHR(2 3) CYL(2 2) VOL(xxxxxx) ) - 
DATA(    - 
RECSZ(10 2048) CISZ(4096) FREESPACE(0 0) ) 
IDC0508I DATA ALLOCATION STATUS FOR VOLUME xxxxxx IS 0 
IDC0509I INDEX ALLOCATION STATUS FOR VOLUME xxxxxx IS 0 
IDC0512I NAME GENERATED-(D) ENRICO.MF.ESDS.AIX.DATA 
IDC0512I NAME GENERATED-(I) ENRICO.MF.ESDS.AIX.INDEX 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 

END 


IF MAXCC  = 0 THEN - 
DO 

BLDINDEX INDATASET(ENRICO.MF.ESDS.CL) - 
OUTDATASET(ENRICO.MF.ESDS.AIX) 
IDC31802I LOAD OF MODULE 'ICEBLDX' WAS UNSUCCESSFUL - ABEND CODE IS 
IDC31802I X'0306'  , REASON CODE IS X'A6B6' 
IDC0657I REQUIRED SORT PRODUCT FUNCTIONS UNAVAILABLE 
IDC0652I ENRICO.MF.ESDS.AIX SUCCESSFULLY BUILT 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 

END 


IF MAXCC  = 0 THEN - 
DO 

DEFINE PATH( - 
NAME(ENRICO.MF.ESDS.PATH) - 
PATHENTRY(ENRICO.MF.ESDS.AIX) ) 
IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 

END 


IF MAXCC  = 0 THEN - 
PRINT INDATASET(ENRICO.MF.ESDS.PATH) 

IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 
LISTING OF DATA SET -ENRICO.MF.ESDS.PATH 
KEY OF RECORD - F0F0F0F0F0F0F0F0F0F0 
000000  F0F0F0F0 F0F0F0F0 F0F04040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F1F1F1F1F1F1F1F1F1F1 
000000  F1F1F1F1 F1F1F1F1 F1F14040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F2F2F2F2F2F2F2F2F2F2 
000000  F2F2F2F2 F2F2F2F2 F2F24040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F3F3F3F3F3F3F3F3F3F3 
000000  F3F3F3F3 F3F3F3F3 F3F34040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F4F4F4F4F4F4F4F4F4F4 
000000  F4F4F4F4 F4F4F4F4 F4F44040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F5F5F5F5F5F5F5F5F5F5 
000000  F5F5F5F5 F5F5F5F5 F5F54040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F6F6F6F6F6F6F6F6F6F6 
000000  F6F6F6F6 F6F6F6F6 F6F64040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F7F7F7F7F7F7F7F7F7F7 
000000  F7F7F7F7 F7F7F7F7 F7F74040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 
LISTING OF DATA SET -ENRICO.MF.ESDS.PATH 
KEY OF RECORD - F8F8F8F8F8F8F8F8F8F8 
000000  F8F8F8F8 F8F8F8F8 F8F84040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

KEY OF RECORD - F9F9F9F9F9F9F9F9F9F9 
000000  F9F9F9F9 F9F9F9F9 F9F94040 40404040   40404040 40404040 40404040 4040404 
000020  40404040 40404040 40404040 40404040   40404040 40404040 40404040 4040404 
000040  40404040 40404040 40404040 40404040 

IDC0005I NUMBER OF RECORDS PROCESSED WAS 10 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 
IDCAMS  SYSTEM SERVICES                                           TIME: 13:11:21 


IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0 
second JCL

Code: Select all

//ENRICO@A JOB (H001),'ZESDS2',NOTIFY=ENRICO, 
//             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1) 
//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//* 
//AMS      EXEC PGM=IDCAMS 
//SYSPRINT   DD SYSOUT=* 
//SYSIN      DD * 
  PRINT INDATASET(ENRICO.MF.ESDS.AIX) 
//

second output

Code: Select all

IDCAMS  SYSTEM SERVICES                                           TIME: 13:48:59 

PRINT INDATASET(ENRICO.MF.ESDS.AIX) 
IDCAMS  SYSTEM SERVICES                                           TIME: 13:48:59 
LISTING OF DATA SET -ENRICO.MF.ESDS.AIX 
KEY OF RECORD - F0F0F0F0F0F0F0F0F0F0 
000000  00040001 0AF0F0F0 F0F0F0F0 F0F0F000   0002D0 

KEY OF RECORD - F1F1F1F1F1F1F1F1F1F1 
000000  00040001 0AF1F1F1 F1F1F1F1 F1F1F100   000140 

KEY OF RECORD - F2F2F2F2F2F2F2F2F2F2 
000000  00040001 0AF2F2F2 F2F2F2F2 F2F2F200   000280 

KEY OF RECORD - F3F3F3F3F3F3F3F3F3F3 
000000  00040001 0AF3F3F3 F3F3F3F3 F3F3F300   0000F0 

KEY OF RECORD - F4F4F4F4F4F4F4F4F4F4 
000000  00040001 0AF4F4F4 F4F4F4F4 F4F4F400   000230 


KEY OF RECORD - F5F5F5F5F5F5F5F5F5F5 
000000  00040001 0AF5F5F5 F5F5F5F5 F5F5F500   0000A0 

KEY OF RECORD - F6F6F6F6F6F6F6F6F6F6 
000000  00040001 0AF6F6F6 F6F6F6F6 F6F6F600   0001E0 

KEY OF RECORD - F7F7F7F7F7F7F7F7F7F7 
000000  00040001 0AF7F7F7 F7F7F7F7 F7F7F700   000050 

KEY OF RECORD - F8F8F8F8F8F8F8F8F8F8 
000000  00040001 0AF8F8F8 F8F8F8F8 F8F8F800   000190 

KEY OF RECORD - F9F9F9F9F9F9F9F9F9F9 
000000  00040001 0AF9F9F9 F9F9F9F9 F9F9F900   000000 

IDC0005I NUMBER OF RECORDS PROCESSED WAS 10 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0 
IDCAMS  SYSTEM SERVICES                                           TIME: 13:48:59 


IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0 


cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)


Topic Author
ESDSIndex

Re: ESDS VSAM dataset and alternate INDEX.

Post by ESDSIndex » Tue Dec 08, 2015 7:19 pm

Thank you. Did not know it can be done. And the explanation is quite exhaustive.

But what are the practical usage of alternate INDEX in ESDS?

Can this concept mimic the functionality of KSDS then?



User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: ESDS VSAM dataset and alternate INDEX.

Post by Robert Sample » Wed Dec 09, 2015 9:28 am

But what are the practical usage of alternate INDEX in ESDS?

Can this concept mimic the functionality of KSDS then?
It could be used, for example, if name and address are being written to the ESDS in fixed positions to index the zip code for retrieval by location instead of however they were entered (or, for that matter, to index the name -- or account number -- or whatever -- for retrieval in a different sequence than how they were entered). And yes it mimics a KSDS to some degree, but there are significant differences (such as updating the data).




Topic Author
ESDSIndex

Re: ESDS VSAM dataset and alternate INDEX.

Post by ESDSIndex » Wed Dec 09, 2015 3:01 pm

Robert Sample wrote:
But what are the practical usage of alternate INDEX in ESDS?

Can this concept mimic the functionality of KSDS then?
It could be used, for example, if name and address are being written to the ESDS in fixed positions to index the zip code for retrieval by location instead of however they were entered (or, for that matter, to index the name -- or account number -- or whatever -- for retrieval in a different sequence than how they were entered). And yes it mimics a KSDS to some degree, but there are significant differences (such as updating the data).
But that is what we can do with the KSDS also then why to go through all the pain of creating an alternate INDEX for ESDS. It looks like more lengthy process than KSDS as per enrico-sorichetti's post.
And yes it mimics a KSDS to some degree, but there are significant differences (such as updating the data).
In KSDS we use DELETE which we can not use in ESDS, apart from this will there be any other difference? Please share what you feel.



User avatar

Akatsukami
Global Moderator
Global Moderator
Posts: 119
Joined: Tue Oct 20, 2015 3:20 am
Location: Bloomington, IL

Re: ESDS VSAM dataset and alternate INDEX.

Post by Akatsukami » Wed Dec 09, 2015 5:22 pm

ESDSIndex wrote:
Robert Sample wrote:
But what are the practical usage of alternate INDEX in ESDS?

Can this concept mimic the functionality of KSDS then?
It could be used, for example, if name and address are being written to the ESDS in fixed positions to index the zip code for retrieval by location instead of however they were entered (or, for that matter, to index the name -- or account number -- or whatever -- for retrieval in a different sequence than how they were entered). And yes it mimics a KSDS to some degree, but there are significant differences (such as updating the data).
But that is what we can do with the KSDS also then why to go through all the pain of creating an alternate INDEX for ESDS. It looks like more lengthy process than KSDS as per enrico-sorichetti's post.
Remember that the primary index of a KSDS must be unique. If there is no unique, contiguous key, then an ESDS with an alternate index must be used.


"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli


nicc
Global Moderator
Global Moderator
Posts: 597
Joined: Wed Apr 23, 2014 8:45 pm

Re: ESDS VSAM dataset and alternate INDEX.

Post by nicc » Wed Dec 09, 2015 7:49 pm

Perhaps you shuld read the "VSAM Demystified" red book.


Regards
Nic

User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: ESDS VSAM dataset and alternate INDEX.

Post by Robert Sample » Thu Dec 10, 2015 5:48 am

I strongly second the recommendation to read VSAM Demystified -- it talks about VSAM in great detail. The main reasons to use KSDS or ESDS will depend upon the application -- is there a unique key for each record? If not, ESDS is the only choice. KSDS is more suited for CICS (online) applications and ESDS is more suited for batch applications (where many records may be entered as a batch). There are times when either could be used and then intangible factors play a role -- experience in the organization with KSDS or ESDS, for example.



Previous topicNext topic

Return to “You are a Guest.”