ESDS (for Experienced)


  • 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.
  • Once the record is placed in ESDS, the RBA for the specific record is permanent and remains the same until the dataset is deleted.
  • 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.
  • ESDS can be used by IMS, DB2, z/OS, and UNIX.

Access 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. The starting position of sequential access can be from the beginning of the file or the middle of the file. Skip sequential access is not allowed for an ESDS.
  • 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. VSAM allows ESDS datasets to have alternate indexes (AIX); however, the extended ESDS doesn't. AIX can define with a key field in the logical record and is the best option to access randomly instead of accessing an ESDS sequentially by RBA.

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.

To change the record size, use the following steps -

  • Insert the record as a new one at the end of the dataset.
  • Override an existing old record with spaces that makes the record flagged as inactive.

Extended ESDS -


  • A standard RBA is an unsigned 32-bit number. If 32-bit RBA is used, then the standard ESDS cannot contain more than 4 GB data.
  • However, another ESDS supports 64-bit extended relative byte addresses ( XRBA ). If 64-bit XRBA is used, there is no 4 GB data limit. This type of ESDS is called as an "extended addressing ESDS" or an "extended ESDS".
  • CICS supports 64-bit XRBAs and extended ESDS datasets.

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.
  • And also INDEX component is not required to specify. Because ESDS doesn't have an index component.
  • The remaining parameters usage is almost identical for ESDS and KSDS.

Refer IDCAMS DEFINE command for full set of parameters.

Create 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 changes 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.

Create 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 changes 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.

Advantages -


  • Easy and fast creation.
  • A unique index is not required.
  • Have only a DATA component, so it occupies less space when compared to KSDS.
  • Can have alternate index except for extended ESDS.

Disadvantages -


  • Limited updating facilities.
  • Can't delete the record.
  • Can't alter the record length because of using RBA as a key.
  • Access is sequential until RBA is known.

Usage -


  • Applications that have only sequential access can use ESDS.
  • Aging online applications use ESDS for reporting purposes.

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.

How to use ESDS in the COBOL Program?


Fixed-length ESDS files -


Requirement - Define the fixed-length ESDS file in the COBOL program.

Let us assume MATEGJ.TEST.ESDS is the ESDS file with the record length 47, and it is defined like below in the COBOL program.

In Environment Division -

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
	SELECT ESDS-1 ASSIGN to INPUT.
	ORGANIZATION IS SEQUENTIAL.
	ACCESS MODE IS SEQUENTIAL.
	FILE STATUS IS file-status1.

In Data Division -

DATA DIVISION.
FILE SECTION.
FD ESDS-1.
	RECORD CONTAINS 47 CHARACTERS.
	BLOCK CONTAINS 470 CHARACTERS.
	DATA RECORD is ESDS-RECORD-1.
	RECORDING MODE IS F.

01 ESDS-RECORD-1 PIC X(47).

In the above example, ESDS-1 is the file-name used to represent the ESDS file in the COBOL program. INPUT is the DDNAME used to map with the JCL DDNAME specified corresponding to the ESDS file. For example -

//INPUT DD DSN=MATEGJ.TEST.ESDS,DISP=SHR

ESDS-RECORD-1 represents the logical record used to insert the data to a file or read the data from a file.

Variable-length ESDS files -


Requirement - Define the variable-length ESDS file in the COBOL program.

Let us assume MATEGJ.TEST.VESDS is the variable-length ESDS file with rectord length 47 to 67, and it is defined like below in the COBOL program.

In Environment Division -

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
	SELECT ESDS-2 ASSIGN to INPUTV.
	ORGANIZATION IS SEQUENTIAL.
	ACCESS MODE IS SEQUENTIAL.
	FILE STATUS IS file-status2.

In Data Division -

DATA DIVISION.
FILE SECTION.
FD ESDS-2.
	RECORD CONTAINS 47 TO 67 CHARACTERS.
	BLOCK CONTAINS 470 TO 670 CHARACTERS.
	DATA RECORD is ESDS-RECORD-2.
	RECORDING MODE IS V.

01 ESDS-RECORD-2 PIC X(67).

In the above example, ESDS-2 is the file-name used to represent the ESDS file in the COBOL program. INPUT is the DDNAME used to map with the JCL DDNAME specified corresponding to the ESDS file. For example -

//INPUTV DD DSN=MATEGJ.TEST.VESDS,DISP=SHR

ESDS-RECORD-2 represents the logical record used to insert the data to a file or read the data from a file.