GDG Basics in JCL: Generation Data Groups Explained with Examples
Understand GDG datasets, relative generations, and common JCL usage patterns for daily batch processing.
A Generation Data Group, or GDG, is a group of related datasets arranged by generation. GDGs are widely used in daily batch processing because they make it easy to refer to today’s file, yesterday’s file, or a newly created file.
Why GDGs are used
Many jobs process files by business date. For example:
- daily transaction file
- daily extract file
- daily report file
- daily backup file
Instead of hardcoding a new dataset name every day, a GDG allows relative references.
Relative generation numbers
Common references are:
GDG.BASE(0)= current/latest generationGDG.BASE(-1)= previous generationGDG.BASE(+1)= new generation to be created
Example:
//INFILE DD DSN=DBALA.SALES.DAILY(0),DISP=SHR
//OUTFILE DD DSN=DBALA.SALES.DAILY(+1),DISP=(NEW,CATLG,DELETE)
Creating a GDG base
GDG bases are often created with IDCAMS:
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE GDG(NAME(DBALA.SALES.DAILY) LIMIT(7) SCRATCH)
/*
LIMIT(7) keeps seven generations. SCRATCH means old generations are deleted when they roll off.
Practical use case
A daily billing job might do this:
1. Read CUSTOMER.INPUT(0).
2. Create BILLING.REPORT(+1).
3. Compare current report with BILLING.REPORT(-1).
4. Archive output for audit.
GDGs keep this flow simple and consistent.
Common mistakes
- Using
(0)when the job should create(+1). - Creating a new generation and then not cataloging it.
- Forgetting GDG base creation before first use.
- Assuming
(-1)exists in a new environment.
Conclusion
GDGs are a clean way to manage time-based datasets. Once you understand relative generations, many batch jobs become easier to read and safer to operate.