MODULE 12 · JCL AND BATCH JOBS · 2/9

JOB, EXEC and DD statements

15 min30 XPExercise

JCL comes from the punched-card era, and it shows. Every statement is an 80-column card image, and the columns matter as much as they did in fixed- format COBOL.

The fields of a statement

//STEP01   EXEC PGM=ACCTCOPY                 BACKUP THE MASTER
|| |       |    |                            |
|| name    op   operands                     comment
columns 1-2: //
Columns Content
1–2 // on every statement (//* for a comment line, /* ends instream data)
3–10 Name: 1 to 8 letters, digits or @ # $, starting with a letter. Must start in column 3
then at least one blank, the operation (JOB, EXEC, DD), at least one blank
then the operands, separated by commas with no blanks
after a blank, then anything you like: it's a comment
72 nothing past column 71 is part of the statement

Write JCL in capitals. Lining up operations in column 12 and operands in column 17 is only convention, but everyone does it and your team will expect it.

The three statements

//BACKUP   JOB (ACCT),'TRAINEE',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//STEP01   EXEC PGM=ACCTCOPY
//ACCTIN   DD DSN=BANK.ACCOUNTS,DISP=SHR
//SYSOUT   DD SYSOUT=*
  • JOB names the job (the name is what you look for in SDSF). The positional operands are accounting information and the programmer's name; CLASS picks the initiators that may run it, MSGCLASS where the job log goes, NOTIFY who gets a message when it ends. Every site has its own standard JOB card; copy it from a colleague.
  • EXEC starts a step. The step name is how the job log, restarts and COND refer to it. PGM= names the load module to run: your program's name, or a utility.
  • DD belongs to the step above it. The DD name must match what the program uses: the ASSIGN TO name in a COBOL SELECT, or a fixed name such as SYSUT1 for a utility.

A lone // ends the job; anything after it is ignored.

Continuation

A long statement is split after a comma. The next line starts with //, a blank in column 3, and the operands resume anywhere from column 4 to 16:

//ACCTOUT  DD DSN=BANK.ACCOUNTS.BACKUP,
//            DISP=(NEW,CATLG,DELETE)

Two classic mistakes:

  • Missing comma. Without the trailing comma, the second line is read as a new statement with no name and the "operation" DISP=(NEW,CATLG,DELETE): a JCL error.
  • Blank after a comma. DSN=BANK.ACCOUNTS, DISP=SHR ends the operands at the blank. DISP=SHR becomes a comment, and because the line ends in a comma the system treats the next line as a continuation. The error message then points at a later line. When a JCL error makes no sense, look at the line above.

Errors before anything runs

Syntax errors are caught when the job is converted, so no step runs and no dataset is touched. The simulator stops at the first error and tells you the line number, so fix one error, run again, repeat.

On the job

Real statements also use COND, REGION and TIME on the JOB card, and STEPLIB or JOBLIB DD statements to say which load library holds your freshly compiled program. If a job suddenly runs the old version of your code, check STEPLIB first.

Your task

A colleague wrote this backup job but it fails with a JCL error before anything runs. Fix the statement syntax so it runs cleanly.

The job has one step, STEP01, which runs the program ACCTCOPY. ACCTCOPY copies every record from DD ACCTIN to DD ACCTOUT and displays ACCTCOPY: nnnnn RECORDS COPIED.

DD Dataset DISP
ACCTIN BANK.ACCOUNTS (already exists) SHR
ACCTOUT BANK.ACCOUNTS.BACKUP (new) (NEW,CATLG,DELETE)
SYSOUT the spool SYSOUT=*

There are three mistakes, all about columns, blanks and commas. Keep the ACCTOUT statement split over two lines: fix the continuation rather than joining it into one line.

Run the job after each fix; the simulator reports one error at a time.

Check your understanding

1. In which columns must the name field of a JCL statement start?
2. What happens to DISP=SHR in //IN DD DSN=A.B, DISP=SHR ?
3. How do you continue a DD statement onto the next line?
JCL
Run your program to see its output here. The first visible test's input and datasets are used.
Submit to grade your program against every test.