What is a GDG?
GDG- It is the acronynm for Generation Data Group. GDG is a group of chronologically related datasets. The individual generation of datasets within a GDG is called generation data set (GDS). These GDS have sequential generations as the absolute names. These can also be referred by their relative names.
GDG(0)- Refers to the current generation of GDG
GDG(-1)- Refers to the previous generation of GDG
GDG(+1)- Refers to the next generation of GDG
Example:- my.gdg.name.GnnnVnn
Where
        my.gdg.name is Group name or the GDG base name
        Gnnnn   –          Absolute generation number ( 0000 to 9999 )
        Vnn       –          Version of that generation. (00 to 99)
How to define a GDG base?
A GDG base can be defined by IDCAMS utility.
Example:
           //DEFINE         EXEC          PGM=IDCAMS
           //SYSPRINT  DD     SYSOUT=A
           //SYSIN         DD *
                       DEFINE GDG (NAME(my.gdg.name) SCRATCH-
                       NOEMPTY-
                       LIMIT(30))
           /*
The various parameters used for defining the GDG are as below
Name:- Name of the GDG to be created.
Limit(n):-Maximum number of generations that can exist at a time.
Empty:-This option will delete all the older generations if the limit of generations is reached
For Eg:- If a GDG is defined with a limit of 30 and 31st generation is created then all the old 30 generations are deleted and the 31st generation is created.
NoEmpty:-Â This option will delete the oldest generation if the limit of generations is reachedÂ
For Eg:- If a GDG is defined with a limit of 30 and 31st generation is created then all the first generation will be deleted and the 31st generation will be created. So at the end there will be generations from 2nd to 31st
Scratch:-This option will delete the generation completely if the dataset is deleted. NoScratch-> This option will uncatalog the dataset if the dataset is deleted.