MainframeMaster

JCL Tutorial

EXEC Statement Parameters

Controlling program execution with parameters

Progress0 of 0 lessons

Introduction to EXEC Statement Parameters

EXEC statement parameters give you fine-grained control over how programs and procedures execute. These parameters let you pass data to programs, control step execution based on conditions, manage resource allocation, and override procedure parameters.

PARM Parameter

The PARM parameter allows you to pass information to a program when it executes. This parameter is often used to control program behavior by specifying options, values, or configuration settings.

Syntax:

jcl
1
2
//stepname EXEC PGM=program-name,PARM='parameter-string' //stepname EXEC PGM=program-name,PARM=(parameter-string)

Key points about the PARM parameter:

  • Parameters are passed as a single string to the program
  • The string must be enclosed in single quotes or parentheses
  • Maximum length is 100 characters
  • Structure depends on what the program expects
  • Programs access parameters via entry point registers

Example:

jcl
1
2
//STEP1 EXEC PGM=REPORT,PARM='DETAIL,SUMMARY,NOHEADINGS' //STEP2 EXEC PGM=SORT,PARM='FIELDS=(1,10,CH,A),SIZE=MAX'

Note:

If a parameter string contains a single quote, you must represent it as two consecutive single quotes within the string.

jcl
1
//STEP1 EXEC PGM=REPORT,PARM='Don''t print headers'

COND Parameter

The COND parameter specifies conditions under which a job step should be executed or skipped based on the completion codes of previous steps. This allows for conditional execution of job steps.

Syntax:

jcl
1
2
3
//stepname EXEC PGM=program-name,COND=(code,operator[,stepname]) //stepname EXEC PGM=program-name,COND=EVEN //stepname EXEC PGM=program-name,COND=ONLY

Components of the COND parameter:

  • code - Return code to compare against (0-4095)
  • operator - Comparison operator (GT, GE, EQ, LT, LE, NE)
  • stepname - Optional name of the step whose condition code to check
  • EVEN - Execute the step even if a previous step abnormally terminated
  • ONLY - Execute the step only if a previous step abnormally terminated

Examples:

jcl
1
2
3
4
5
//STEP1 EXEC PGM=PROG1 //STEP2 EXEC PGM=PROG2,COND=(4,LT) //STEP3 EXEC PGM=PROG3,COND=(0,NE,STEP1) //STEP4 EXEC PGM=PROG4,COND=EVEN //STEP5 EXEC PGM=PROG5,COND=ONLY

In this example:

  • STEP2 executes only if return code from the previous step is less than 4
  • STEP3 executes only if return code from STEP1 is not equal to 0
  • STEP4 executes even if a previous step abended
  • STEP5 executes only if a previous step abended

COND Logic:

The COND parameter works by specifying when to bypass a step. The step is skipped if any of the conditions are true.

For example, COND=(4,LT) means "bypass this step if the return code is less than 4" - so the step only runs if the return code is 4 or higher.

Multiple conditions can be specified:

jcl
1
//STEP3 EXEC PGM=PROG3,COND=((0,NE,STEP1),(4,LT,STEP2))

STEP3 will be bypassed if either STEP1 return code is not 0 OR STEP2 return code is less than 4.

TIME Parameter

The TIME parameter specifies the maximum amount of CPU time that a job step can use. This prevents steps from consuming excessive CPU resources due to programming errors or unexpected conditions.

Syntax:

jcl
1
2
3
4
5
//stepname EXEC PGM=program-name,TIME=minutes //stepname EXEC PGM=program-name,TIME=(minutes,seconds) //stepname EXEC PGM=program-name,TIME=1440 //stepname EXEC PGM=program-name,TIME=NOLIMIT //stepname EXEC PGM=program-name,TIME=MAXIMUM

Key points about the TIME parameter:

  • Specifies maximum CPU time (not elapsed time)
  • Can be specified as minutes only or minutes and seconds
  • TIME=1440 (24 hours) means no time limit
  • TIME=NOLIMIT means no time limit (z/OS)
  • TIME=MAXIMUM means installation-defined maximum

Examples:

jcl
1
2
3
//STEP1 EXEC PGM=QUICKPGM,TIME=2 //STEP2 EXEC PGM=LONGPGM,TIME=(10,30) //STEP3 EXEC PGM=BATCHPGM,TIME=NOLIMIT

In this example:

  • STEP1 is limited to 2 minutes of CPU time
  • STEP2 is limited to 10 minutes and 30 seconds of CPU time
  • STEP3 has no CPU time limit

REGION Parameter

The REGION parameter specifies how much memory (virtual storage) a job step can use. It helps control memory allocation to prevent a single job from consuming excessive resources.

Syntax:

jcl
1
2
3
4
//stepname EXEC PGM=program-name,REGION=nK //stepname EXEC PGM=program-name,REGION=nM //stepname EXEC PGM=program-name,REGION=0K //stepname EXEC PGM=program-name,REGION=0M

Key points about the REGION parameter:

  • Specifies memory in kilobytes (nK) or megabytes (nM)
  • REGION=0K or REGION=0M typically means maximum available region size
  • Actual allocation behavior is controlled by installation settings
  • Most modern installations use system exits to control actual region limits

Examples:

jcl
1
2
3
//STEP1 EXEC PGM=SMALLPGM,REGION=4M //STEP2 EXEC PGM=MEDIUMPGM,REGION=64M //STEP3 EXEC PGM=BIGPGM,REGION=0M

In this example:

  • STEP1 is limited to 4 megabytes of memory
  • STEP2 is limited to 64 megabytes of memory
  • STEP3 requests the maximum available memory

Best Practice:

In modern z/OS environments, REGION=0M is often the recommended setting unless there's a specific reason to limit memory. This allows z/OS to manage memory allocation based on system policies and prevents artificial constraints that might cause job failures.

ADDRSPC Parameter

The ADDRSPC parameter specifies whether the step is to execute in a real or virtual storage environment.

Syntax:

jcl
1
2
//stepname EXEC PGM=program-name,ADDRSPC=VIRT //stepname EXEC PGM=program-name,ADDRSPC=REAL

Values for ADDRSPC parameter:

  • VIRT (or V) - Virtual storage (default)
  • REAL (or R) - Real storage

Example:

jcl
1
//STEPREAL EXEC PGM=REALTIME,ADDRSPC=REAL

Modern Usage Note:

In modern z/OS environments, ADDRSPC=VIRT is the default and virtually all applications run in virtual storage. The REAL option is rarely used and may require special authorization. This parameter is primarily retained for compatibility with older systems.

DYNAMNBR Parameter

The DYNAMNBR parameter specifies the number of data definition (DD) statements that can be dynamically allocated by a program. This parameter is particularly important for TSO sessions and programs that use dynamic allocation.

Syntax:

jcl
1
//stepname EXEC PGM=program-name,DYNAMNBR=number

Key points about the DYNAMNBR parameter:

  • Specifies the number of DD statements that can be dynamically allocated
  • Default value is installation-defined (often 0)
  • Common values range from 10 to 100
  • Each dynamic allocation consumes system resources

Example:

jcl
1
//DYNAM EXEC PGM=ALLOCPGM,DYNAMNBR=20

This example allows the program ALLOCPGM to dynamically allocate up to 20 DD statements during execution.

Common Usage:

DYNAMNBR is commonly used in ISPF applications, REXX execs, and other programs that need to allocate datasets dynamically at runtime rather than having them predefined in the JCL.

Parameter Override Techniques

When invoking a cataloged or in-stream procedure, you can override the parameters specified in the procedure. This allows for customization of procedures without modifying the procedure itself.

Syntax for overriding EXEC parameters:

jcl
1
2
//stepname EXEC procname,parameter=value //stepname EXEC procname,procstep.parameter=value

Key points about parameter overrides:

  • Parameters specified on the EXEC statement override procedure defaults
  • You can override parameters for specific steps using the format procstep.parameter
  • You can add parameters not defined in the procedure
  • This allows flexibility while maintaining standard procedures

Example of a procedure:

jcl
1
2
3
4
//MYPROC PROC //STEP1 EXEC PGM=PROG1,REGION=4M,TIME=2 //STEP2 EXEC PGM=PROG2,REGION=6M,TIME=5 // PEND

Examples of overriding parameters:

jcl
1
2
3
4
//RUN1 EXEC MYPROC //RUN2 EXEC MYPROC,REGION=8M //RUN3 EXEC MYPROC,STEP1.REGION=8M,STEP2.TIME=10 //RUN4 EXEC MYPROC,STEP1.PARM='OPTION1,OPTION2'

In these examples:

  • RUN1 executes the procedure with all default parameters
  • RUN2 overrides the REGION parameter for all steps to 8M
  • RUN3 overrides REGION for STEP1 to 8M and TIME for STEP2 to 10 minutes
  • RUN4 adds a PARM parameter to STEP1 that wasn't in the original procedure

Practical Examples of EXEC Parameters

Example 1: Sort Program with Parameters

jcl
1
2
3
4
//SORT EXEC PGM=SORT, // PARM='SORT FIELDS=(1,10,CH,A),SIZE=MAX', // REGION=64M, // TIME=5

This job step executes the SORT program with parameters specifying the sort fields and maximum size. It allocates 64MB of memory and limits execution to 5 minutes of CPU time.

Example 2: Conditional Execution Based on Previous Steps

jcl
1
2
3
4
//EXTRACT EXEC PGM=EXTRACTOR //SORT EXEC PGM=SORT,COND=(0,EQ,EXTRACT) //REPORT EXEC PGM=REPORTER,COND=((0,EQ,EXTRACT),(0,EQ,SORT)) //CLEANUP EXEC PGM=CLEANUP,COND=EVEN

In this example, SORT executes only if EXTRACT completed with return code 0. REPORT executes only if both EXTRACT and SORT completed with return code 0. CLEANUP executes regardless of whether previous steps failed or completed successfully.

Example 3: Overriding Parameters in a Procedure

jcl
1
2
3
4
//PAYROLL EXEC PAYPROC, // STEP1.PARM='REGION=EAST,DEPT=SALES', // STEP2.REGION=96M, // STEP3.TIME=30

This example executes a procedure called PAYPROC, overriding the PARM for STEP1, the REGION for STEP2, and the TIME for STEP3.

Best Practices for EXEC Parameters

  • Use PARM to pass configuration options rather than hardcoding them in programs
  • Use COND parameters to create robust job flows that handle errors appropriately
  • Set TIME limits to prevent runaway jobs from consuming excessive resources
  • Use REGION=0M unless there's a specific reason to limit memory
  • Design procedures with default parameters that can be overridden
  • Document parameter requirements and valid values in job documentation

Summary

EXEC statement parameters provide powerful capabilities for controlling program execution, procedure invocation, and resource allocation. By understanding and using these parameters effectively, you can:

  • Pass data to programs using PARM
  • Control conditional execution using COND
  • Manage CPU time consumption with TIME
  • Control memory allocation with REGION
  • Manage address space type with ADDRSPC
  • Control dynamic allocation with DYNAMNBR
  • Override procedure parameters for flexibility

These parameters, when used appropriately, can significantly enhance the flexibility, efficiency, and robustness of your JCL.

Practice Exercise

Write JCL for each of the following scenarios:

  1. Execute a program named ANALYZER that takes region parameters as input, allocating 128MB of memory
  2. Execute a procedure named DAILYPROC, but override the TIME parameter for a step named REPORT to 15 minutes
  3. Create a job with three steps where the third step only executes if both previous steps completed with a return code of 0