GDGs are group of chronologically related datasets.
Suppose we want to keep track of daily sales of shop.We can create new files everyday, or can run the same job to produce new GDG versions everyday.
So we need to create a model dataset,which is called the GDG Base, and all the new files created by the system will take the properties of the Base version and create new files.
We use IDCAMS utility to build the GDG base.
//STEP1 EXEC PGM=IDCAMS,TIME=4
//SYSDUMP DD SYSOUT=$
//SYSPRINT DD SYSOUT=$
//SYSIN DD *
DEFINE GDG -
Now we are creating the versions of the GDG and lets see what happens.
//STEP2 EXEC PGM=IEFBR14
//MODEL1 DD DSN=TEST.OUTPUT.GDGBASE(+1),
On submitting this job 3 times, we will get something like this
Now if we submit and create one more version, it will be TEST.OUTPUT.GDGBASE.G0004V00
We will see that TEST.OUTPUT.GDGBASE.G0001V00 is no more there in the system. It has been DELETED and UNCATLG ed . Its expcted because we defined it with SCRATCH
The NOEMPTY parameter specifies that when the three (3) generation limit is reached the oldest generation data set will be deleted. The remaining generation data sets will be retained. An EMPTY parameter specifies that when the limit is reached the three (3) current files will be deleted and the process will start again with the new file. The SCRATCH parameter specifies that the oldest generation data set will be uncataloged and deleted when the generation limit is exceeded.
Default is NOEMPTY/NOSCRATH.
specifies that the generation data set's DSCB is to be deleted from the volume's VTOC when the generation data set is uncataloged.
specifies that the generation data set's DSCB is not to be removed from the volume's VTOC when the generation data set is uncataloged.
Other paramters are there but are not so much frequently like
OWNER -> For user identification
TO(DATE) -> Retention Period
FOR(DATE) -> Retention Period
"How do we know the characteristics of a GDG from its name" ???
We use IDCAMS to get its definition.
//STEP001U EXEC PGM=IDCAMS
//SYSUDUMP DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ENTRY('TEST.OUTPUT.GDGBASE') ALL