Thursday, October 29, 2015

REUSE option in VSAM and IDCAM. Drawbacks of Reuse.

I have seen the REUSE parameter in the REPRO statement using IDCAMS. Backtracking the purpose of using it, came to know several features of this keyword which i am sharing here.
Some applications might need temporary files, which can be deleted after the program run is over.You may need these files in the form of a KSDS,ESDS or RRDS. Thus VSAM allows to  create a Reusable cluster or files  using this keyword in the definition of the cluster.

Lets see  what happens if we do not use the REUSE parameter ? 
In this case, we can reload the VSAM only once.Only way to reload the data is to DELETE DEFINE the vsam file and repro the data.Should we reload it again, we need to delete/define it again.  In order to remove this repeated  DELETE DEFINE steps, we can define the vsam with REUSE parameter.
Do we remember the term HURBA ? Check the  listcat  section once how we can know about it.
HURBA stands for  --> Highly Used Relative Byte Area.
When we delete define a VSAM, this HURBA remains as zero. It increments as we add records. Ideally this HURBA indicates the offset of the last byte in the data set.
When we use reuse option, this HURBA is reset back to zero. Logically we are deleting all the records thereby.
Thus,the REUSE parameter allows us to reload the vsam as if it were empty.

Although it sounds simple, but there are certain drawbacks for using REUSE parameter.

We know VSAM performance depends on the CI/CA splits. With this resue option, the CI/CA splits remain in place. Over the period of time the performance degrades.

Few points to remember :
1. We cant use REUSE in the repro when the cluset is not defined with REUSE option.
     However we can Alter the VSAM definition to make it resuable.

  //STEPA    EXEC  PGM=IDCAMS
  //SYSPRINT DD    SYSOUT=A
  //SYSIN    DD    *
             ALTER -
                TEST.VSAMDATASET -
                REUSE
2.  Cluster defined with Reuse keyword can not have alternate index defined on it.