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 -

//SYSIN   DD  *
   DEFINE GDG(NAME(gdg-base-name) -
          LIMIT(nnn)       -
          EMPTY|NOEMPTY    -

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 -

//             NOTIFY=&SYSUID
//* Create GDG Base
//SYSIN   DD  *
          LIMIT(05)  - 
          NOEMPTY    - 

SYSPRINT in Spool -

Creating New GDG Base SYSPRINT

Output -

Creating New GDG Base 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.