Referencing GDG Generations Using Relative Numbers

In a GDG each generation represents a different version of the dataset created over time.

Instead of using the full dataset name every time (like MYDATA.BACKUP.REPORT.G0005V00), we can refer to generations relatively

(0) always points to the latest (most recently created) generation.

(-1) points to the generation created just before the latest.

(-2) points to the one created before that

Similarly (-3), (-4), etc.

EXAMPLE

GDG base is MYDATA.BACKUP.REPORT and you have these generations:

  • MYDATA.BACKUP.REPORT.G0005V00 (latest)

  • MYDATA.BACKUP.REPORT.G0004V00

  • MYDATA.BACKUP.REPORT.G0003V00

In JCL or a program

  • Referring to MYDATA.BACKUP.REPORT(0) means you are accessing G0005V00

  • Referring to MYDATA.BACKUP.REPORT(-1) means you are accessing G0004V00

  • Referring to MYDATA.BACKUP.REPORT(-2) means you are accessing G0003V00

Referencing an existing generation using (0) and (-1)

Example: 1

Referencing an existing GDG generation

//ACESGDG   JOB (12345),CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//STEP1     EXEC PGM=MYPROGRAM
//INPUT     DD   DSN=MYDATA.BACKUP.REPORT(0),
//               DISP=SHR

Explanation:

DSN=MYDATA.BACKUP.REPORT(0): Refers to the current (most recent) generation (MYDATA.BACKUP.REPORT.G0005V00).

Example: 2

Referencing the previous generation

//ACESGDG   JOB (12345),CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//STEP1     EXEC PGM=MYPROGRAM
//INPUT     DD   DSN=MYDATA.BACKUP.REPORT(-1),
//               DISP=SHR

Explanation:

DSN=MYDATA.BACKUP.REPORT(-1): Refers to the previous generation (the one created just before the current one) (MYDATA.BACKUP.REPORT.G0004V00)

Last updated

Was this helpful?