JOB, EXEC and DD Statements Explained With a Working Example
Learn what the JOB, EXEC and DD statements do in z/OS JCL, with a working copy job, a field-by-field walk through, the job log and the common mistakes.

Job Control Language, JCL, is how you tell z/OS what to run. A mainframe does not start a program by typing its name. It receives a job: a description of the work, the program to run and the datasets it will read and write, and it runs that description as a batch. Nearly every JCL job, however long, is built from three kinds of statement, JOB, EXEC and DD. This post explains what each does using one small job that copies one dataset to another, with every field described, the log it produces, and the errors beginners meet first. The examples use z/OS 3.1 and JES2, the job entry subsystem most sites run, and they are the foundation for the complete JCL guide on this site, which builds on them.
The three statements in one job
//COPYJOB JOB (ACCT123),'COPY CUSTOMERS',CLASS=A,MSGCLASS=X,
// MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP1 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUT1 DD DSN=PROD.CUSTOMER.MASTER,DISP=SHR
//SYSUT2 DD DSN=TEST.CUSTOMER.COPY,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)Every statement begins in column 1 with //. After it comes a name, an operation, then operands. The name is optional on some statements and required on others, and the operation tells the system what kind of statement it is.
The JOB statement
The JOB statement is the first line of every job and gives it an identity. COPYJOB is the job name, which the system uses to identify the job in queues and logs; it is one to eight characters beginning with a letter or national character, and most sites require it to start with your user id, so check your site's rule.
The first operand, (ACCT123), is accounting information, a string that tells the installation whom to charge. The second, 'COPY CUSTOMERS', is the programmer name, free text of up to twenty characters. Then keyword operands that control how the job runs:
| Operand | Meaning |
|---|---|
CLASS=A | The job class, which decides which initiators may run the job and what resources it gets |
MSGCLASS=X | The output class for the job's system messages, which decides where the job log is held |
MSGLEVEL=(1,1) | Print all JCL statements and all allocation messages in the log |
NOTIFY=&SYSUID | Send a message to the submitting user when the job ends; &SYSUID is replaced by the user id |
Classes and message classes are set by each installation, so A and X here are common values, not universal ones.
The EXEC statement
An EXEC statement starts a step, one run of one program. Its name, STEP1, is how later JCL and the job log refer to the step. PGM=IEBGENER names the program to run, a utility supplied with z/OS that copies a sequential dataset to another. A job has one or more steps, run in order, and each step has its own set of DD statements. Instead of PGM= an EXEC can name a procedure, EXEC PROC=name or just EXEC name, which expands to a set of prewritten statements.
The name of the program is looked up in the system's libraries, in the order STEPLIB, JOBLIB if present, then the system link list. A program that lives in your own load library needs a STEPLIB statement that points to it.
The DD statements
A DD statement, for data definition, connects a name the program uses to a real dataset or other source. Programs do not hard-code dataset names. They open a name such as SYSUT1, and the JCL says what that name stands for in this run. The same program can therefore read a test file today and a production file tomorrow with no change to the program.
IEBGENER reads from SYSUT1, writes to SYSUT2, reads control statements from SYSIN and writes messages to SYSPRINT. The DD statements supply each of them.
SYSPRINT DD SYSOUT=* routes the message listing to the job's output, in the same class as the job log. SYSIN DD DUMMY supplies an empty control file, which tells IEBGENER to do a plain copy. SYSUT1 points to the input dataset with DSN= for the dataset name and DISP=SHR, which says the dataset exists and may be shared with other readers. SYSUT2 describes a new dataset: DISP=(NEW,CATLG,DELETE) says to create it, catalog it if the step succeeds, and delete it if the step fails. UNIT=SYSDA and SPACE=(CYL,(5,5),RLSE) say where and how much room to allocate, five cylinders to start and five more when needed, releasing unused space at the end. The DCB operand sets the record format and length: fixed blocked records of 80 bytes, with BLKSIZE=0 asking the system to choose a block size. The later posts on DISP, SPACE and DCB cover each in turn.
The continuation lines show a basic rule: a line that ends with a comma continues onto the next, which starts with // and then operands in columns 4 to 16.
What the log shows
When the job runs, JES2 writes a job log. The lines that matter in a successful run are these:
IEF142I COPYJOB STEP1 - STEP WAS EXECUTED - COND CODE 0000
IEF285I PROD.CUSTOMER.MASTER KEPT
IEF285I TEST.CUSTOMER.COPY CATALOGED
$HASP395 COPYJOB ENDED - RC=0000IEF142I reports that the step ran and gives its condition code, the number the step returned. 0000 means success. IEF285I reports what happened to each dataset when the step ended: the input was kept, and the new dataset was cataloged. $HASP395 is JES2 reporting that the job ended with a return code of zero. The job number the system assigns, shown as JOB followed by digits, is different on every run.
The mistakes beginners make
A missing comma at the end of a line that should continue. The next line is then read as a new statement, and the system reports a JCL error at the operand that follows.
**A dataset name with no DISP.** A DD for a dataset with no DISP defaults to NEW,DELETE, which creates a temporary dataset and throws it away. If you wanted to read an existing file, DISP=SHR is what you meant.
**A new dataset with no SPACE.** The system cannot allocate it, and the job fails with an allocation error before the program runs.
Names that are too long or start with a digit. Names of jobs, steps and DD statements are one to eight characters, and the first must be a letter or national character.
A program name that is not found. If PGM= names a module the system cannot find in its libraries, the step ends with an abend S806, and the fix is a STEPLIB or JOBLIB that points to the right library.
When JCL itself is wrong, the job never reaches the step. The log shows the failing statement and a message, then a line saying the job was not run because of a JCL error, and the return code is not 0:
IEF452I COPYJOB - JOB NOT RUN - JCL ERRORWhen this does not fit
Long jobs are rarely written out in full like this. Sites keep the repeated parts in procedures and in parameter libraries, and run production work from a scheduler rather than a person submitting JCL. The same three statements remain the base of everything, because a procedure is made of EXEC and DD statements and a scheduler submits a job that starts with a JOB statement. Online work such as CICS transactions does not use them per transaction, though the region that runs them was started by a job.


