Creating New GDG Base
Creating New GDG Base
Before using GDG, we need to create a GDG base first. Then, we need to create the generations on it. IDCAMS utility is used to create a GDG base. The syntax is as follows -
----+----1----+----2----+----3----+----4
//job-card
//STEP01 EXEC PGM=IDCAMS
//SYSIN DD *
DEFINE GDG(NAME(gdg-base-name) -
LIMIT(nnn) -
EMPTY|NOEMPTY -
SCRATCH|NOSCRATCH)
/*
Parameters -
- NAME(gdg-base-name) - Specifies the name of the GDG base.
- LIMIT(nnn) - Specifies the total number of generations that the GDG may contain. The maximum value for LIMIT is 255.
- EMPTY|NOEMPTY - These are mutually exclusive parameters.
EMPTY parameter specifies that all existing generations are to be uncataloged whenever the generations of GDG reach the maximum limit. For example, Suppose a GDG is defined with a limit of 7, and we are creating an 8th generation with an EMPTY option. In that case, it will delete all seven generations.
NOEMPTY specifies that only the oldest generation of the GDG is to be uncataloged if the limit is reached. From the same above example, if it is NOEMPTY option, it will delete the oldest generation (G0001V00). - SCRATCH|NOSCRATCH - These are mutually exclusive parameters.
SCRATCH specifies that the generation should be deleted physically when uncataloged.
NOSCRATCH specifies that the generation should not be deleted when it is uncataloged. It can be accessed using the UNIT and VOL parameters.
Practical Example -
Scenario - Create a GDG base with 5 generations limit and delete the oldest generation when it reaches the limit.
Code -
----+----1----+----2----+----3----+----4----+----5----+----6
//MATEPKCG JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//***************************************************
//* Create GDG Base
//***************************************************
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE GDG(NAME(MATEPK.TESTPS.GDG) -
LIMIT(05) -
NOEMPTY -
SCRATCH)
/*
SYSPRINT in Spool -
Output -
Explaining Example -
In this example, the IDCAMS utility creates the GDG called MATEPK.TESTPS.GDG. The number of generations that can exist at anytime is limited to five. NOEMPTY specifies the system should uncatalog the oldest generation once the limit is reached. The SCRATCH parameter is used to determine whether to physically delete the uncataloged data set.