ESDS (for Beginners)


  • ESDS is the short form of Entry Sequential Data Set.
  • In ESDS, records are stored in the same order as how they were loaded into the dataset (entry sequential).
  • Each record is identified by its Relative Byte Address (RBA).
  • The RBA is the starting byte of the record from where the record is saved and can't be changed once set.
  • Inserting a new record always appends immediately after the last record in the ESDS dataset.
  • ESDS allows fixed-length or variable-length records.
  • ESDS dataset only contains the DATA component.

Allowed Accessing Types -


ESDS allows two types of access -

  • Sequential access - While sequential accessing, the records are retrieved in the same order as how they were stored.
  • Direct (or random) access - When a record is loaded or inserted, VSAM returns the record RBA to the application. To retrieve records directly, we should provide the RBA for the record as input.

Deleting a Record?


We can't delete the existing records and can't alter the record length also. If someone says deletion is possible, then it is logical delete. However, updating the record is possible when there is no length change or change in record position.

DEFINE ESDS Syntax -


IDCAMS DEFINE CLUSTER command with NONINDEXED parameter is used to create ESDS dataset.

Syntax - JCL for creating ESDS dataset with minimum required parameters

//JOBCARD
//*------------------------------------------------------------------
//* Definition of ESDS
//*------------------------------------------------------------------
//STEP01  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*   
//SYSOUT   DD SYSOUT=*   
//SYSIN     DD *
    DEFINE CLUSTER 								–
       (NAME(userid.CLUSTER.NAME) 					–
		CYLS(primary secondary)  					–
		VOL(XXXXXX) 								–
		CONTROLINTERVALSIZE(ci-size) 				–
		RECORDSIZE(avg max) 						–
		SHAREOPTIONS(cross-region [cross-region])	–
        NONINDEXED									–
        REUSE) 										–
		DATA (NAME(userid.CLUSTER.NAME.DATA)) 	 	
/*

In the above syntax,

  • The NONINDEXED parameter specifies the file that is creating is ESDS.

Refer IDCAMS DEFINE command for full set of parameters.

Creating Fixed-length ESDS Example -


Requirement - Create ESDS with fixed-length records of size 47 bytes.

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEGJE JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),            
//             NOTIFY=&SYSUID                                           
//************************************************************          
//* DEFINE VSAM FIXED-LENGTH ESDS CLUSTER                               
//************************************************************          
//STEP01   EXEC PGM=IDCAMS                                              
//SYSPRINT DD SYSOUT=*                                                  
//SYSOUT   DD SYSOUT=*                                                  
//SYSIN    DD  *                                                        
  DEFINE CLUSTER(NAME(MATEGJ.TEST.ESDS)  -                              
     RECORDSIZE(47,47)    -                                             
     CYLINDERS(2,1)       -                                             
     CISZ(4096)           -                                             
     VOLUMES(DEVHD4)      -                                             
     NONINDEXED           -                                             
     REUSE     )          -                                             
  DATA(NAME(MATEGJ.TEST.ESDS.DATA))                                     
/*                                                                      
**************************** Bottom of Data ****************************

In the above JCL, MATEGJ is the userid and change them all as required.

Output -

Once the above JCL is submitted, check the MAXCC of the job for any errors. If the MAXCC is 00 or 04, ESDS successfully created.

Create ESDS Output

Verify the ESDS in 3.4 (Dataset List utility) or any File management tools.

Create ESDS Output

Explaining Example -

In the above example,

  • RECORDSIZE(47,47) specifies the record average length is 47, and the maximum size is 47. So the ESDS file we are creating is fixed-length.
  • CYLINDERS(2,1) specifies the primary memory allocation is 2 CYLINDERS, and secondary memory allocation is 1 CYLINDER.
  • CISZ(4096) specifies the control interval size is 4096.
  • VOLUMES(DEVHD4) specifies that allocate the ESDS on volume DEVHD4.
  • NONINDEXED parameter specifies the file is to create ESDS.
  • REUSE specifies the memory can reuse immediately once the file gets deleted.

Creating Variable-length ESDS Example -


Requirement - Create ESDS with variable-length records of average size 47 and maximum size 67 bytes.

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEGJE JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),            
//             NOTIFY=&SYSUID                                           
//************************************************************          
//* DEFINE VSAM VARIABLE-LENGTH ESDS CLUSTER                            
//************************************************************          
//STEP01   EXEC PGM=IDCAMS                                              
//SYSPRINT DD SYSOUT=*                                                  
//SYSOUT   DD SYSOUT=*                                                  
//SYSIN    DD  *                                                        
  DEFINE CLUSTER(NAME(MATEGJ.TEST.VESDS)  -                             
      RECORDSIZE(47,67)    -                                            
      CYLINDERS(2,1)       -                                            
      CISZ(4096)           -                                            
      VOLUMES(DEVHD4)      -                                            
      NONINDEXED           -                                            
      REUSE     )          -                                            
  DATA(NAME(MATEGJ.TEST.VESDS.DATA))                                    
/*                                                                      
**************************** Bottom of Data ****************************

In the above JCL, MATEGJ is the userid and change them all as required.

Output -

Once the above JCL is submitted, check the MAXCC of the job for any errors. If the MAXCC is 00 or 04, ESDS successfully created.

Create ESDS Output

Verify the ESDS in 3.4 (Dataset List utility) or any File management tools.

Create ESDS Output

Explaining Example -

In the above example,

  • RECORDSIZE(47,67) specifies the record average length is 47, and the maximum size is 67. So the ESDS file we are creating is variable-length.
  • CYLINDERS(2,1) specifies the primary memory allocation is 2 CYLINDERS, and secondary memory allocation is 1 CYLINDER.
  • CISZ(4096) specifies the control interval size is 4096.
  • VOLUMES(DEVHD4) specifies that allocate the ESDS on volume DEVHD4.
  • NONINDEXED parameter specifies the file is to create ESDS.
  • REUSE specifies the memory can reuse immediately once the file gets deleted.

Loading Data to ESDS -


Loading data to ESDS can be done in three ways -

  • Using utilities.
  • Using File Management Tools[Covered in tools section in future].
  • Through programmatically[Covered as part of COBOL tutorial ].

Using utilities -


If the records count is more, load the records to a flat file(PS) and copy PS file data to ESDS. IDCAMS utility is used to copy the data from the PS file to ESDS. JCL for the same shown below -

Input - MATEGJ.TEST.DATA

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEGJR JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),            
//             NOTIFY=&SYSUID                                           
//************************************************************          
//* LOADING DATA TO ESDS                                                
//************************************************************          
//STEP01   EXEC PGM=IDCAMS                                              
//SYSPRINT DD   SYSOUT=*                                                
//INPUT    DD   DSNAME=MATEGJ.TEST.DATA,DISP=SHR                        
//OUTPUT   DD   DSNAME=MATEGJ.TEST.ESDS,DISP=SHR                        
//SYSIN    DD   *                                                       
      REPRO    -                                                        
           INFILE(INPUT)   -                                            
           OUTFILE(OUTPUT)                                              
/*                                                                      
**************************** Bottom of Data ****************************

In the above JCL, MATEGJ.TEST.DATA is the flat file and MATEGJ.TEST.ESDS is the ESDS file.

Output -

Once the above JCL is submitted, check the MAXCC of the job for any errors. If the MAXCC is 00 or 04, ESDS successfully loaded with data from PS.

loading ESDS Output

Verify the ESDS in 3.4 (Dataset List utility) or any File management tools.

loading ESDS Output

Explaining Example -

In the above example, all the records from the MATEGJ.TEST.DATA (flat file of length 47) file copied to MATEGJ.TEST.ESDS(ESDS file of length 47) file.

Note! The flat file(PS) and ESDS file should have the same record length (47 in the above example) to load the data successfully.

Delete ESDS Example -


Requirement - Delete ESDS using the IDCAMS utility.

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEGJD JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),            
//             NOTIFY=&SYSUID                                           
//************************************************************          
//* DELETING ESDS                                                       
//************************************************************          
//STEP01   EXEC PGM=IDCAMS                                              
//SYSPRINT DD   SYSOUT=*                                                
//SYSIN    DD   *                                                       
      DELETE 'MATEGJ.TEST.ESDS'                                         
/*                                                                      
**************************** Bottom of Data ****************************

In the above JCL, MATEGJ.TEST.ESDS is the ESDS name that is planned to delete.

Output -

Once the above JCL is submitted, check the MAXCC of the job for any errors. If the MAXCC is 00 or 04, ESDS successfully got deleted.

DELETE ESDS Output

Verify the ESDS in 3.4 (Dataset List utility) or any File management tools if required to double-check.

DELETE ESDS Output

Explaining Example -

In the above example, the MATEGJ.TEST.ESDS (ESDS file) successfully deleted and uncatalogued(space released).

Note! If the file is already deleted and trying to delete the file again, we may receive MAXCC as 08. So, verify the file once before proceeding for delete.