Progress0 of 0 lessons

Generation Data Groups (GDG): Define, Use, and Delete

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.

Understanding Generation Data Groups

GDGs organize datasets into generations for automatic version management.

What is a GDG?

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:

  • Maintaining historical versions of output files
  • Storing report generations
  • Managing data file versions
  • Automating version roll-off
  • Simplifying dataset references in JCL

GDG Structure

GDG structure includes:

  • GDG Base Name: The base name for all generations (e.g., USERID.REPORTS.OUTPUT)
  • GDG Index: Catalog entry that defines the GDG
  • Generations: Individual datasets with generation numbers (G0001V00, G0002V00, etc.)
  • Limit: Maximum number of generations allowed
  • Scratch/NoScratch: Whether to delete old generations automatically

Generation Numbers

GDG generations use relative numbers:

  • +1: Creates a new generation (next in sequence)
  • 0: References the current (newest) generation
  • -1: References the previous generation
  • -2: References two generations back
  • And so on for older generations

GDG Naming Convention

GDG generations are named with a pattern:

text
1
2
3
4
GDG 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

Defining a GDG creates the GDG index in the catalog.

Using IDCAMS DEFINE GDG

To define a GDG, use the IDCAMS utility with the DEFINE GDG command:

jcl
1
2
3
4
5
6
7
8
9
//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:

  • NAME: GDG base name
  • LIMIT: Maximum number of generations (5)
  • SCRATCH: Delete old generations when limit is reached
  • NOEMPTY: Don't allow empty GDG index

GDG Definition Parameters

Key parameters for GDG definition:

  • NAME: GDG base name (required)
  • LIMIT: Maximum generations (required, typically 5-10)
  • SCRATCH: Delete old generations automatically (default)
  • NOSCRATCH: Keep old generations (manual deletion required)
  • EMPTY: Allow empty GDG index
  • NOEMPTY: Don't allow empty GDG index (default)

SCRATCH vs NOSCRATCH

SCRATCH and NOSCRATCH control automatic deletion:

  • SCRATCH: When limit is reached, oldest generation is automatically deleted (uncataloged and deleted)
  • NOSCRATCH: Old generations are uncataloged but not deleted (manual deletion required)
  • SCRATCH is more common for automatic cleanup
  • NOSCRATCH provides more control but requires manual management

EMPTY vs NOEMPTY

EMPTY and NOEMPTY control empty GDG handling:

  • EMPTY: Allows GDG index to exist with no generations
  • NOEMPTY: GDG index is deleted when last generation is deleted
  • NOEMPTY is more common for automatic cleanup
  • EMPTY allows GDG to exist before first generation is created

Defining GDG from TSO

You can also define a GDG from TSO using IDCAMS:

text
1
2
3
4
5
ALLOCATE 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

Using GDG generations in JCL and TSO commands.

Creating New Generations

To create a new generation, use +1 in JCL:

jcl
1
2
3
4
//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.

Referencing Current Generation

To reference the current (newest) generation, use 0:

jcl
1
2
//INPUT DD DSN=USERID.REPORTS.OUTPUT(0), // DISP=SHR

This references the newest generation. The 0 always points to the most recent generation.

Referencing Previous Generations

To reference previous generations, use negative numbers:

jcl
1
2
3
4
//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).

GDG in TSO Commands

You can reference GDG generations in TSO commands:

text
1
2
ALLOCATE FILE(INPUT) DA('USERID.REPORTS.OUTPUT(0)') SHR ALLOCATE FILE(OUTPUT) DA('USERID.REPORTS.OUTPUT(+1)') NEW

GDG Limit and Roll-Off

When a GDG reaches its limit:

  • New generation (+1) is created
  • Oldest generation is automatically removed (if SCRATCH)
  • GDG maintains the specified limit
  • Generation numbers are renumbered if needed

For example, with LIMIT(5):

  • When generation 6 is created, generation 1 is removed
  • GDG always has the 5 most recent generations
  • Automatic cleanup maintains the limit

Viewing GDG Information

You can view GDG information using LISTCAT.

LISTCAT for GDG

Use LISTCAT to view GDG index and generations:

text
1
LISTCAT ENTRIES('USERID.REPORTS.OUTPUT') ALL

This shows the GDG index and all generations.

LISTCAT Output Example

Example LISTCAT output for a GDG:

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
LISTCAT 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

Deleting GDG Generations

You can delete individual generations or the entire GDG.

Deleting Individual Generations

To delete a specific generation, use DELETE:

jcl
1
2
3
4
5
6
//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.

Deleting All Generations

To delete all generations, delete each one individually, or use a pattern:

jcl
1
2
3
4
5
6
7
8
//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 /*

Deleting GDG Index

After deleting all generations, delete the GDG index:

jcl
1
2
3
4
5
6
//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.

Deleting from TSO

You can delete GDG generations from TSO:

text
1
2
DELETE 'USERID.REPORTS.OUTPUT.G0001V00' DELETE 'USERID.REPORTS.OUTPUT' GDG

GDG Best Practices

Following best practices helps you use GDGs effectively:

  • Choose Appropriate Limits: Set limits based on how many generations you need (typically 5-10)
  • Use SCRATCH for Auto-Cleanup: Use SCRATCH for automatic deletion of old generations
  • Use NOEMPTY for Cleanup: Use NOEMPTY to automatically remove GDG index when empty
  • Document GDG Usage: Document which applications use which GDGs
  • Monitor GDG Growth: Periodically review GDG generations
  • Use Consistent Naming: Follow naming conventions for GDG base names
  • Plan for Deletion: Understand deletion requirements before creating GDGs
  • Test GDG Operations: Test GDG creation and deletion in test environments

Common GDG Scenarios

Common scenarios for using GDGs.

Daily Report Generation

GDGs are ideal for daily reports:

  • Each day creates a new generation (+1)
  • Previous days are accessible via -1, -2, etc.
  • Old reports are automatically cleaned up
  • Easy to reference current report (0)

Data File Versions

GDGs work well for data file versions:

  • Maintain multiple versions of data files
  • Access previous versions for comparison
  • Automatic version management
  • Simplified JCL references

Output File Management

GDGs simplify output file management:

  • Automatic versioning of output files
  • Easy access to historical outputs
  • Automatic cleanup of old files
  • Consistent naming across versions

GDG vs Regular Datasets

Understanding when to use GDGs vs regular datasets.

Use GDGs When

Use GDGs for:

  • Files that need automatic versioning
  • Output files with historical versions
  • Reports that need to be maintained over time
  • Data files with multiple versions
  • Files that benefit from automatic cleanup

Use Regular Datasets When

Use regular datasets for:

  • Single-version files
  • Files that don't need versioning
  • Input files that don't change
  • Files with manual version management
  • Files that don't fit GDG patterns

Troubleshooting GDG Issues

Common GDG issues and solutions.

GDG Not Found

If GDG is not found:

  • Verify GDG is defined using LISTCAT
  • Check GDG base name is correct
  • Verify catalog access permissions
  • Check if GDG index exists

Cannot Create Generation

If you cannot create a generation:

  • Verify GDG is defined
  • Check GDG limit hasn't been reached (if NOSCRATCH)
  • Verify catalog permissions
  • Check for catalog errors

Generation Number Issues

If generation numbers seem wrong:

  • Use LISTCAT to see actual generation numbers
  • Verify relative numbers match expectations
  • Check for deleted generations
  • Review GDG history

Explain Like I'm 5: GDG

Think of GDG like a photo album with automatic organization:

  • GDG is like a photo album that automatically organizes your photos. When you take a new photo, it goes in the front of the album (+1). The album can only hold a certain number of photos (limit). When it's full and you add a new photo, the oldest photo in the back automatically falls out. It's like having a smart photo album that keeps your newest photos and removes the oldest ones!
  • Generations are like individual photos in the album. Each photo is separate, but they're all in the same album. You can look at the newest photo (0), the previous photo (-1), or older photos (-2, -3, etc.). It's like having numbered photos that you can reference by their position!
  • Defining a GDG is like setting up the photo album. You decide how many photos it can hold (limit), whether old photos should be thrown away automatically (SCRATCH), and other rules. It's like creating the album with specific rules for how it works!

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!

Practice Exercises

Complete these exercises to reinforce your understanding of GDGs:

Exercise 1: Define a GDG

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.

Exercise 2: Create Generations

Practice creation: create multiple GDG generations using JCL, verify generations with LISTCAT, understand generation numbering, and learn generation creation. Master generation creation.

Exercise 3: Reference Generations

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.

Exercise 4: GDG Limit and Roll-Off

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.

Exercise 5: Delete GDG

Practice deletion: delete individual generations, delete all generations, delete GDG index, verify deletions, and learn GDG deletion. Master GDG deletion.

Test Your Knowledge

1. What does GDG stand for?

  • Group Data Generation
  • Generation Data Group
  • General Data Group
  • Grouped Data Generation

2. What does +1 mean in a GDG reference?

  • Previous generation
  • Current generation
  • New generation
  • Oldest generation

3. What does 0 mean in a GDD reference?

  • Previous generation
  • Current (newest) generation
  • New generation
  • Oldest generation

4. What happens when a GDG reaches its limit?

  • No more generations can be created
  • The oldest generation is automatically deleted
  • The GDG is deleted
  • An error occurs

5. How do you define a GDG?

  • Using ISPF Data Set Utility
  • Using IDCAMS DEFINE GDG
  • Using TSO ALLOCATE
  • Using JCL DD statement

Related Concepts