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:
- Status: Indicates the status of the dataset at the start of the job step.
- Normal Disposition: Specifies what to do with the dataset if the job step ends normally.
- Abnormal Disposition: Specifies what to do with the dataset if the job step ends abnormally.
DISP Syntax
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
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
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:
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:
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.
JCL (Job Control Language) Course
Module 1: Introduction to JCL
Module 2: JCL Statements and Syntax
Module 3: Data Definition (DD) Statements
Module 4: Procedures and Symbolic Parameters
Module 5: Advanced JCL Concepts
- Conditional Processing
- JCLLIB and INCLUDE Statements
- Generation Data Groups (GDGs)
- Restart and Checkpoint
Module 6: Error Handling and Debugging
- Common JCL Errors
- Interpreting JCL Error Messages
- Debugging Techniques
- Using JES2/JES3 for Troubleshooting