Generation data group
A set of numbered copies of one file, so today's, yesterday's and older versions all exist.
Also written GDG, generation dataset
Why it matters. A daily backup job can run with the same JCL every night. The group keeps the last few copies for you.
See it
A GDG is a base name. Each run adds a new copy under it.
Syntax
DEFINE GDG (NAME(base) LIMIT(n) [SCRATCH|NOSCRATCH] [EMPTY|NOEMPTY]) //ddname DD DSN=base(+1),DISP=(NEW,CATLG),...
- NAME
- The base name of the group.
- LIMIT(n)
- How many generations to keep, up to 255.
- NOEMPTY
- When full, drop only the oldest. This is the default.
- EMPTY
- When full, drop them all.
- NOSCRATCH / SCRATCH
- Dropped copies are only uncatalogued, or also deleted.
- (0) (-1) (+1)
- Newest, the one before, and a new one.
Try it DEFINE GDG
- 1
You're in the SYSIN lines of job DEFGDG, under EXEC PGM=IDCAMS. Write the command that defines the base for daily backups, ZB0001.DEV.BACKUP, and keeps the last 3 copies. Type it on one line.
SYSIN DEFINE GDG (NAME(ZB0001.DEV.BACKUP) LIMIT(3)) - 2
Submit the job DEFGDG from your DEV JCL library.
SUBMIT 'ZB0001.DEV.JCL(DEFGDG)' - 3
Read what IDCAMS printed, STEP1.SYSPRINT.
OUTPUT DEFGDG STEP1.SYSPRINT - 4
Ask the catalog about the base.
LISTCAT ENTRIES('ZB0001.DEV.BACKUP')
Remember
- A GDG is a base name plus numbered copies, called generations.
- (0) is the newest copy. (-1) is the one before. (+1) makes a new one.
- LIMIT is how many to keep. When it is full, the oldest drops out of the group. It is uncatalogued, and deleted too if the group was defined with SCRATCH.
The usual mistake
DSN=ZB0001.DEV.BACKUP to write tonight's copy
The base name alone does not make a new generation. Used as input, it reads every generation in turn. To write, you name one: (+1) for a new one.
DSN=ZB0001.DEV.BACKUP(+1)
On real z/OS
The base is defined with IDCAMS DEFINE GDG, as on z/OS. The line starting Mainframe101 sim: in the SYSPRINT listing is MF/OS's own note. MF/OS does not model SCRATCH or EMPTY, or the model dataset (GDGMODEL) real jobs often point to. In a real job, every (+1) in one job means the same new generation, and it is cataloged at the end of the step that made it.
Where can I practise Generation data group?
Right here, at ZedBank. You take a junior job at a simulated bank and use Generation data group in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- DatasetWhat a mainframe calls a file: a named collection of records with a defined structure, rather than a loose stream of bytes.
- Batch processingRunning work in bulk, without anyone watching, usually on a schedule. The overnight run that settles a day of transactions.
- JCLJob Control Language: the language used to tell the mainframe what programs to run, in what order, and with what files.
- DispositionThe DISP parameter, which says whether a dataset already exists, and what to do with it when the step ends normally or fails.
- IDCAMSThe utility used to create, list, copy and delete datasets, and the standard tool for anything involving VSAM.