Generation Data Group in Mainframe Environment

What is GENERATION DATA GROUP  (GDG)?

Generation Data Group is a method used on the mainframe to allow a group of related files to be created which can be referenced individually or as a group. It is group of datasets that are related to each other chronologically or functionally
1) Adding a new generation.
2) Retaining the previous generation.
3) Discarding the oldest generation
Using GDG, JCL can remain unchanged while the data set names change with every execution.

How to Create GDG?
//GDG01 EXEC PGM=IEFBR14
//GDG DD DSN=MVS.SAMPLEGDG.BASE(+1),DISP=(NEW,CATLG)
//SPACE=(TRK,(....)),VOL=SER=....,
//UNIT=SYSDA,DCB= MVS.SMPLMODEL

How to Allocate GDG?
DEFGDG EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
DEFINE GDG -
(NAME(MVS.SAMPLEGDG.BASE)-
SCRATCH
NOEMPTY
LIMIT(10))
/*


How to Delete a GDG Entry?
//INFENR EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE MVS.SAMPLEGDG.BASE PURGE FORCE
/*