JCLintermediate

Generation Data Groups (GDGs)

Understand how GDGs manage a rolling series of related datasets (like daily extracts) by relative generation number instead of hardcoded names.

A Generation Data Group is a cataloged collection of chronologically related datasets — think daily, weekly, or monthly extracts of the same file — referenced by relative generation number rather than a fixed absolute name. This is a heavily tested JCL concept because almost every shop's daily batch cycle produces and consumes GDGs, and interviewers use it to check whether you can reason about relative generations without getting confused about direction.

A GDG is like a stack of dated newspapers on a porch where you never refer to the actual date printed on the page — you just say 'today's paper' (+1) when adding a new one or 'yesterday's paper' (-1 or 0) when picking one up to read, and the oldest paper at the bottom eventually gets recycled once the stack hits its limit.

Key Concepts

1
Each dataset in a GDG is a 'generation,' and JCL refers to them relative to the current base: GDGNAME(0) is the most recently created generation, GDGNAME(+1) means 'create the next new generation,' GDGNAME(-1) means 'the generation before the current one,' and so on. This relative addressing means today's job doesn't need to know or hardcode an actual date-stamped dataset name — it just says 'create the newest generation' or 'read the most recent one,' and the catalog handles the bookkeeping.
2
GDG bases are defined via IDCAMS with DEFINE GDG, specifying LIMIT (how many generations to retain) and SCRATCH/NOSCRATCH (whether rolled-off generations are physically deleted or just uncatalogued). When the LIMIT is reached, the oldest generation is either scratched or simply deallocated from the GDG index depending on that setting, which is itself a frequent point of confusion in interviews.
3
A strong candidate can explain both directions fluently: writing a new day's file uses (+1) with DISP=(NEW,CATLG,DELETE), while reading yesterday's already-created file for comparison uses (0) or (-1) with DISP=SHR — mixing these up (using +1 to read, or 0 to create) is one of the most common real-world GDG mistakes.