Master Mainframe Technologies - COBOL, JCL, DB2, VSAM, CICS & More
ABEND Codes SQLCODEs File Status Interview Prep Contact
🖥 JCL

JCL GDG - Generation Data Groups

Intermediate 🕑 15 min read 👁 0 views

15

Code Example


## JCL GDG - Generation Data Groups

GDGs manage multiple versions (generations) of related datasets, automatically handling version numbers.

### GDG Concepts
- Base: Template defining the GDG (no data)
- Generations: Actual datasets (+1, 0, -1, etc.)
- Relative naming: Current, previous, next
- Absolute naming: Actual generation number

### Creating GDG Base
Use IDCAMS:
\`\`\`jcl
DEFINE GDG (NAME(MY.GDG.BASE) -
            LIMIT(10) -
            SCRATCH -
            NOEMPTY)
\`\`\`

### Relative Generation Numbers
\`\`\`jcl
DSN=MY.GDG.BASE(+1)    Next (new)
DSN=MY.GDG.BASE(0)     Current
DSN=MY.GDG.BASE(-1)    Previous
DSN=MY.GDG.BASE(-2)    Two back
\`\`\`

### Absolute Generation Numbers
\`\`\`jcl
DSN=MY.GDG.BASE.G0001V00
DSN=MY.GDG.BASE.G0002V00
\`\`\`

### GDG Parameters
- **LIMIT**: Max generations kept
- **SCRATCH**: Delete uncataloged datasets
- **NOSCRATCH**: Keep uncataloged datasets  
- **EMPTY**: Delete all when limit exceeded
- **NOEMPTY**: Keep limit, delete oldest

### Best Practices
- Use meaningful base names
- Set appropriate limits
- Handle rolloff properly