In this section, we will explore the concept of temporary data sets in JCL. Temporary data sets are used for intermediate storage during the execution of a job and are deleted automatically when the job completes. They are particularly useful for passing data between steps within the same job.
Key Concepts
- Definition: Temporary data sets are data sets that exist only for the duration of the job and are deleted once the job completes.
- Naming Convention: Temporary data sets are identified by names that start with two ampersands (
&&
). - Scope: They are accessible only within the job in which they are created.
Creating Temporary Data Sets
To define a temporary data set in JCL, you use the DD
statement with a name that starts with &&
. Here is the basic syntax:
Example
Let's look at a practical example where we create a temporary data set and use it in subsequent steps.
//JOB1 JOB (ACCT),'TEMP DATA SET EXAMPLE',CLASS=A,MSGCLASS=X //STEP1 EXEC PGM=PROG1 //TEMPDS DD DSN=&&TEMP,DISP=(NEW,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSOUT DD SYSOUT=* //STEP2 EXEC PGM=PROG2 //INPUT DD DSN=&&TEMP,DISP=(OLD,DELETE) //SYSOUT DD SYSOUT=*
Explanation
-
STEP1:
- TEMPDS: Defines a temporary data set named
&&TEMP
. TheDISP=(NEW,PASS)
parameter indicates that the data set is newly created and will be passed to the next step. - UNIT=SYSDA: Specifies the device type.
- SPACE=(CYL,(1,1)): Allocates space for the data set.
- DCB=(RECFM=FB,LRECL=80,BLKSIZE=800): Defines the data control block parameters.
- TEMPDS: Defines a temporary data set named
-
STEP2:
- INPUT: References the temporary data set
&&TEMP
created in STEP1. TheDISP=(OLD,DELETE)
parameter indicates that the data set is to be used as an existing data set and will be deleted after this step.
- INPUT: References the temporary data set
Practical Exercises
Exercise 1: Creating and Using a Temporary Data Set
Task: Write a JCL job that creates a temporary data set in the first step and uses it in the second step.
//JOB2 JOB (ACCT),'TEMP DATA SET EXERCISE',CLASS=A,MSGCLASS=X //STEP1 EXEC PGM=PROG1 //TEMPDS DD DSN=&&TEMP,DISP=(NEW,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSOUT DD SYSOUT=* //STEP2 EXEC PGM=PROG2 //INPUT DD DSN=&&TEMP,DISP=(OLD,DELETE) //SYSOUT DD SYSOUT=*
Solution Explanation:
- STEP1: Creates a temporary data set
&&TEMP
with the necessary parameters. - STEP2: Uses the temporary data set
&&TEMP
and deletes it after use.
Exercise 2: Modifying a Temporary Data Set
Task: Modify the previous job to add a third step that reads the temporary data set again.
//JOB3 JOB (ACCT),'MODIFY TEMP DATA SET',CLASS=A,MSGCLASS=X //STEP1 EXEC PGM=PROG1 //TEMPDS DD DSN=&&TEMP,DISP=(NEW,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSOUT DD SYSOUT=* //STEP2 EXEC PGM=PROG2 //INPUT DD DSN=&&TEMP,DISP=(OLD,PASS) //SYSOUT DD SYSOUT=* //STEP3 EXEC PGM=PROG3 //INPUT DD DSN=&&TEMP,DISP=(OLD,DELETE) //SYSOUT DD SYSOUT=*
Solution Explanation:
- STEP1: Creates the temporary data set
&&TEMP
. - STEP2: Uses the temporary data set
&&TEMP
and passes it to the next step. - STEP3: Reads the temporary data set
&&TEMP
again and deletes it after use.
Common Mistakes and Tips
- Incorrect DISP Parameter: Ensure that the
DISP
parameter is correctly set toPASS
when passing the data set between steps. - Naming Convention: Always start the name of a temporary data set with
&&
. - Scope Limitation: Remember that temporary data sets are only accessible within the job they are created in.
Conclusion
Temporary data sets are a powerful feature in JCL for managing intermediate data within a job. By understanding how to create, use, and manage these data sets, you can write more efficient and organized JCL jobs. In the next section, we will delve into referencing data sets, which will further enhance your ability to manage data within your JCL jobs.
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