VSAM - RRDS


Advertisements


RRDS is known as Relative Record Data Set. RRDS cluster is similar to an ESDS cluster. The only difference is that RRDS records are accessed by Relative Record Number (RRN), we must code NUMBERED inside the DEFINE CLUSTER command. Following are the key features of RRDS −

  • A Relative record dataset has records that are identified by the Relative Record Number (RRN), which is the sequence number relative to the first record.

  • RRDS allows access of records by number like record 1, record 2, and so on. This provides random access and assumes the application program has a way to get the desired record numbers.

  • The records in an RRDS dataset can be accessed sequentially, in relative record number order, or directly, by supplying the relative record number of the desired record.

  • The records in a RRDS dataset are stored in fixed length slots. Each record is referenced by the number of its slot, number can vary from 1 to the maximum number of records in the dataset.

  • Records in a RRDS can be written by inserting new record into an empty slot.

  • Records can be deleted from an RRDS cluster, thereby leaving an empty slot.

  • Applications which use fixed-length records or a record number with contextual meaning that can use RRDS datasets.

  • RRDS can be used in COBOL programs like any other file. We will specify the file name in JCL and we can use the KSDS file for processing inside program. In COBOL program specify file organization as RELATIVE and you can use any access mode (Sequential, Random or Dynamic) with RRDS dataset.

RRDS File Structure

Space is divided into fixed length slots in RRDS file structure. A slot can be either completely vacant or completely full. Thus, new records can be added to empty slots and existing records can be deleted from slots which are filled. We can access any record directly by giving Relative Record Number. Following example shows the basic structure of data file −

Data Component

Relative Record Number Record Field 1 Record Field 2
1 Tutorial Point
2 Mohtashim M.
3 Nishant Malik

Defining RRDS Cluster

The following syntax shows which parameters we can use while creating RRDS cluster.

The parameter description remains the same as mentioned in VSAM - Cluster module.

DEFINE CLUSTER (NAME(rrds-file-name)     -
BLOCKS(number)                           -
VOLUMES(volume-serial)                   -
NUMBERED                                 -
RECSZ(average maximum)                   -
[FREESPACE(CI-Percentage,CA-Percentage)] -
CISZ(number)                             -
[READPW(password)]                       -
[FOR(days)|TO(date)]                     -
[UPDATEPW(password)]                     -
[REUSE / NOREUSE])                       -
DATA                                     -
   (NAME(rrds-file-name.data))           

Example

Following example shows how to create an RRDS cluster in JCL using IDCAMS utility −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1  EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN    DD  *
   DEFINE CLUSTER (NAME(MY.VSAM.RRDSFILE)  -
   NUMBERED                                -
   RECSZ(80 80)                            -
   TRACKS(1,1)                             -
   REUSE                                   - 
   FREESPACE(3 3) )                        -
   DATA (NAME(MY.VSAM.RRDSFILE.DATA))      
/*

If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will create MY.VSAM.RRDSFILE VSAM file.

Deleting RRDS Cluster

RRDS cluster is deleted using IDCAMS utility. DELETE command removes the entry of the VSAM cluster from the catalog and optionally removes the file, thereby freeing up the space occupied by the object.

DELETE data-set-name CLUSTER  
[ERASE / NOERASE] 
[FORCE / NOFORCE] 
[PURGE / NOPURGE] 
[SCRATCH / NOSCRATCH]

Above syntax shows which parameters we can use while deleting RRDS cluster. The parameter description remains the same as mentioned in VSAM - Cluster module.

Example

Following example shows how to delete an RRDS cluster in JCL using IDCAMS utility −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEPNAME EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN    DD  *
   DELETE MY.VSAM.RRDSFILE CLUSTER
/*

If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will delete MY.VSAM.RRDSFILE VSAM Cluster.



Advertisements
E-Books Store