Chapter 27: Key Takeaways - JCL Essentials for COBOL Programmers
Chapter Summary
Job Control Language (JCL) is the scripting language of the z/OS mainframe -- it tells the operating system what programs to run, what datasets to use, and how to handle the outcomes. For COBOL programmers, JCL is not optional knowledge; it is the mechanism by which every COBOL program is compiled, linked, and executed in a batch environment. This chapter introduced the three fundamental JCL statement types -- JOB, EXEC, and DD -- and showed how they combine to create job streams that can compile source code, execute programs against production datasets, and manage output. Without a properly coded JCL job, even the most sophisticated COBOL program simply cannot run on z/OS.
The chapter explored each statement type in detail. The JOB statement defines the unit of work to the system, specifying the job name, accounting information, programmer name, message class, and job-level parameters such as REGION and TIME. The EXEC statement identifies which program or cataloged procedure to execute in each job step, and can pass PARM values directly to COBOL programs. DD (Data Definition) statements are where the real complexity lives -- they connect the logical file names used in COBOL SELECT statements to physical z/OS datasets, specifying attributes like DSN (dataset name), DISP (disposition), SPACE (allocation), DCB (data control block parameters), and UNIT. We examined how DISP's three sub-parameters (status, normal disposition, abnormal disposition) control dataset access and lifecycle.
Advanced JCL topics rounded out the chapter, including cataloged and in-stream procedures, symbolic parameters and their overrides, conditional execution through both the legacy COND parameter and the modern IF/THEN/ELSE/ENDIF construct, JCL comments, concatenated DD statements, and the JCLLIB statement for procedure libraries. The chapter also covered common JCL errors and the JES2/JES3 job entry subsystem, which manages job scheduling, input spooling, and output routing on the mainframe.
Key Concepts
- JOB Statement: The first statement in every job, it names the job, supplies accounting data, and sets job-level defaults for message class (MSGCLASS), message level (MSGLEVEL), job class (CLASS), region size (REGION), and CPU time limit (TIME).
- EXEC Statement: Identifies the program (PGM=) or cataloged procedure (PROC=) to execute for each step. The PARM parameter passes a string to the program, which COBOL receives through the LINKAGE SECTION using a standard parameter list convention.
- DD Statement: Connects a COBOL program's file definitions (the ddname matching the SELECT/ASSIGN clause) to physical datasets. Key parameters include DSN, DISP, SPACE, UNIT, VOL, and DCB.
- DISP Parameter: Three sub-parameters control dataset handling: status (NEW, OLD, SHR, MOD), normal disposition (KEEP, DELETE, CATLG, UNCATLG, PASS), and abnormal disposition (same options as normal). Default for existing datasets is (OLD,KEEP,KEEP).
- SPACE Parameter: Allocates disk space for new datasets using tracks (TRK), cylinders (CYL), or average block length. Includes primary quantity, secondary extent, and directory blocks for partitioned datasets.
- DSN Parameter: Specifies the fully qualified dataset name (up to 44 characters) or a temporary dataset name (&&TEMPNAME) for datasets that exist only for the duration of the job.
- Cataloged Procedures: Predefined sets of JCL stored in procedure libraries that can be invoked by name on an EXEC statement. They accept symbolic parameter overrides and are the standard mechanism for compiling and link-editing COBOL programs (e.g., IGYWCL, IGYWCLG).
- Symbolic Parameters: Placeholders in JCL procedures (coded as &SYMBOL) that are replaced with actual values when the procedure is invoked. Default values are defined with SET or on the PROC statement.
- COND Parameter: The legacy mechanism for conditional step execution, based on testing return codes from previous steps. COND=(4,LT) means "skip this step if 4 is less than the return code of any previous step."
- IF/THEN/ELSE/ENDIF: The modern conditional execution construct that is far more readable than COND. Allows testing specific step return codes, abend conditions, and run status with Boolean logic.
- Concatenated DD Statements: Multiple DD statements sharing the same ddname (only the first carries the name) are read sequentially as a single logical file, commonly used for library concatenation.
- JES2/JES3: The Job Entry Subsystem manages job input, scheduling, execution, and output. JES2 operates independently on each LPAR while JES3 provides centralized job management across a multi-system complex.
- JCLLIB Statement: Specifies the order in which procedure libraries are searched when a cataloged procedure is invoked, replacing the need for system-level PROCLIB modifications.
- Referbacks: The ability to reference a parameter from a previous DD statement using *.stepname.ddname notation, commonly used for DISP and DSN to avoid redundant coding.
Common Pitfalls
- Mismatching the DD name with the COBOL SELECT/ASSIGN clause. The ddname on the DD statement must exactly match the system name in the ASSIGN TO clause. A mismatch produces a S013 or S0C1 abend with no obvious error message pointing to the real cause.
- Getting the DISP parameter wrong for existing datasets. Using DISP=(NEW,...) for a dataset that already exists causes a JCL error (JCLERROR or IEC030I). Conversely, DISP=(OLD,...) or DISP=(SHR,...) for a dataset that does not exist causes a "dataset not found" failure.
- Forgetting to specify SPACE for new datasets. When DISP=(NEW,CATLG) is coded, a SPACE parameter must be provided or the job will fail. This is one of the most common JCL errors for beginners.
- Confusing COND parameter logic. The COND parameter uses inverted logic -- it specifies when to SKIP a step, not when to execute it. COND=(0,NE) means "skip if 0 is not equal to any prior return code," which effectively means "skip unless all prior steps returned 0."
- Not coding the abnormal disposition sub-parameter of DISP. If a job creates a dataset with DISP=(NEW,CATLG) and the step abends, the default abnormal disposition is DELETE, meaning the dataset is lost. Always code the third sub-parameter explicitly: DISP=(NEW,CATLG,DELETE) or DISP=(NEW,CATLG,CATLG) as appropriate.
- Exceeding the 71-character JCL record boundary. JCL statements must not extend past column 71. Continuation requires ending the line after a comma in columns 1-71, then starting the next parameter in columns 4-16 of the continuation line.
- Using incorrect accounting or class information. Each installation has its own standards for the JOB statement accounting field and CLASS parameter. Using invalid values causes the job to be rejected before it even begins execution.
Quick Reference
//MYJOB JOB (ACCT),'PROGRAMMER',
// CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1),
// REGION=0M,TIME=1440,NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=MYPROG,PARM='PARAM-VALUE'
//STEPLIB DD DSN=MY.LOAD.LIBRARY,DISP=SHR
//INPUT1 DD DSN=MY.INPUT.FILE,DISP=SHR
//OUTPUT1 DD DSN=MY.OUTPUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(10,5),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//*
//* CONDITIONAL EXECUTION
// IF STEP01.RC = 0 THEN
//STEP02 EXEC PGM=MYPROG2
//INPUT2 DD DSN=MY.OUTPUT.FILE,DISP=SHR
// ENDIF
//*
//* INVOKE CATALOGED PROCEDURE
//COMPILE EXEC PROC=IGYWCLG,
// PARM.COBOL='LIST,MAP,OFFSET'
//COBOL.SYSIN DD DSN=MY.SOURCE.LIB(MYPROG),DISP=SHR
//*
//* CONCATENATED DD
//STEPLIB DD DSN=MY.FIRST.LOADLIB,DISP=SHR
// DD DSN=MY.SECOND.LOADLIB,DISP=SHR
What's Next
Chapter 28 takes the JCL knowledge you have built and applies it to the design of complete batch processing solutions. You will learn about multi-step batch architectures, checkpoint/restart mechanisms that protect long-running jobs, the sequential file update pattern, control break processing for report generation, and strategies for error handling and recovery across complex job streams. These patterns form the backbone of mainframe batch operations in every enterprise.