In this section, we will cover how to add comments to your JCL code and how to handle long statements that need to be continued onto the next line. These are essential skills for writing clear, maintainable, and error-free JCL scripts.

Comments in JCL

Comments are used to make your JCL code more understandable. They can describe the purpose of the job, explain complex logic, or provide any other information that might be useful to someone reading the code.

Types of Comments

  1. In-line Comments: These comments are placed on the same line as a JCL statement.
  2. Standalone Comments: These comments occupy an entire line and are not associated with any specific JCL statement.

Syntax for Comments

  • In-line Comments: Use //* to start a comment. Anything following //* on that line is considered a comment.
  • Standalone Comments: Use //* at the beginning of the line.

Examples

//MYJOB    JOB  (ACCT),'MY JOB',CLASS=A,MSGCLASS=X
//* This is a standalone comment
//STEP1    EXEC PGM=MYPROG
//DD1      DD   DSN=MY.DATA.SET,DISP=SHR  //* This is an in-line comment

In the example above:

  • The line starting with //* This is a standalone comment is a standalone comment.
  • The part //* This is an in-line comment is an in-line comment.

Continuation in JCL

Sometimes, a JCL statement can be too long to fit on a single line. In such cases, you can continue the statement onto the next line.

Continuation Syntax

  • Use a comma , at the end of the line to indicate that the statement continues on the next line.
  • The continuation line should start in column 4.

Examples

//MYJOB    JOB  (ACCT),'MY JOB',CLASS=A,MSGCLASS=X
//STEP1    EXEC PGM=MYPROG
//DD1      DD   DSN=MY.LONG.DATASET.NAME,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,SPACE=(CYL,(50,10))
//* This is a continuation example

In the example above:

  • The DD statement for DD1 is continued over three lines.
  • Each continuation line starts in column 4.

Practical Exercise

Exercise 1: Adding Comments

Add comments to the following JCL script to explain each step:

//MYJOB    JOB  (ACCT),'MY JOB',CLASS=A,MSGCLASS=X
//STEP1    EXEC PGM=MYPROG
//DD1      DD   DSN=MY.DATA.SET,DISP=SHR

Solution

//MYJOB    JOB  (ACCT),'MY JOB',CLASS=A,MSGCLASS=X
//* This job is named MYJOB and is associated with account ACCT
//* It will run under class A and use message class X
//STEP1    EXEC PGM=MYPROG
//* This step executes the program MYPROG
//DD1      DD   DSN=MY.DATA.SET,DISP=SHR
//* This DD statement defines the data set MY.DATA.SET with shared disposition

Exercise 2: Using Continuation

Rewrite the following JCL script using continuation lines:

//MYJOB    JOB  (ACCT),'MY JOB',CLASS=A,MSGCLASS=X
//STEP1    EXEC PGM=MYPROG
//DD1      DD   DSN=MY.VERY.LONG.DATASET.NAME,DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,SPACE=(CYL,(50,10))

Solution

//MYJOB    JOB  (ACCT),'MY JOB',CLASS=A,MSGCLASS=X
//STEP1    EXEC PGM=MYPROG
//DD1      DD   DSN=MY.VERY.LONG.DATASET.NAME,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,SPACE=(CYL,(50,10))

Common Mistakes and Tips

  • Forgetting the comma: Ensure you place a comma at the end of the line to indicate continuation.
  • Incorrect column for continuation: The continuation line should start in column 4.
  • Overusing comments: While comments are helpful, avoid over-commenting, which can make the code harder to read.

Conclusion

In this section, you learned how to add comments to your JCL scripts and how to handle long statements using continuation lines. These practices are crucial for writing clear and maintainable JCL code. In the next section, we will dive into the JOB statement, which is fundamental for defining and managing JCL jobs.

© Copyright 2024. All rights reserved