Introduction

The Disposition (DISP) parameter in JCL is crucial for defining how datasets are treated during and after the execution of a job. It specifies the status of the dataset at the beginning of the job step, what to do with the dataset if the job step ends normally, and what to do if the job step ends abnormally.

Key Concepts

The DISP parameter has three sub-parameters:

  1. Status: Indicates the status of the dataset at the start of the job step.
  2. Normal Disposition: Specifies what to do with the dataset if the job step ends normally.
  3. Abnormal Disposition: Specifies what to do with the dataset if the job step ends abnormally.

DISP Syntax

DISP=(status,normal-disposition,abnormal-disposition)

Status Values

  • NEW: The dataset is to be created.
  • OLD: The dataset already exists and is to be used.
  • MOD: The dataset already exists and is to be appended.
  • SHR: The dataset already exists and is to be shared.

Normal and Abnormal Disposition Values

  • DELETE: The dataset is to be deleted.
  • KEEP: The dataset is to be kept.
  • CATLG: The dataset is to be cataloged.
  • UNCATLG: The dataset is to be uncataloged.
  • PASS: The dataset is to be passed to the subsequent steps.

Practical Examples

Example 1: Creating a New Dataset

//STEP1    EXEC PGM=MYPROG
//MYDATA   DD   DSN=MY.NEW.DATASET,DISP=(NEW,CATLG,DELETE),
//              SPACE=(CYL,(5,5)),UNIT=SYSDA

Explanation:

  • Status: NEW - The dataset MY.NEW.DATASET is to be created.
  • Normal Disposition: CATLG - If the job step ends normally, the dataset will be cataloged.
  • Abnormal Disposition: DELETE - If the job step ends abnormally, the dataset will be deleted.

Example 2: Using an Existing Dataset

//STEP2    EXEC PGM=MYPROG
//MYDATA   DD   DSN=MY.EXISTING.DATASET,DISP=(OLD,KEEP,KEEP)

Explanation:

  • Status: OLD - The dataset MY.EXISTING.DATASET already exists and is to be used.
  • Normal Disposition: KEEP - If the job step ends normally, the dataset will be kept.
  • Abnormal Disposition: KEEP - If the job step ends abnormally, the dataset will be kept.

Example 3: Appending to an Existing Dataset

//STEP3    EXEC PGM=MYPROG
//MYDATA   DD   DSN=MY.APPEND.DATASET,DISP=(MOD,CATLG,DELETE)

Explanation:

  • Status: MOD - The dataset MY.APPEND.DATASET already exists and is to be appended.
  • Normal Disposition: CATLG - If the job step ends normally, the dataset will be cataloged.
  • Abnormal Disposition: DELETE - If the job step ends abnormally, the dataset will be deleted.

Practical Exercises

Exercise 1: Define a New Dataset

Task: Write a JCL statement to create a new dataset USER.TEST.DATA that should be cataloged if the job ends normally and deleted if it ends abnormally.

Solution:

//STEP1    EXEC PGM=MYPROG
//TESTDATA DD   DSN=USER.TEST.DATA,DISP=(NEW,CATLG,DELETE),
//              SPACE=(CYL,(1,1)),UNIT=SYSDA

Exercise 2: Use and Keep an Existing Dataset

Task: Write a JCL statement to use an existing dataset USER.EXIST.DATA and keep it regardless of the job's outcome.

Solution:

//STEP2    EXEC PGM=MYPROG
//EXISTDATA DD   DSN=USER.EXIST.DATA,DISP=(OLD,KEEP,KEEP)

Exercise 3: Append to a Dataset and Catalog It

Task: Write a JCL statement to append to an existing dataset USER.APPEND.DATA and catalog it if the job ends normally, but delete it if the job ends abnormally.

Solution:

//STEP3    EXEC PGM=MYPROG
//APPENDDATA DD   DSN=USER.APPEND.DATA,DISP=(MOD,CATLG,DELETE)

Common Mistakes and Tips

  • Incorrect Status: Ensure the status (NEW, OLD, MOD, SHR) matches the actual state of the dataset.
  • Disposition Conflicts: Be cautious of conflicting dispositions, such as trying to catalog a dataset that doesn't exist.
  • Dataset Naming: Always verify the dataset names to avoid unintentional data loss.

Conclusion

Understanding the DISP parameter is essential for effective dataset management in JCL. By mastering the status, normal disposition, and abnormal disposition sub-parameters, you can control the lifecycle of datasets within your JCL jobs. Practice with different scenarios to become proficient in using the DISP parameter.

© Copyright 2024. All rights reserved