Showing posts with label DD CNTL parameter. Show all posts
Showing posts with label DD CNTL parameter. Show all posts

Saturday, 10 August 2013

JCL CNTL and ENDCNTL Statements: Program Control Example

A print job can need control information that is not a normal DD, EXEC, or OUTPUT statement. In z/OS JCL, CNTL marks the start of one or more program control statements, and ENDCNTL marks the end of that group. The common example is a PSF direct-printing job where a PRINTDEV statement sits between CNTL and ENDCNTL.

JCL CNTL and ENDCNTL diagram showing a labeled control block, program control statement, and DD CNTL reference
Group the control statements.

What are CNTL and ENDCNTL in JCL?

CNTL and ENDCNTL define a block of program control statements in the input stream. IBM lists CNTL as the statement that marks the beginning of one or more program control statements and ENDCNTL as the statement that marks their end.

Most everyday batch jobs never use these statements. You are more likely to see them in special printing work, especially where a job supplies printer initialization data through PRINTDEV.

Basic syntax

//label    CNTL
//label    program-control-statement
//label    ENDCNTL
//ddname   DD  CNTL=*.label,other-dd-parameters

The label matters because the DD statement can refer to the control block by using the CNTL=*.label parameter. Keep the names short and clear. JCL statement names begin after the leading // and can be up to eight characters.

PRINTDEV example

This sample shows the shape of a direct-printing step. Site standards vary, so copy real printer parameters from your print support team instead of guessing values.

//PRTSTEP  EXEC PGM=MYPRINT
//PSFCTL   CNTL
//PSFCTL   PRINTDEV TRACE=YES,
//             PIMSG=(YES,16),
//             DATACK=BLOCK
//PSFCTL   ENDCNTL
//OUT1     OUTPUT FORMDEF=STD1
//PRTDD    DD UNIT=AFP1,
//            CNTL=*.PSFCTL,
//            OUTPUT=*.OUT1,
//            SYSOUT=*

The DD statement named PRTDD points back to the PSFCTL control block. That connection is the reason the label needs to be stable and easy to read.

How the statements work together

Part Purpose Check during review
CNTL Starts the program control block. Has a label that the DD statement can reference.
Control statement Supplies subsystem or program control data, such as PRINTDEV. Uses parameters approved for that subsystem.
ENDCNTL Ends the control block. Appears after the control statements and before the referencing DD.
DD CNTL=*.label Connects the DD statement to the control block. References the correct label in the same step.

Placement rules

Place the CNTL and ENDCNTL block in the same step as the DD statement that references it. In the usual pattern, the DD statement follows the block and uses CNTL=*.name to point to it.

Do not treat CNTL as a substitute for PROC, INCLUDE, or IF/THEN/ELSE/ENDIF. It has a narrower job: it groups control statements for a program or subsystem that expects them.

When would you use CNTL and ENDCNTL?

PSF direct printing

IBM's direct-printing examples show CNTL, PRINTDEV, and ENDCNTL used together. This is the main case a JCL learner is likely to find in old production libraries.

Subsystem-specific control data

Some subsystem interfaces accept control statements through the input stream. If your site uses that pattern, the production JCL should include a runbook note that explains who owns the parameters.

Legacy print procedures

Old cataloged procedures can hide this block behind symbolic parameters. When a print problem appears, expand the PROC or review the resolved JCL before changing CNTL labels.

Common mistakes

Using the wrong label

If CNTL=*.PSFCTL points to a label that does not exist in the step, conversion or allocation can fail before the program does useful work.

Putting the DD in another step

The control block and the referencing DD belong in the same job step. A later step cannot safely rely on a prior step's CNTL block.

Adding comments where the subsystem example forbids them

For PSF direct-printing examples, IBM states that CNTL and ENDCNTL have no parameters and must not have comments on the same line. Keep comments on separate //* lines if your site wants notes.

Troubleshooting checklist

  • Confirm the CNTL label is spelled the same way in CNTL=*.label.
  • Check the control block is in the same EXEC step as the referencing DD.
  • Verify the DD appears after the CNTL/ENDCNTL block when your site follows the standard print pattern.
  • Review the subsystem statement, such as PRINTDEV, against local print support documentation.
  • Keep labels within the JCL name length rules.
  • Check the JES conversion messages before changing the program.

Related Mainframe Forum guides

For nearby JCL topics, read JCL EXEC statement, JCL DD statement, JCL parameters, JCL IF/THEN/ELSE/ENDIF, JCL instream procedures, and JCL spanned records.

External references

IBM documents JCL statement purposes, JCL statement fields, and direct-printing JCL with PRINTDEV.

FAQ

What does CNTL mean in JCL?

CNTL marks the beginning of one or more program control statements in a job step.

What does ENDCNTL do?

ENDCNTL marks the end of the control statement group that started with CNTL.

Is CNTL used in normal batch JCL?

Usually no. Most batch jobs use JOB, EXEC, DD, and condition statements. CNTL appears more often in special print or subsystem control cases.

How does a DD statement refer to CNTL?

A DD statement can use CNTL=*.label, where label is the name on the CNTL block in the same step.

New In-feed ads