ESDS
- 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. 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 - 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.
- Direct (or random) access - When a record is loaded or inserted, VSAM returns the record RBA. We need to use the RBA as an input to retrieve the record directly.
Managing 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 (over writing with SPACES).
- However, updating the record is possible when there is no length change or change in record position.
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.
- ESDS also 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.
IDCAMS DEFINE CLUSTER command with NONINDEXED parameter is used to create ESDS dataset. INDEX component is ignored because ESDS doesn't have an index component.
Syntax - JCL for creating ESDS dataset with minimum required parameters
//job-card
//*
//STEP01 EXEC PGM=IDCAMS
//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))
/*
Refer IDCAMS DEFINE command for full set of parameters.
Fixed-length RRDS -
Create Fixed-length ESDS Example -
Scenario - Create ESDS with fixed-length records of size 47 bytes.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP01 EXEC PGM=IDCAMS
//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))
/*
...
How to use Fixed-length ESDS in the COBOL Program?
Scenario - 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 in the COBOL program as shown below -
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 -
Create Variable-length ESDS Example -
Scenario - Create ESDS with variable-length records of average size 47 and maximum size 67 bytes.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP01 EXEC PGM=IDCAMS
//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))
/*
...
How to use Vixed-length ESDS in the COBOL Program?
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.
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
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//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)
/*
...
In the above JCL, MATEGJ.TEST.DATA is the flat file and MATEGJ.TEST.ESDS is the ESDS file.
Delete ESDS Example -
Scenario - Delete ESDS using the IDCAMS utility.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE 'MATEGJ.TEST.ESDS'
/*
...
In the above JCL, MATEGJ.TEST.ESDS is the ESDS name that is planned to delete.
Advantages -
- Easy and fast creation.
- A unique index is not required so no additional space is needed.
- 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.