In JCL, referencing data sets is a crucial aspect of managing and manipulating data. This topic will cover how to reference existing data sets, the syntax involved, and practical examples to help you understand the process.

Key Concepts

  1. Data Set Naming Conventions: Understanding the rules for naming data sets.
  2. Referencing Existing Data Sets: How to reference data sets that already exist.
  3. Using the DSN Parameter: Detailed explanation of the DSN (Data Set Name) parameter.
  4. Referencing Temporary Data Sets: How to reference data sets created within the same job.

Data Set Naming Conventions

Before referencing data sets, it's important to understand the naming conventions:

  • Qualified Names: Data set names are typically qualified, meaning they are divided into segments separated by periods (e.g., USER.DATA.SET).
  • Maximum Length: The maximum length of a data set name is 44 characters.
  • Characters: Names can include alphanumeric characters and special characters like @, #, and $.

Referencing Existing Data Sets

To reference an existing data set in JCL, you use the DSN parameter within a DD statement. The DSN parameter specifies the name of the data set you want to use.

Syntax

//DDNAME  DD  DSN=dataset.name,DISP=SHR
  • DDNAME: The name you assign to the DD statement.
  • DSN: The data set name.
  • DISP: The disposition parameter, which specifies the status of the data set (e.g., SHR for shared access).

Example

//STEP1    EXEC PGM=MYPROG
//INPUT1   DD   DSN=USER.DATA.INPUT,DISP=SHR
//OUTPUT1  DD   DSN=USER.DATA.OUTPUT,DISP=OLD

In this example:

  • INPUT1 references an existing data set USER.DATA.INPUT with shared access.
  • OUTPUT1 references an existing data set USER.DATA.OUTPUT with exclusive access (indicated by DISP=OLD).

Using the DSN Parameter

The DSN parameter is used to specify the name of the data set. It can be used in various ways depending on the context:

  • Fully Qualified Name: Specifies the complete name of the data set.
  • Partially Qualified Name: Uses a portion of the name, often with symbolic parameters.

Fully Qualified Name Example

//MYDATA  DD  DSN=USER.PROJECT.DATA,DISP=SHR

Partially Qualified Name Example

//MYDATA  DD  DSN=&USER..PROJECT.DATA,DISP=SHR

In this example, &USER is a symbolic parameter that will be replaced with a specific value at runtime.

Referencing Temporary Data Sets

Temporary data sets are created and used within the same job. They are typically referenced using special naming conventions.

Syntax

//DDNAME  DD  DSN=&&TEMPDS,DISP=(NEW,PASS)
  • &&TEMPDS: Indicates a temporary data set.
  • DISP=(NEW,PASS): Specifies that the data set is new and will be passed to subsequent steps.

Example

//STEP1    EXEC PGM=MYPROG
//TEMPDS   DD   DSN=&&TEMPDS,DISP=(NEW,PASS),UNIT=SYSDA,SPACE=(CYL,(5,5))
//STEP2    EXEC PGM=ANOTHERPGM
//INPUT    DD   DSN=&&TEMPDS,DISP=(OLD,DELETE)

In this example:

  • STEP1 creates a temporary data set &&TEMPDS.
  • STEP2 references the temporary data set &&TEMPDS created in STEP1.

Practical Exercise

Exercise

Write a JCL job that references an existing data set for input and creates a temporary data set for output, which is then used in a subsequent step.

Solution

//JOB1     JOB  (ACCT),'REFERENCE DATA SETS',CLASS=A,MSGCLASS=A
//STEP1    EXEC PGM=MYPROG
//INPUT    DD   DSN=USER.DATA.INPUT,DISP=SHR
//TEMPDS   DD   DSN=&&TEMPDS,DISP=(NEW,PASS),UNIT=SYSDA,SPACE=(CYL,(5,5))
//STEP2    EXEC PGM=ANOTHERPGM
//OUTPUT   DD   DSN=&&TEMPDS,DISP=(OLD,DELETE)

Explanation

  • STEP1:
    • INPUT references an existing data set USER.DATA.INPUT with shared access.
    • TEMPDS creates a new temporary data set &&TEMPDS.
  • STEP2:
    • OUTPUT references the temporary data set &&TEMPDS created in STEP1.

Common Mistakes and Tips

  • Incorrect Data Set Names: Ensure that data set names follow the naming conventions and do not exceed 44 characters.
  • Disposition Errors: Use the correct disposition parameters (DISP) to avoid conflicts and ensure proper data set handling.
  • Temporary Data Set References: When referencing temporary data sets, ensure that the naming and disposition parameters are consistent across steps.

Conclusion

Referencing data sets in JCL is a fundamental skill that allows you to manage and manipulate data effectively. By understanding the syntax and conventions, you can confidently reference both existing and temporary data sets in your JCL jobs. Practice with the provided examples and exercises to reinforce your understanding and prepare for more advanced topics.

© Copyright 2024. All rights reserved