Sunday, 28 July 2013

JCL EXEC Statement: PGM, PROC, PARM, and COND Examples

//STEP10 EXEC PGM=IDCAMS starts a job step named STEP10 and tells z/OS to run IDCAMS. Every executable step begins with a JCL EXEC statement. The statement can name a program directly, invoke a reusable procedure, pass program options, and control step-level processing.

JCL EXEC statement flow from JOB to an EXEC step, program or procedure, and DD statements
An EXEC statement starts a step, selects a program or procedure, and is followed by the DD statements needed by that work.

JCL EXEC statement syntax

//stepname EXEC PGM=program-name,keyword=value
//stepname EXEC PROC=procedure-name,keyword=value
//stepname EXEC procedure-name,keyword=value

An EXEC statement must identify a program or a procedure. PGM= names an executable program. PROC= names a cataloged or in-stream procedure. If both PGM and PROC are omitted, z/OS treats the first positional value after EXEC as a procedure name.

The step name is one through eight characters and identifies the job step in messages, condition tests, backward references, and overrides. Choose a meaningful name such as SORTIN, COMPILE, or REPORT. Step names must be unique within the job.

Statement boundary: an EXEC statement begins a step. The next EXEC statement, another JOB statement, or the end of the job ends that step. The associated DD statements normally follow the EXEC statement.

Run a program with EXEC PGM

//COPYSTEP EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSUT1   DD  DSN=APP.INPUT.FILE,DISP=SHR
//SYSUT2   DD  DSN=APP.OUTPUT.FILE,
//             DISP=(NEW,CATLG,DELETE),
//             SPACE=(TRK,(5,2)),UNIT=SYSDA
//SYSIN    DD  DUMMY

Here the system runs the load module named IEBGENER. DD statements connect the names expected by IEBGENER to input, output, messages, and control data. The PGM value names the program; it is not a source member or a compile command.

Use PGM= when the step should run one known program and the full DD setup belongs in the submitted job. The mainframe utilities guide lists common IBM utility program names.

Call a procedure with EXEC PROC

//RUNRPT  EXEC PROC=RPTPROC,ENV=PROD

//* Equivalent positional form:
//RUNRPT2 EXEC RPTPROC,ENV=TEST

Both statements invoke a procedure named RPTPROC. PROC= is explicit; the positional form is shorter and is widely used. A procedure can hold several EXEC and DD statements, so one job-level EXEC can expand into multiple procedure steps.

The ENV value in this example is a symbolic parameter only if RPTPROC defines or uses that symbol. Symbolic parameters are substituted while JCL is converted; they are different from PARM=, which passes data to a running program. See the JCL cataloged procedure guide for PROC, JCLLIB, symbols, and DD overrides.

Pass options with the PARM parameter

//COMPILE EXEC PGM=IGYCRCTL,PARM='LIB,LIST,MAP'

//RUNPGM  EXEC PGM=MYPROG,PARM='MODE=BATCH'

PARM= passes a character string to the program for that step. The program must be written to receive and interpret it, so valid values depend on that program's documentation. Quotes are needed when a value contains commas, blanks, or other JCL-significant characters.

The normal JCL PARM limit is 100 characters, excluding the enclosing delimiters. Some products provide a DD-based option mechanism for longer input. Do not assume that an arbitrary program accepts PARMDD or another alternate DD name.

PROC override: qualify PARM with the internal procedure step name when necessary. For example, //C1 EXEC COBPROC,PARM.COMP='LIST,MAP' changes PARM for the procedure step named COMP.

Skip a step with the COND parameter

//STEP1   EXEC PGM=PROGA
//STEP2   EXEC PGM=PROGB,COND=(4,LT,STEP1)

The comparison asks whether 4 is less than STEP1's return code. If STEP1 returns 8, the comparison is true and STEP2 is bypassed. If STEP1 returns 0 or 4, the comparison is false and STEP2 can run. This reverse-looking behavior is the main source of COND mistakes: a true EXEC COND test means skip the step.

An EXEC statement can contain up to eight COND comparisons. For new multi-branch logic, IF, THEN, and ELSE often state the intended run condition more directly. The JCL COND parameter tutorial covers operators, EVEN, ONLY, and return-code examples.

Do not read COND as “run when true.” First evaluate the coded comparison; if it is true, bypass the step. Also check whether a preceding abend affects later step processing.

Set storage with REGION

//REPORT EXEC PGM=RPTPGM,REGION=0M

//SMALL   EXEC PGM=OLDPROG,REGION=8M

REGION= controls the storage made available to a job step, subject to system and installation controls. Many sites use REGION=0M to request the available limit rather than an artificially small value, but local standards decide what is acceptable.

REGION can be coded on JOB or EXEC. IBM states that a REGION value on the JOB statement overrides one on an EXEC statement. When a storage failure occurs, check both statements and the site's exits or limits before increasing the step value.

Override an EXEC parameter inside a procedure

To change one internal procedure step, append a dot and that procedure step name to the keyword:

//RUNPROC EXEC PROC=PROCA,
//             TIME.STEP1=2,
//             PARM.STEP2='ABCD'

This sets TIME for procedure step STEP1 and PARM for procedure step STEP2. Other keywords on those internal EXEC statements remain in effect unless the override replaces them or they conflict with the overriding value.

Do not qualify the keyword with the calling job step name. Use the name of the EXEC statement inside the procedure. Likewise, a DD override uses procstep.ddname after the procedure call.

How z/OS finds the program

For EXEC PGM=MYPROG, the system must locate an executable module in an accessible program library. A step-level STEPLIB DD or job-level JOBLIB DD can identify private libraries; z/OS also searches its configured system libraries. Follow local standards because authorized program libraries and search order are site controlled.

//RUNAPP  EXEC PGM=MYPROG
//STEPLIB DD  DSN=APP.PROD.LOAD,DISP=SHR
//SYSOUT   DD  SYSOUT=*

If MYPROG cannot be found, an S806 abend is a common result. Check the PGM spelling, confirm that the member is a load module or program object, inspect STEPLIB or JOBLIB names and concatenation order, and verify access to the library. S806 is an execution-time module-location failure, not a compilation message.

Common EXEC statement errors

SymptomLikely check
JCL error before executionCheck commas, continuation alignment, duplicate step names, keyword spelling, and whether PGM or a procedure name is present.
S806 abendCheck PGM spelling and whether the module is available through STEPLIB, JOBLIB, or system libraries.
Procedure not foundCheck the procedure name and the JES procedure libraries or JCLLIB ORDER statement.
Program ignores PARMConfirm that the program accepts the exact string and delimiters supplied.
Step unexpectedly skippedEvaluate every COND comparison against earlier return codes; true means bypass.
Override has no effectUse the internal procedure step name after the keyword, such as PARM.COMP.

EXEC coding checklist

  • Give each step a short, meaningful, unique name.
  • Use exactly one program or procedure form on the statement.
  • Verify the program or procedure name against the target environment.
  • Keep PARM syntax within the called program's documented rules.
  • Read COND as a bypass test and trace the earlier return codes.
  • Qualify procedure overrides with the internal procedure step name.
  • Confirm the DD statements expected by the selected program or procedure.
  • Review JES messages and the job log when conversion or execution fails.

For the complete JOB, EXEC, and DD relationship, use the JCL tutorial with examples. For JES control statements outside normal JOB/EXEC/DD syntax, see the JCL JECL quick reference.

Official IBM references

JCL EXEC statement FAQ

What does the EXEC statement do in JCL?

It begins a job step and identifies either the program or the in-stream or cataloged procedure that z/OS is to run for that step.

What is the difference between EXEC PGM and EXEC PROC?

EXEC PGM names one executable program. EXEC PROC names a reusable JCL procedure, which can contain one or more internal steps and their DD statements.

When does JCL COND skip an EXEC step?

For an EXEC COND return-code test, z/OS bypasses the step when any coded comparison evaluates true. IF, THEN, and ELSE are often clearer for new conditional logic.

What usually causes an S806 abend on an EXEC step?

S806 normally means the requested load module could not be found in an accessible program library. Check the PGM spelling and the applicable STEPLIB, JOBLIB, and system library setup.

Start with the simplest valid form—//stepname EXEC PGM=program—then add only the PARM, COND, REGION, or procedure overrides that the step actually needs.

No comments:

Post a Comment