Deleting and uncataloging generation data sets

Note that uncataloging is not supported for SMS-managed data sets.

In a multiple-step job, catalog or uncatalog generation data sets using the DD DISP parameter. Do not use the IEHPROGM utility program or a user program. Because system routines access the catalog during job execution, they are unaware of the functions performed by IEHPROGM or a user program; you might get unpredictable results.

If a DD statement in a multiple-step job tries to delete or uncatalog any generation data set except the oldest in a GDG, catalog management can lose orientation within the data group. This could cause the deletion, uncataloging, or retrieval of the wrong data set when you later refer to a specific generation. Therefore, if you delete a generation data set in a multiple-step job, do not refer to any older generations in later job steps.

When you delete a generation data group in a multiple-step job, remember that the first time you use a relative generation number for a generation data group within a job, the system establishes the relationship between the relative generation number and the absolute generation number. The system maintains this relationship throughout the job.

The following examples illustrate how the system maintains this relationship when deleting a generation data group:

Assume the following generation data sets already exist with absolute generation numbers: G0006V00, G0007V00, and G0008V00.

Issue the following JCL:
//STEP1  EXEC
//DD1    DD    DISP=OLD,DSN=A.B.C(-1)
//STEP2  EXEC
//DD2    DD    DISP=(OLD,DELETE),DSN=A.B.C
//STEP3  EXEC
//DD3    DD    DISP=(NEW,CATLG),DSN=A.B.C(+1)  

In the above example, the absolute generation number referenced by relative generation number in STEP1 (DD1) is G0007V00. The system establishes the relative/absolute relationship that it will maintain throughout the job. In STEP2, all generation data sets are to be deleted, which occurs at STEP2 termination. In STEP3, the system assigns the absolute generation number G0009V00 to the new generation data set created (DD3).

In the following example, the JCL is set up to delete all generation data sets at the beginning of the job.
//STEP1  EXEC
//DD1    DD    DISP=(OLD,DELETE),DSN=A.B.C
//STEP2  EXEC
//DD2    DD    DISP=(NEW,CATLG),DSN=A.B.C(+1)
//STEP3  EXEC
//DD3    DD    DISP=(NEW,CATLG),DSN=A.B.C(+2)  

In this second example, the system establishes the relative/absolute relationship in STEP2, the first time that a relative generation number is used in the job. The system then assigns absolute generation number G0001V00 to the data set referenced in DD2 and absolute generation number G0002V00 to the data set referenced in DD3.