Generation Data Groups (GDG) are collections of related datasets organized as generations, providing automatic version management. GDGs allow you to maintain multiple versions of datasets with automatic roll-off of old generations. Understanding GDGs is essential for managing versioned data files, reports, and output datasets. This tutorial covers defining GDGs, using GDG generations, deleting GDGs, and best practices.
GDGs provide a powerful way to manage dataset versions automatically. Instead of manually creating versioned dataset names, GDGs handle versioning through generations. Each generation is a separate dataset, but they're organized under a GDG base name. This tutorial provides practical guidance for working with GDGs effectively.
GDGs organize datasets into generations for automatic version management.
A Generation Data Group (GDG) is a catalog structure that organizes related datasets as generations. Each generation is a separate dataset, but they're grouped under a GDG base name. GDGs automatically manage versioning, allowing you to reference datasets by relative generation numbers rather than specific version names.
GDGs are commonly used for:
GDG structure includes:
GDG generations use relative numbers:
GDG generations are named with a pattern:
1234GDG Base: USERID.REPORTS.OUTPUT Generation 1: USERID.REPORTS.OUTPUT.G0001V00 Generation 2: USERID.REPORTS.OUTPUT.G0002V00 Generation 3: USERID.REPORTS.OUTPUT.G0003V00
The system automatically appends generation numbers (G0001V00, G0002V00, etc.) to the base name.
Defining a GDG creates the GDG index in the catalog.
To define a GDG, use the IDCAMS utility with the DEFINE GDG command:
123456789//DEFGDG JOB ... //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE GDG (NAME(USERID.REPORTS.OUTPUT) - LIMIT(5) - SCRATCH - NOEMPTY) /*
This defines a GDG with:
Key parameters for GDG definition:
SCRATCH and NOSCRATCH control automatic deletion:
EMPTY and NOEMPTY control empty GDG handling:
You can also define a GDG from TSO using IDCAMS:
12345ALLOCATE FILE(SYSPRINT) DA('*') ALLOCATE FILE(SYSIN) DA(*) CALL 'SYS1.LINKLIB(IDCAMS)' DEFINE GDG (NAME(USERID.REPORTS.OUTPUT) LIMIT(5) SCRATCH NOEMPTY) END
Using GDG generations in JCL and TSO commands.
To create a new generation, use +1 in JCL:
1234//OUTPUT DD DSN=USERID.REPORTS.OUTPUT(+1), // DISP=(NEW,CATLG), // SPACE=(TRK,(10,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3120)
This creates a new generation and catalogs it. The +1 tells the system to create the next generation in sequence.
To reference the current (newest) generation, use 0:
12//INPUT DD DSN=USERID.REPORTS.OUTPUT(0), // DISP=SHR
This references the newest generation. The 0 always points to the most recent generation.
To reference previous generations, use negative numbers:
1234//PREVIOUS DD DSN=USERID.REPORTS.OUTPUT(-1), // DISP=SHR //OLDER DD DSN=USERID.REPORTS.OUTPUT(-2), // DISP=SHR
This references the previous generation (-1) and two generations back (-2).
You can reference GDG generations in TSO commands:
12ALLOCATE FILE(INPUT) DA('USERID.REPORTS.OUTPUT(0)') SHR ALLOCATE FILE(OUTPUT) DA('USERID.REPORTS.OUTPUT(+1)') NEW
When a GDG reaches its limit:
For example, with LIMIT(5):
You can view GDG information using LISTCAT.
Use LISTCAT to view GDG index and generations:
1LISTCAT ENTRIES('USERID.REPORTS.OUTPUT') ALL
This shows the GDG index and all generations.
Example LISTCAT output for a GDG:
123456789101112131415161718LISTCAT ENTRIES('USERID.REPORTS.OUTPUT') ALL USERID.REPORTS.OUTPUT GDG BASE LIMIT --- 5 SCRATCH NOEMPTY IN-CAT --- USERID.USERCAT USERID.REPORTS.OUTPUT.G0001V00 IN-CAT --- USERID.USERCAT VOLUME --- VOL001 DSORG --- PS USERID.REPORTS.OUTPUT.G0002V00 IN-CAT --- USERID.USERCAT VOLUME --- VOL001 DSORG --- PS
You can delete individual generations or the entire GDG.
To delete a specific generation, use DELETE:
123456//DELGEN JOB ... //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE USERID.REPORTS.OUTPUT.G0001V00 /*
This deletes the specified generation. You can also use relative numbers in some contexts.
To delete all generations, delete each one individually, or use a pattern:
12345678//DELALL JOB ... //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE USERID.REPORTS.OUTPUT.G0001V00 DELETE USERID.REPORTS.OUTPUT.G0002V00 DELETE USERID.REPORTS.OUTPUT.G0003V00 /*
After deleting all generations, delete the GDG index:
123456//DELGDG JOB ... //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE USERID.REPORTS.OUTPUT GDG /*
The GDG keyword specifies deleting the GDG index. This removes the GDG definition from the catalog.
You can delete GDG generations from TSO:
12DELETE 'USERID.REPORTS.OUTPUT.G0001V00' DELETE 'USERID.REPORTS.OUTPUT' GDG
Following best practices helps you use GDGs effectively:
Common scenarios for using GDGs.
GDGs are ideal for daily reports:
GDGs work well for data file versions:
GDGs simplify output file management:
Understanding when to use GDGs vs regular datasets.
Use GDGs for:
Use regular datasets for:
Common GDG issues and solutions.
If GDG is not found:
If you cannot create a generation:
If generation numbers seem wrong:
Think of GDG like a photo album with automatic organization:
So GDG is like a smart photo album that automatically organizes your dataset versions, keeps the newest ones, and removes the oldest ones when needed!
Complete these exercises to reinforce your understanding of GDGs:
Practice definition: define a test GDG with IDCAMS, set appropriate limit and options, verify GDG definition with LISTCAT, and understand GDG parameters. Master GDG definition.
Practice creation: create multiple GDG generations using JCL, verify generations with LISTCAT, understand generation numbering, and learn generation creation. Master generation creation.
Practice referencing: reference GDG generations using relative numbers (0, -1, -2), understand relative number meanings, test generation access, and learn GDG references. Master generation references.
Practice limits: create generations up to the limit, observe automatic roll-off, understand SCRATCH behavior, test limit enforcement, and learn GDG limits. Master GDG limits.
Practice deletion: delete individual generations, delete all generations, delete GDG index, verify deletions, and learn GDG deletion. Master GDG deletion.
1. What does GDG stand for?
2. What does +1 mean in a GDG reference?
3. What does 0 mean in a GDD reference?
4. What happens when a GDG reaches its limit?
5. How do you define a GDG?