DEFINE cluster command.


Defining a VSAM cluster:

Ø  DEFINE CLUSTER is the command that is used to Create ESDS, KSDS and RRDS datasets.

Ø  Note that each of the DEFINE commands has its own () , inside which all other parameters are mentioned.

Ø  Following is the Syntax:
DEFINE CLUSTER
    (NAME(entryname) 
    {CYLINDERS(primary] secondary])  |
        RECORDS(primary[ secondary])  |
        TRACKS(primary[ secondary])}
    VOLUMES(volser[ volser...])
 
    [BUFFERSPACE(size)] 
    [CONTROLINTERVALSIZE(size)]
    [ERASE  |  NOERASE] 
    [FILE(ddname)] 
    [FREESPACE(CI-percent[ CA-percent]|0 0)] 
    [IMBE  NOIMBED
    [INDEXED   NONINDEXE  NUMBERED]
    [KEYS(length offset|64 0)] 
    [MODEL(entryname[/password][ catname[/password]])]
    [RECORDSIZE(average maximum)]
 
    [REPLICATE  |  NOREPLICATE]
    [REUSE  |  NOREUSE]
    [SPEED   RECOVERY
    [TO(date)  |  FOR(days)] 
    [UNIQUE  |  SUBALLOCATION
   
    [DATA 
    ([NAME(entryname)])

    [INDEX
    ([NAME(entryname)])


    [CATALOG(catname[/password])] 

Ø  The three main parameter lists that may be specified are grouped by CLUSTER, DATA, and INDEX.  These lists of parameters apply to the CLUSTER as a whole, the DATA component of the cluster, and the INDEX component of the cluster. 

Ø  The INDEX component is only present when a Key Sequenced cluster is being defined. 
Almost all parameters that may be specified for the CLUSTER can also be specified individually for the DATA and INDEX components. But generally only parameter that is frequently supplied for the DATA and INDEX component is the NAME.
Otherwise AMS will generate a non-intuitive name for that component of the cluster. The data component will be specified by adding .DATA as the suffix and index component will be denoted by adding .INDEX as the suffix to the name of the cluster.
We could use the DATA and  INDEX components to separately specify the parameters for performance considerations where  the INDEX and DATA components of the cluster could be split and placed on separate direct access storage volumes.

Ø  Following is the meaning of the parameters defined.
·        NAME: It’s the name given to the Cluster

·        Space allocation: One of the three space allocation subparameters must be coded to specify the size of the cluster.  Space may be requested in terms of cylinders, tracks, or records.  Both a primary and secondary quantity may be specified for either of the three specification units.  The primary quantity is the amount of space initially allocated to the cluster.  The secondary quantity is the amount of additional space allocated when the available space is completely used and an additional record is added to the cluster.

·        Volume: The VOLUMES parameter specifies one or more direct access storage volumes on which space may be allocated for the cluster.

Above 3 parameters are the ones that will be generally coded on DEFINE statement including for VSAM and catalog.

·        Type of cluster:
INDEXEDà KSDS
NONINDEXEDà ESDS
NUMBERED à RRDS.

·        Record Size:
The RECORDSIZE parameter specifies two things
1)     size of the logical record which can be written to the cluster and
2)     whether the records will be fixed or variable length. 
If the integer values of both average andmaximum are identical, the records which can be written to the cluster will be fixed length and of the size specified by the value. EX: RECORDSIZE ( 65 65) means its Fixed width of 65 length
If the values specified differ, the records written to the cluster may be in varying length, up to the value specified for maximum.
EX: RECORDSIZE(80 160) Means it’s a variable length file with least length of 80 and maximum length of 160.

·        Keys (INDEXED clusters only):
The KEYS parameter specifies the length and position (relative to the beginning of the record, with 0 indicating the first character) of the primary key in the records written to the cluster.
Note that 0 indicates the 1st character.

·        Re-Usable Clusters
The REUSE parameter allows clusters to be defined that may be reset to empty status without deleting and re-defining them.  This is most often used for clusters used as work datasets.

Ø  Following Parameters are optional:
·        Buffer Space
BUFFERSPACE is used to specify the minimum amount of buffer space required to process the dataset.  

·        Control Interval Size
In most cases, the CONTROLINTERVALSIZE parameter should be omitted.  This allows AMS to choose the most efficient value for the dataset.  A control interval can range from 512 to 32,768 bytes in size.

·        Erase
The ERASE parameter specifies that when the cluster is deleted, the space occupied by the cluster should be physically erased by overwriting the space with binary zeros prior to freeing the space for reuse.

·        Free Space (INDEXED clusters only)
The FREESPACE parameter specifies a percentage of space to leave unallocated for future expansion.  If FREESPACE is not specified, control intervals are filled as completely as possible and no space is left for addition of records in the future.

·        Model
The MODEL parameter is used to specify an existing cluster from which the attributes used to define the new cluster should be copied.  When MODEL is used, the only additional parameter that is required is NAME.  If additional parameters are specified with MODEL, they will override attributes copied from the existing cluster.

Points to Note:
FREESPACE and KEYS can be used only with INDEXED dataset.
MODEL can be used to copy characteristics from another Cluster

Example 1 : Creating a KSDS cluster
***************************** Top of Data ******************************
//JOB00002 JOB (XXXX),'ACCESS METHOD',NOTIFY=SYSUID                    
//STEP0001 EXEC PGM=IDCAMS                                             
//SYSPRINT DD   SYSOUT=*                                               
//SYSIN    DD *                                                        
 DELETE SM017R.TEST.VSAM1 CLUSTER PURGE                                
 /* ABOVE DELETES IF THE KSDS EXISTS */                                
 DEFINE CLUSTER(                    -                                  
       NAME (SM017R.TEST.VSAM1)      -                                 
       TRK  (1 1)                    -                                 
       INDEXED                       -                                 
       KEYS (10 0)                   -                                 
       RECORDSIZE (80 80))                                             
                                                                        
 IF LASTCC=0 THEN                    -                                 
     LISTCAT ALL LEVEL(SM017R.TEST.VSAM1)                              
/*                                                                     
**************************** Bottom of Data ****************************
The Above shown example can be used to create the KSDS cluster. Here we provided the Name of the KSDS file, the space allocation .We also mentioned that file is indexed and has fixed with record length of 80.
The Key of the file starts from position 1 to 10 in the file.As we had not mentioned the names of the data and index components it builds automatically with names SM017R.TEST.VSAM1.DATA and SM017R.TEST.VSAM1.INDEX respectively.
From LISTCAT output in SSO we can see that KSDS dataset is created properly.
                                                           
        THE NUMBER OF ENTRIES PROCESSED WAS:               
                  AIX -------------------0                 
                  ALIAS -----------------0                 
                  CLUSTER ---------------0                 
                  DATA ------------------1                 
                  GDG -------------------0                 
                  INDEX -----------------1                 
                  NONVSAM ---------------0                 
                  PAGESPACE -------------0                 
                  PATH ------------------0                 
                  SPACE -----------------0                 
                  USERCATALOG -----------0                 
                  TAPELIBRARY -----------0                 
                  TAPEVOLUME ------------0                 
                  TOTAL -----------------2                 
                                                           
Example 2: Defining data and index component

***************************** Top of Data ******************************
 //JOB00003 JOB (XXXX),'ACCESS METHOD',NOTIFY=SYSUID                    
 //STEP0001 EXEC PGM=IDCAMS                                             
 //SYSPRINT DD   SYSOUT=*                                               
 //SYSIN    DD *                                                         
  DELETE SM017R.TEST.VSAM1 CLUSTER PURGE                                
  /* ABOVE DELETES IF THE KSDS EXISTS */                                
  DEFINE CLUSTER(                    -                                  
        NAME (SM017R.TEST.VSAM1)      -                                 
        TRK  (1 1)                    -                                 
        INDEXED                       -                                 
        KEYS (10 0)                   -                                  
        RECORDSIZE (80 80))           -                                 
    DATA(NAME(SM017R.ABC.DATA))        -                                
    INDEX(NAME(SM017R.ABC.INDEX))                                       
  IF LASTCC=0 THEN                    -                                 
      LISTCAT ALL LEVEL(SM017R.TEST.VSAM1)                              
 /*                                                                     
 **************************** Bottom of Data ****************************

We can use the above script to create DATA and INDEX files with User defined Files.

Example 3 : Creating an ESDS file
***************************** Top of Data ******************************
//JOB00004 JOB (XXXX),'ACCESS METHOD',NOTIFY=SYSUID                     
//STEP0001 EXEC PGM=IDCAMS                                             
//SYSPRINT DD   SYSOUT=*                                               
//SYSIN    DD *                                                        
 DELETE SM017R.TEST.VSAM1 CLUSTER PURGE                                
 /* ABOVE DELETES IF THE KSDS EXISTS */                                
 DEFINE CLUSTER(                    -                                  
       NAME (SM017R.TEST.VSAM1)      -                                  
       TRK  (1 1)                    -                                                         
       NONINDEXED                    -                                 
       RECORDSIZE (80 80))                                              
 IF LASTCC=0 THEN                    -                                 
     LISTCAT ALL LEVEL(SM017R.TEST.VSAM1)                              
/*                                                                     
**************************** Bottom of Data ****************************

ESDS contains only the data part. Thus above creates DATA part with name SM017R.TEST.VSAM1.DATA.
Also we don’t code KEYS as it is used only for the INDEXED files.
Below is the Listing:
-------------------------------------------------------------------------------
         SM017R.TEST.VSAM1                                              *VSAM*
         SM017R.TEST.VSAM1.DATA                                         PAP070
***************************** End of Data Set list ****************************

Example of Creating RRDS:
***************************** Top of Data ******************************
//JOB00005 JOB (XXXX),'ACCESS METHOD',NOTIFY=SYSUID                    
//STEP0001 EXEC PGM=IDCAMS                                              
//SYSPRINT DD   SYSOUT=*                                               
//SYSIN    DD *                                                        
 DELETE SM017R.TEST.VSAM1 CLUSTER PURGE                                 
 /* ABOVE DELETES IF THE KSDS EXISTS */                                
 DEFINE CLUSTER(                    -                                  
       NAME (SM017R.TEST.VSAM1)      -                                 
       TRK  (1 1)                    -                                 
       NUMBERED                      -                                 
       RECORDSIZE (80 80))                                             
 IF LASTCC=0 THEN                    -                                 
     LISTCAT ALL LEVEL(SM017R.TEST.VSAM1)                              
/*                                                                     
**************************** Bottom of Data ****************************

No comments:

Post a Comment