Showing posts with label DD statement. Show all posts
Showing posts with label DD statement. Show all posts

Saturday, 10 August 2013

JCL Statements Quick Reference: JOB, EXEC, DD, and More

A converter error such as IEFC001I often comes from one misplaced field, a missing comma, or a statement coded in the wrong part of the job. This quick reference identifies the JCL statements that define a job, run its steps, allocate resources, call procedures, apply conditions, and control special processing.

JCL statements quick reference showing JOB, EXEC, and DD as the core job flow with supporting PROC, IF, SET, INCLUDE, JCLLIB, and OUTPUT statements
JOB identifies the unit of work, EXEC starts a step, and DD defines the resources used by that step.

JCL statements, commands, and control records

Most lines in a batch job are JCL statements, not commands. A JCL statement normally starts with two slashes and contains an operation such as JOB, EXEC, or DD. The language also has a comment statement, an in-stream data delimiter, a null statement, and two ways to place operator commands in an input stream.

JES2 and JES3 control statements are a separate category. They may appear beside JCL in submitted input, but their syntax and behavior belong to the active job entry subsystem. The JES2 and JES3 statement reference covers that boundary.

Anatomy of a JCL statement

IBM divides a JCL statement into identifier, name, operation, parameter, and comments fields. Not every statement uses every field.

//STEP01   EXEC PGM=IEFBR14          RUN A PROGRAM
//DD01     DD   DSN=USERID.TEST,DISP=SHR
  • Identifier: columns 1 and 2 normally contain //.
  • Name: begins in column 3, can be one through eight supported characters, and is followed by a blank.
  • Operation: identifies the statement, such as EXEC or DD.
  • Parameters: follow the operation and are commonly separated by commas.
  • Comments: follow the parameter field after at least one blank.

Except for a comment statement, do not code fields past column 71. Columns 73 through 80 are ignored and are often used for sequence numbers. See the JCL parameter field guide for positional and keyword parameter rules.

The minimum JOB, EXEC, and DD pattern

A job needs a JOB statement and at least one EXEC statement. DD statements are added when the program or procedure needs data sets, SYSOUT, in-stream input, or other resources.

//REFJOB   JOB  (ACCT),'JCL REF',CLASS=A,MSGCLASS=X
//STEP01   EXEC PGM=IEFBR14
//WORKDD   DD   DSN=USERID.TEST.DATA,DISP=SHR

The JOB statement describes the submitted job. EXEC establishes STEP01 and requests IEFBR14. WORKDD associates a DD name with an existing cataloged data set. The JOB, EXEC, and DD tutorial explains this basic structure in detail.

JCL statements quick-reference table

Statement or recordTypical formPrimary purpose
JOB//jobname JOB ...Marks the beginning of a job and assigns its job name.
EXEC//stepname EXEC PGM=...Creates a job step and runs a program or procedure.
DD//ddname DD ...Identifies input, output, storage, SYSOUT, or another step resource.
PROC / PEND//name PROC ... // PENDBegins and ends an in-stream procedure; PROC can also appear in a cataloged procedure.
SET//name SET SYMBOL=valueAssigns or changes JCL symbolic parameter values.
INCLUDE//name INCLUDE MEMBER=memberInserts a complete JCL group from a library.
JCLLIB//name JCLLIB ORDER=...Specifies search libraries for procedures and INCLUDE groups.
IF / THEN / ELSE / ENDIF//name IF condition THENControls execution of one or more steps from prior step results.
OUTPUT//name OUTPUT ...Defines processing options that SYSOUT DD statements can reference.
Comment//* textDocuments the input stream without creating an executable statement.
Delimiter/*Ends in-stream data unless another delimiter was defined with DLM.
Null//Marks the end of a job in an input stream.
COMMAND//name COMMAND 'command'Requests an MVS or JES command; use is controlled by installation authority.
JCL command// command operandsOlder input-stream form for an operator command; IBM prefers COMMAND.
CNTL / ENDCNTL//label CNTL ... //label ENDCNTLDelimits program control statements for supported processing.
XMIT//name XMIT destinationTransmits input-stream records from one node to another.
EXPORT//name EXPORT SYMLIST=...Makes selected JCL symbol values available to a job-step program.
SCHEDULE//name SCHEDULE ...Supplies JES2 scheduling attributes such as job-group or hold timing.
Use this table to identify a statement, then open its full reference before coding uncommon parameters. Several entries are installation-sensitive or valid only in specific positions.

JOB statement

JOB begins the job, supplies its name, and can carry accounting, programmer, class, message, notification, restart, and other job-level parameters. The exact accounting field and accepted classes are site rules.

//PAYR001  JOB (D123),'PAYROLL',CLASS=A,
//             MSGCLASS=X,NOTIFY=&SYSUID

A continuation keeps the parameter field readable. Do not copy a job card from another system without checking accounting and class requirements.

EXEC statement

EXEC starts a job step. Use PGM= to run a program, PROC= to call a procedure, or the procedure name as the first positional value where permitted.

//SORTSTEP EXEC PGM=SORT
//COPYSTEP EXEC PROC=COPYPROC,HLQ=USERID

A step name lets later conditions, restart requests, backward references, and messages identify the step. The JCL EXEC statement guide covers PGM, PROC, PARM, and COND.

DD statement

DD defines a resource used by a step. Common forms name an existing data set, allocate a new one, route output to SYSOUT, declare DUMMY input, concatenate data sets, or introduce in-stream records.

//INPUT    DD DSN=USERID.INPUT,DISP=SHR
//REPORT   DD SYSOUT=*
//SYSIN    DD *
  CONTROL STATEMENT
/*

The program determines which DD names it expects. A syntactically valid DD with the wrong name does not satisfy that program contract. Review the JCL DD statement guide before changing DISP, SPACE, DCB, UNIT, or volume details.

PROC and PEND statements

PROC begins an in-stream procedure and PEND ends it. A cataloged procedure member can also start with PROC, though IBM permits the PROC statement to be omitted in some cataloged procedure cases. Symbolic parameters on PROC provide defaults that a calling EXEC can override.

//MYPROC   PROC HLQ=USERID
//PSTEP    EXEC PGM=MYPROG
//INPUT    DD DSN=&HLQ..INPUT,DISP=SHR
//         PEND

Keep procedure boundaries matched. The cataloged procedure guide covers JCLLIB search order and overrides.

SET, INCLUDE, and JCLLIB statements

SET assigns a value to a JCL symbol. INCLUDE inserts a complete group of JCL statements from a library. JCLLIB tells the converter which private libraries to search for procedures and INCLUDE members before or along with site defaults.

//LIBS     JCLLIB ORDER=(USERID.PROCLIB,SYS1.PROCLIB)
//VARS     SET ENV=TEST,HLQ=USERID
//COMMON   INCLUDE MEMBER=OUTDDS

INCLUDE cannot be used to splice the missing continuation of an incomplete DD statement. The included member must contain complete statements, and symbol values must be set where converter processing can resolve them.

IF, THEN, ELSE, and ENDIF statements

This construct conditionally runs job steps from return-code, abend, or run-state tests. The THEN or ELSE clause that is selected must contain at least one EXEC statement; comments and SET statements alone do not make an executable branch.

//CHKRC    IF (STEP01.RC = 0) THEN
//STEP02   EXEC PGM=MYPROG
//         ELSE
//FAIL     EXEC PGM=ERRHANDL
//         ENDIF

JOB, JCLLIB, JOBLIB, and XMIT do not belong inside a conditional branch. Use the JCL IF/THEN/ELSE/ENDIF guide for RC, ABEND, and RUN examples.

Comment, delimiter, and null records

//* starts a JCL comment statement. /* normally ends in-stream data read from a DD * or DD DATA statement. A DLM parameter can define another two-character delimiter when the input itself might contain /*.

A null statement contains only //. It marks the end of a job in the input stream. Do not confuse it with a blank comment or a continuation line.

OUTPUT statement

OUTPUT JCL defines processing options for SYSOUT data sets, such as destination, forms, copies, or related print handling. A SYSOUT DD can refer to the OUTPUT statement by name.

//OUTOPT   OUTPUT DEST=LOCAL,COPIES=2
//REPORT   DD SYSOUT=A,OUTPUT=*.OUTOPT

Supported output parameters and destinations depend on JES and installation configuration. This JCL statement is different from the TSO OUTPUT command used to retrieve or manage held job output.

COMMAND and JCL command statements

Both forms can place an operator command in the input stream, but IBM identifies COMMAND as the preferred JCL statement. Commands are normally issued when conversion occurs and are not synchronized with later job-step execution.

Do not use a command statement as a timed application step. Authorization, input source, job class, JES options, and site policy control whether the command is accepted. Coordinate operational commands with the system operations team.

CNTL and ENDCNTL statements

CNTL and ENDCNTL enclose program control statements that a supported subsystem or program processes. The opening and closing labels may need to match, and no ordinary JCL statements belong inside the control group. They are uncommon in daily application JCL; follow the product-specific format.

See the CNTL and ENDCNTL example for a focused explanation.

XMIT statement

XMIT transmits input-stream records from one network node to another. Routing names, authority, supported operands, and NJE configuration are installation matters. It is not the same as the TSO TRANSMIT command.

The JCL XMIT guide gives a separate example, while the JCL miscellaneous features guide places XMIT beside other less-used statements.

EXPORT statement

EXPORT names JCL symbols whose values should be available to an executing job-step program. The coded form uses SYMLIST; the symbol must also receive a value through SET or procedure symbol processing at the proper point.

//EXPSYM   EXPORT SYMLIST=(ENV,REGION)
//VALUES   SET ENV=TEST,REGION=EAST

Exported values resolve at execution time under rules that differ from ordinary converter substitution. Review the IBM reference before using them in procedures or in-stream data.

SCHEDULE statement

SCHEDULE supplies attributes for JES2 job scheduling, including association with a job group or a timed hold. It is supported by JES2, not JES3, and is ignored for started tasks and TSO sessions. Code it after JOB and before the first EXEC or IF statement; only one is allowed in a job.

JCL statements versus JES control statements

JCL tells z/OS which work to perform and which resources a step uses. JES control statements tell the job entry subsystem how to handle submission, routing, accounting, or output. A line that starts with a slash and asterisk can mean different things in JES2, JES3, and JCL contexts, so confirm the active subsystem before copying old input-stream controls.

Continuation rules that prevent converter errors

  • End a continued parameter line with a comma where the syntax requires another parameter.
  • Begin the continuation record with // and leave the name and operation fields blank.
  • Start the continued parameter field in columns 4 through 16.
  • Keep statement fields within column 71.
  • Do not split quoted text or a parameter at an arbitrary point.
  • Use matched parentheses and retain the comma between adjacent parameters.

Always read the converter message and the statement shown in the JES listing. The reported line can be where the parser noticed the problem, while the missing comma or quote sits on the prior record.

Common JCL statement mistakes

SymptomLikely causeCheck
Operation not recognizedName, operation, or blank delimiter is misplaced.Verify the five statement fields and column 3.
Parameter treated as an operationContinuation alignment is wrong.Leave name and operation blank on the continued record.
Procedure or INCLUDE member not foundSearch library or member name is wrong.Check JCLLIB ORDER, site defaults, and catalog access.
Unmatched statement messageMissing or extra ENDIF, PEND, or ENDCNTL.Pair every opening and closing statement.
Step skipped unexpectedlyIF expression or earlier step result differs from the assumption.Read step RC and abend data in the job log.
Command runs too earlyInput-stream command executes during conversion.Do not treat COMMAND as step-synchronized work.

Pre-submission checklist

  1. Confirm JOB is first and every executable unit has an EXEC statement.
  2. Match each program-required DD name exactly.
  3. Check commas, quotes, parentheses, and continuation alignment.
  4. Match PROC/PEND, IF/ENDIF, and CNTL/ENDCNTL pairs.
  5. Confirm JCLLIB members and symbolic parameters exist.
  6. Separate JCL syntax from JES2 or JES3 controls.
  7. Review destructive data-set dispositions and operator commands.
  8. After submission, read converter, allocation, and step messages.

Official IBM references

JCL statements FAQ

What are the three main JCL statements?

JOB identifies the job, EXEC defines a job step and requests a program or procedure, and DD identifies resources used by that step. Most batch jobs use these three statement types even when they also need conditions or procedures.

Is DD a JCL command?

DD is a JCL statement whose operation is data definition. It associates a DD name with a data set, SYSOUT class, in-stream data, DUMMY resource, or another supported allocation. Calling every JCL statement a command can hide the separate COMMAND syntax.

What is the difference between a comment, delimiter, and null statement?

A comment begins with three characters, slash-slash-asterisk. A delimiter normally contains slash-asterisk and ends in-stream data. A null statement contains only two slashes and marks the end of a job in an input stream.

Why does valid-looking JCL fail in the converter?

Common causes are a field in the wrong column, a missing comma, bad continuation alignment, an unmatched ENDIF or PEND, and an operation coded where it is not allowed. Check the prior record as well as the line named in the converter message.

New In-feed ads