ESDS is the short form of Entry Sequential Data Set. In ESDS, records are stored in the same order as to how they were first loaded into the data set(sequentially).

Each record is identified by its Relative Byte Address (RBA). Once the record is placed in ESDS, the RBA for the specific record is permanent and remains the same until the data set is deleted. Inserting a new record always appends immediately after the last record in the ESDS dataset.

ESDS records can be fixed-length or variable-length. ESDS dataset only contains data components and no index 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 to how they were stored.
    The starting position of sequential access can be from the beginning of the file or the middle of the file.
    To start sequential access from the middle of the file, RBA positioning is mandatory before starting the sequential access. Sequential forward or backward read or browse is possible using RBA.
    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 a search argument.
    VSAM allows ESDS data sets 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.
    BLDINDEX command builds the alternate index record by extracting key values and record RBAs. Define path is mandatory before accessing the ESDS with an alternate index. AIX is now used as a key for the ESDS dataset to access it randomly.

Deleting Record?

We can't delete the existing records and can't alter the record length as well. 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 data set.
  • Override an existing old record 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, there is a different ESDS that supports 64-bit extended relative byte addresses ( XRBA ). If 64-bit XRBA is used, then 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 data sets.

DEFINE ESDS -

ESDS data set can be created using the NONINDEXED parameter in the IDCAMS DEFINE CLUSTER command.

Syntax -

JCL syntax for creating ESDS dataset with minimum parameters -

//JOB CARD
//*------------------------------------------------------------------
//* 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 not required to specify because ESDS doesn't have an index.
  • Most of the remaining parameters usage is almost identical for ESDS or KSDS. Note that the values in the parameter might change.

Create Fixed-length ESDS JCL -

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

Code -

Create ESDS JCL
----+----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 length 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.
Note! In the above example, the ESDS file was created with minimum parameters. Add the additional parameters based on the requirements. Refer total parameters description in Define Cluster topic.

Create Variable-length ESDS JCL -

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

Code -

Create ESDS JCL
----+----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 length 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 occupies less space when compared to KSDS.
  • Can have alternate index except for extended ESDS.

Disadvantages -

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

Usage -

  • Applications that requires only sequential access.
  • Online applications that use an existing entry-sequenced data set.

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's data to ESDS. To do that, IDCAMS utility used like below -

Code -

Loading ESDS
----+----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 -

Requirement - Delete ESDS using the IDCAMS utility.

Code -

Delete ESDS
----+----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.