Deleting GDG
Deleting a Generation Data Group (GDG) involves two key aspects: deleting the GDG base and optionally deleting the individual generations (datasets) associated with that GDG.
Deleting Generation -
If we want to delete the individual generations associated with the GDG, we should delete them separately. This can be done either before or after deleting the GDG base.
Scenario - Delete the latest generation.
MATEPK.TEST.GDG
MATEPK.TEST.GDG.G0001V00
MATEPK.TEST.GDG.G0002V00
Code -
----+----1----+----2----+----3----+----4----+----5----+
//MATEPKDG JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//*
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
DELETE (MATEPK.TEST.GDG(0)) GDG
/*
SYSPRINT in Spool -
Output -
MATEPK.TEST.GDG
MATEPK.TEST.GDG.G0001V00
In the above example, we have deleted the latest generation (MATEPK.TEST.GDG.G0002V00) of the GDG MATEPK.TEST.GDG.
Deleting GDG Base -
To delete a GDG base, we typically use the IDCAMS utility DELETE statement in JCL. DELETE statement uses two parameters: -
- PURGE parameter deletes the GDG base, even if its retention period has not expired.
- FORCE parameter is used to delete the GDG base, the model, and all related generations if they exist.
Scenario - Deleting GDG Base.
MATEPK.TEST.GDG
MATEPK.TEST.GDG.G0001V00
MATEPK.TEST.GDG.G0002V00
Code -
----+----1----+----2----+----3----+----4----+----5----+
//MATEPKC JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//*
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
DELETE (MATEPK.TEST.GDG) GDG FORCE
/*
SYSPRINT in Spool -
Output -
In the above example, we have deleted the base (MATEPK.TEST.GDG.G0002V00) and all its generations that are currently on it.