RRDS (for Beginners)
Summary
For basic information, go through the RRDS (for Experienced)
- RRDS is a short form of Relative Record Data Set.
- RRDS has both DATA and INDEX components.
- A record is identified by its relative record number (RRN). The first record in the data set is RRN 1, and the second is RRN 2, and so on. The RRN can be changed based on the record position in the file.
RRDS divided into two types based on record length -
- Fixed-length RRDS
- Variable-length RRDS (VRRDS)
Fixed-length RRDS -
- Fixed length RRDS file have the records of fixed length.
- Fixed length RRDS file have only DATA component.
- RRDS has several fixed-length pre-formatted logical-record slots.
- Each slot has a unique Relative Record Number (RRN), varying from 1 to the maximum number of records in the dataset.
- The record is stored and retrieved by using the RRN of the slot. i.e., Every RRN has a dedicated slot. The slot can either contain data or be empty; RRN is permanent for the slot.
- The records are reorganized as specified below for each operation -
- If inserting a record, it places in the empty slot of RRN and no change in the other RRNs position.
- If deleting a record, it deletes from the RNN slot, makes it available for another record insertion, and no change in the other RRNs position.
- If updating a record, there will be no change in records positions.
Variable-length RRDS (VRRDS) -
- VRRDS is like an RRDS, except it contains only variable-length records.
- VRRDS has no slots like RRDS.
- VRRDS has DATA and INDEX components.
- Each record has a unique Relative Record Number (RRN), and records are placed in ascending order of RRN.
RRDS processing types -
RRDS supports three types of processing, and those are -
Access Type | Description |
---|---|
Sequential Access | RRDS sequential access is the same as ESDS sequential access. |
Direct Access | RRDS supports direct accessing a record by supplying the RRN. |
Dynamic Access or Skip Sequential Access |
RRDS supports skip-sequential access by positioning at a record through direct access. |
DEFINE RRDS Syntax -
IDCAMS DEFINE CLUSTER command with NUMBERED parameter is used to create RRDS dataset.
Syntax - JCL for creating fixed-length RRDS dataset.
//JOBCARD
//*------------------------------------------------------------------
//* Definition of fixed-length RRDS
//*------------------------------------------------------------------
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER (NAME(userid.CLUSTER.NAME) –
CYLINDERS(primary secondary) -
VOL(XXXXXX) –
BUFFERSPACE(buffer-space) –
CONTROLINTERVALSIZE(ci-size) –
FREESPACE(primary secondary) –
RECORDSIZE(avg max) –
NUMBERED -
NOREUSE -
OWNER(userid) ) -
DATA (NAME(userid.CLUSTER.NAME.DATA)) -
CATALOG(XXXXXX)
/*
Syntax - JCL for creating variable-length RRDS dataset.
//JOBCARD
//*------------------------------------------------------------------
//* Definition of variable-length RRDS
//*------------------------------------------------------------------
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER (NAME(userid.CLUSTER.NAME) –
CYLINDERS(primary secondary) -
VOL(XXXXXX) –
BUFFERSPACE(buffer-space) –
CONTROLINTERVALSIZE(ci-size) –
FREESPACE(primary secondary) –
RECORDSIZE(avg max) –
NUMBERED -
NOREUSE -
OWNER(userid) ) -
DATA (NAME(userid.CLUSTER.NAME.DATA)) -
INDEX (NAME(userid.CLUSTER.NAME.INDEX)) -
CATALOG(XXXXXX)
/*
In the above syntax,
- The NUMBERED parameter specifies that the file created is RRDS.
Refer IDCAMS DEFINE command for full set of parameters.
Create Fixed-length RRDS Example -
Requirement - Create RRDS with fixed-length records of size 47 bytes.
Code -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEGJR JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//************************************************************
//* DEFINE VSAM FIXED LENGTH RRDS CLUSTER
//************************************************************
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER(NAME(MATEGJ.TEST.RRDS) -
RECORDSIZE(47,47) -
CYLINDERS(2,1) -
VOLUMES(DEVHD4) -
NUMBERED -
REUSE ) -
DATA(NAME(MATEGJ.TEST.RRDS.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, RRDS successfully created.

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

Explaining Example -
In the above example,
- RECORDSIZE(47,47) specifies that the record average length is 47, and the maximum length is 47. So the RRDS 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.
- VOLUMES(DEVHD4) specifies that allocate the RRDS on volume DEVHD4.
- NUMBERED parameter specifies the file is to create RRDS.
- REUSE specifies that the memory can reuse immediately once the file gets deleted.
Create Variable-length RRDS Example -
Requirement - Create RRDS with variable-length records of average size 47 and maximum size 67 bytes.
Code -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEGJR JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//************************************************************
//* DEFINE VSAM VARIABLE LENGTH RRDS CLUSTER
//************************************************************
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER(NAME(MATEGJ.TEST.VRRDS) -
RECORDSIZE(47,67) -
CYLINDERS(2,1) -
VOLUMES(DEVHD4) -
NUMBERED -
REUSE ) -
INDEX(NAME(MATEGJ.TEST.VRRDS.INDEX)) -
DATA(NAME(MATEGJ.TEST.VRRDS.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, RRDS successfully created.

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

Explaining Example -
In the above example,
- RECORDSIZE(47,67) specifies that the record average length is 47, and the maximum length is 67. So the RRDS 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.
- VOLUMES(DEVHD4) specifies that allocate the RRDS on volume DEVHD4.
- NUMBERED parameter specifies the file is to create RRDS.
- REUSE specifies that the memory can reuse immediately once the file gets deleted.
Loading Data to RRDS -
Loading data to RRDS 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 -
IDCAMS utility is used to copy the data from the PS file to RRDS. The JCL is shown below -
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 RRDS FROM PS(FLAT FILE)
//************************************************************
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INPUT DD DSN=MATEGJ.TEST.DATA,DISP=SHR
//OUTPUT DD DSN=MATEGJ.TEST.RRDS,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.RRDS is the RRDS file.
Output -
Once the above JCL is submitted, check the MAXCC of the job for any errors. If the MAXCC is 00 or 04, RRDS successfully loaded with records.

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

Explaining Example -
In the above example, all the records from the MATEGJ.TEST.DATA(flat file of length 47) file copied to MATEGJ.TEST.RRDS(RRDS file of length 47) file.
Delete RRDS Example -
Requirement - Delete RRDS 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 RRDS
//************************************************************
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE 'MATEGJ.TEST.RRDS'
/*
**************************** Bottom of Data ****************************
In the above JCL, MATEGJ.TEST.RRDS is the RRDS 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, RRDS successfully got deleted.

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

Explaining Example -
In the above example, the MATEGJ.TEST.RRDS (RRDS file) successfully deleted and uncatalogued(space released).