GDG is a collection of historically related non-VSAM data sets that are arranged in chronological order. Each data set within a GDG is called a generation data set (GDS) or generation.
Within a GDG, the generations can have like or unlike DCB attributes and data set organizations. If the attributes and organizations of all generations in a group are identical, the generations can be retrieved together as a single data set.
Generation data sets can be sequential, PDSs, or direct (BDAM). Generation data sets cannot be PDSEs, UNIX files, or VSAM data sets. The same GDG may contain SMS and non-SMS data sets.
Advantages to grouping related data sets include:
- All of the data sets in the group can be referred to by a common name.
- The operating system is able to keep the generations in chronological order.
- Outdated or obsolete generations can be automatically deleted by the operating system.
To define a GDG you must first create a GDG base. This base defines the base portion of the dataset names used by the GDGs as well as defining how many generations (files) can be stored within the GDG. Once this maximum number of generations is reached, creating a new generation will result in the oldest generation being discarded. A GDG can hold up to 255 generations.
The files within a GDG are assigned names derived from the name of the base and have a generation number added to the end so as to give each file a unique name.
GDG base name: TEST.DATASET
The first file created within this GDG will be given the name TEST.DATASET.G0001V00
Subsequent files will be named by incrementing the generation number:
G0002V00, G0003V00, etc. all the way up to G9999V00
Once the G9999V00 generation number is reached the numbering will start again from G0001V00.
1. The two zeroes on the end of the name are now usually used for version control.
2. Only one version is kept for each generation.
Generation data sets have sequentially ordered absolute and relative names that represent their age. The operating system’s catalog management routines use the absolute generation name (ex: TEST.DATASET.G0002V00). The relative name is a signed integer used to refer to the latest (0), the previous (-1) and the next (+1), and so forth, generation.
Next +1: TEST.DATASET(+2)
Referencing the entire GDG
It is possible to reference the entire GDG as if it were a single file by using the base name instead of an absolute or relative file reference. All files within the GDG will then be processed starting from the oldest generation and ending with the latest one. Note that to be able to reference all of the generations at once in this way that all of the files need to be defined with the common Data Control Block information (ex: the same record length). If the files within a GDG are never to be referenced this way then there is no requirement that they have any file attributes in common.
Rolled in and rolled off
When a GDG contains its maximum number of active generation data sets in the catalog, defined in the LIMIT parameter, and a new GDS is rolled in at the end-of-job step, the oldest generation data set is rolled off from the catalog. If a GDG is defined using DEFINE GENERATIONDATAGROUP EMPTY and is at its limit, then when a new GDS is rolled in, all the currently active GDSs are rolled off.