The CNTL (Control) and ENDCNTL (End Control) statements create a control group that contains program control statements or operator commands. These statements provide a structured way to include multiple commands, parameters, or control statements within JCL, serving as a container for information that will be passed to a program or the system during execution.
Key Benefit:
CNTL/ENDCNTL provides an organized structure for including multiple commands or program-specific control statements directly within JCL, which enhances readability and maintainability of complex job streams.
123456//name CNTL // command-1 // command-2 ... // command-n // ENDCNTL
In this structure:
name
is a user-defined label for the control groupcommand-1
through command-n
are program control statements or system commandsENDCNTL
statement marks the end of the control group1//ddname DD CNTL=*.name
To reference the control group, a DD statement uses the CNTL parameter with a backward reference (*.name) to the labeled CNTL statement.
1234567891011//MYJOB JOB (ACCT#),'ADMIN',CLASS=A //* //DELSTEP EXEC PGM=IDCAMS //SYSIN DD CNTL=*.DELCNTL //SYSPRINT DD SYSOUT=* //* //DELCNTL CNTL DELETE MY.OLD.DATASET PURGE DELETE MY.TEMP.DATASET PURGE SET MAXCC=0 // ENDCNTL
This example uses CNTL/ENDCNTL to provide control statements to the IDCAMS utility, instructing it to delete multiple datasets.
1234567891011//CMDJOB JOB (ACCT#),'OPERATOR',CLASS=A //* //STEPA EXEC PGM=IEFBR14 //* //CMDCNTL CNTL COMMAND 'D A,L' COMMAND 'D ASM' COMMAND 'D GRS,C' // ENDCNTL //* //CMDS DD CNTL=*.CMDCNTL
This example uses CNTL/ENDCNTL to group multiple system display commands that will be issued during job execution.
1234567891011121314151617//DB2JOB JOB (ACCT#),'DBA',CLASS=A //* //RUNSQL EXEC PGM=DSNTEP2,PARM='ALIGN(MID)' //STEPLIB DD DSN=DB2.LOADLIB,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //SYSTSIN DD CNTL=*.SQLCNTL //* //SQLCNTL CNTL DSN SYSTEM(DB2P) RUN PROGRAM(DSNTEP2) PLAN(DSNTEP12) - LIB('DB2.RUNLIB') SELECT * FROM SYSIBM.SYSTABLES WHERE CREATOR = 'USER1'; SELECT COUNT(*) FROM USER1.CUSTOMER; END // ENDCNTL
This example shows how to use CNTL/ENDCNTL with DB2 statements to execute SQL queries through batch processing.
1234567891011121314//SORTJOB JOB (ACCT#),'USER',CLASS=A //* //STEP1 EXEC PGM=SORT //SORTIN DD DSN=MY.INPUT.FILE,DISP=SHR //SORTOUT DD DSN=MY.OUTPUT.FILE,DISP=(NEW,CATLG), // SPACE=(CYL,(10,5)),UNIT=SYSDA //SYSIN DD CNTL=*.SORTCNTL //SYSOUT DD SYSOUT=* //* //SORTCNTL CNTL SORT FIELDS=(1,10,CH,A,11,5,PD,D) INCLUDE COND=(21,4,CH,EQ,C'DEPT') OPTION EQUALS // ENDCNTL
This example demonstrates using CNTL/ENDCNTL to provide sort control statements to the SORT utility program.
Program/Utility | CNTL Usage |
---|---|
IDCAMS | DELETE, DEFINE, REPRO, and other Access Method Services commands |
IEBGENER | Data conversion and formatting control statements |
SORT | Sort field definitions, include/exclude conditions, and options |
DB2 | SQL statements and DSN commands |
FTP | FTP commands and transfer specifications |
COMMAND | Groups of system or subsystem commands |
CNTL/ENDCNTL | DD * or DD DATA |
---|---|
Can be referenced by multiple DD statements | Used by a single DD statement |
JCL syntax rules apply to statements | Free-form data without JCL syntax constraints |
Each line starts with // (columns 1-2) | No // prefix required for data lines |
Better for system commands and standard control statements | Better for arbitrary data or non-standard formats |
Issue | Possible Causes | Solutions |
---|---|---|
JCL error on CNTL statement |
|
|
Program doesn't recognize statements |
|
|
CNTL reference not found |
|
|
Command syntax errors |
|
|