MainframeMaster

JCL Tutorial

Generation Data Groups (GDG)

Managing multiple versions of datasets efficiently

Progress0 of 0 lessons

What are Generation Data Groups?

Generation Data Groups (GDGs) are a powerful z/OS feature that allows you to manage multiple versions (generations) of related datasets. Each time a new generation is created, it becomes part of the group, and the system maintains the relationship between all versions.

GDGs are especially useful for:

  • Periodic processing, such as daily, weekly, or monthly reports
  • Backup and recovery procedures
  • Maintaining historical data while working with the most current version
  • Simplifying JCL for jobs that process the latest version of a dataset
  • Managing dataset versions without manual renaming or deletion

GDG Concepts and Terminology

GDG Base

A catalog entry that defines properties for the group and associates all generations

Generation

An individual dataset that belongs to a GDG

Absolute Generation Number

The actual identifier (G0001V00) assigned by the system

Relative Generation Number

Reference to generations relative to current (0, -1, +1)

GDG Limit

Maximum number of generations maintained in the catalog

GDG Roll-off

Process where oldest generations are removed when limit is reached

When you define a GDG, you create a GDG base entry in the catalog. The base doesn't contain any data itself; it's a control structure that groups the individual generations. Each physical dataset (generation) has a name consisting of the GDG base name followed by a suffix like G0001V00, G0002V00, etc.

Creating a GDG Base

Before you can create generation datasets, you must first define a GDG base using the IDCAMS utility. The base entry establishes the properties for the entire group.

IDCAMS DEFINE GENERATIONDATAGROUP Command

jcl
1
2
3
4
5
6
7
8
9
//DEFGDG EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE GENERATIONDATAGROUP - (NAME(MY.EXAMPLE.GDG) - LIMIT(5) - NOEMPTY - SCRATCH) /*

Key Parameters:

  • NAME - Specifies the GDG base name
  • LIMIT - Maximum number of generations to be maintained (1-255)
  • EMPTY/NOEMPTY - Controls whether all generations are deleted when the GDG base is deleted
    • EMPTY - All generations are uncataloged when the GDG base is deleted
    • NOEMPTY - All generations remain cataloged when the GDG base is deleted
  • SCRATCH/NOSCRATCH - Controls what happens to the oldest generation when it's removed from the GDG
    • SCRATCH - The dataset is deleted when it's removed from the GDG
    • NOSCRATCH - The dataset is uncataloged but not deleted when removed from the GDG

Creating and Referencing Generation Datasets

Creating a New Generation

To create a new generation, you reference the GDG base name with a relative generation number of +1:

jcl
1
2
3
4
5
6
7
8
//STEP1 EXEC PGM=MYPROG //SYSPRINT DD SYSOUT=* //OUTPUT DD DSN=MY.EXAMPLE.GDG(+1), // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(1,1)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD * Data records... /*

When creating a new generation, always specify DISP=(NEW,CATLG,DELETE). The CATLG disposition is essential for properly adding the dataset to the GDG.

Referencing Existing Generations

You can reference generations using relative numbers:

  • Current generation: DSN=MY.EXAMPLE.GDG(0)
  • Previous generation: DSN=MY.EXAMPLE.GDG(-1)
  • Oldest available generation: DSN=MY.EXAMPLE.GDG(-n) where n is the maximum within the LIMIT

Example: Processing the Current Generation

jcl
1
2
3
4
//STEP1 EXEC PGM=MYPROG //SYSPRINT DD SYSOUT=* //INPUT DD DSN=MY.EXAMPLE.GDG(0),DISP=SHR //OUTPUT DD SYSOUT=*

Example: Processing All Generations in Sequence

jcl
1
2
3
4
5
6
7
8
//STEP1 EXEC PGM=MYPROG //SYSPRINT DD SYSOUT=* //INPUT DD DSN=MY.EXAMPLE.GDG(-1),DISP=SHR // DD DSN=MY.EXAMPLE.GDG(-2),DISP=SHR // DD DSN=MY.EXAMPLE.GDG(-3),DISP=SHR // DD DSN=MY.EXAMPLE.GDG(-4),DISP=SHR // DD DSN=MY.EXAMPLE.GDG(0),DISP=SHR //OUTPUT DD SYSOUT=*

Managing GDGs

Displaying GDG Information

To list information about a GDG base and its generations, use the LISTCAT command:

jcl
1
2
3
4
5
//LISTGDG EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * LISTCAT ENTRIES(MY.EXAMPLE.GDG) ALL /*

Deleting a GDG Base

To delete a GDG base and potentially all its generations, use the DELETE command:

jcl
1
2
3
4
5
//DELGDG EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE MY.EXAMPLE.GDG GDG FORCE /*

Warning: Deleting a GDG base will affect all associated generations based on the EMPTY/NOEMPTY option specified when the GDG was created.

Modifying GDG Attributes

You can modify certain GDG attributes using the ALTER command:

jcl
1
2
3
4
5
//ALTGDG EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * ALTER MY.EXAMPLE.GDG LIMIT(10) /*

Best Practices for GDGs

Set Appropriate LIMIT

Choose a LIMIT value based on your retention needs and storage capacity. Too low might cause needed data to be lost; too high consumes unnecessary space.

Consider SCRATCH/NOSCRATCH Carefully

NOSCRATCH preserves datasets that roll off but keeps them uncataloged. This provides safety but requires manual cleanup eventually.

Be Careful with Absolute Names

Avoid referencing generations by their absolute names (with G0001V00) in JCL; use relative numbers to ensure your JCL works consistently.

Document GDG Usage

Keep clear documentation about your GDGs, including their purpose, retention requirements, and jobs that use them.

Include DCB Parameters on First Generation

Specify complete DCB parameters when creating the first generation to establish consistent dataset attributes for all generations.

Back Up GDG Catalog Information

Ensure your catalog backup procedures include GDG bases to facilitate disaster recovery without manual GDG reconstruction.

Common GDG Challenges

Practical Exercise

GDG Implementation Challenge

Create JCL to implement a daily reporting system using GDGs. The system should:

  1. Define a GDG base called REPORT.DAILY.DATA with a limit of 7 generations (one week of data)
  2. Create a new generation each day containing the day's data
  3. Process the current generation to produce a daily report
  4. Once a week, process all seven generations to produce a weekly summary report

Consider how you would handle:

  • Initial implementation when no generations exist yet
  • Recovery if a day's processing fails
  • Ensuring consistent dataset attributes across all generations

Try writing the JCL yourself, then compare with a sample solution in a future lesson.

Test Your Knowledge

1. What is the primary purpose of Generation Data Groups?

  • To compress datasets automatically
  • To manage multiple versions of related datasets
  • To encrypt sensitive data
  • To improve I/O performance

2. Which command is used to define a GDG base?

  • DEFINE GENERATIONDATAGROUP
  • DEFINE GDG
  • DEFINE GDGBASE
  • DEFINE GENERATIONGROUP

3. What does a relative generation number of -1 refer to?

  • The newest generation
  • The oldest generation
  • The most recently created previous generation
  • A non-existent generation

4. What happens when a GDG reaches its LIMIT value?

  • The system issues an error
  • The oldest generation is deleted when a new one is created
  • All generations are archived
  • The GDG becomes read-only

5. How would you reference the current (latest) generation in a JCL statement?

  • DSN=MY.GDG.DATA(+1)
  • DSN=MY.GDG.DATA(0)
  • DSN=MY.GDG.DATA
  • DSN=MY.GDG.DATA(LATEST)

Frequently Asked Questions