Controlling program execution with 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.
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:
12//stepname EXEC PGM=program-name,PARM='parameter-string' //stepname EXEC PGM=program-name,PARM=(parameter-string)
Key points about the PARM parameter:
Example:
12//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.
1//STEP1 EXEC PGM=REPORT,PARM='Don''t print headers'
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:
123//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 checkEVEN
- Execute the step even if a previous step abnormally terminatedONLY
- Execute the step only if a previous step abnormally terminatedExamples:
12345//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:
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:
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.
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:
12345//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:
Examples:
123//STEP1 EXEC PGM=QUICKPGM,TIME=2 //STEP2 EXEC PGM=LONGPGM,TIME=(10,30) //STEP3 EXEC PGM=BATCHPGM,TIME=NOLIMIT
In this example:
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:
1234//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:
Examples:
123//STEP1 EXEC PGM=SMALLPGM,REGION=4M //STEP2 EXEC PGM=MEDIUMPGM,REGION=64M //STEP3 EXEC PGM=BIGPGM,REGION=0M
In this example:
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.
The ADDRSPC parameter specifies whether the step is to execute in a real or virtual storage environment.
Syntax:
12//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 storageExample:
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.
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:
1//stepname EXEC PGM=program-name,DYNAMNBR=number
Key points about the DYNAMNBR parameter:
Example:
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.
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:
12//stepname EXEC procname,parameter=value //stepname EXEC procname,procstep.parameter=value
Key points about parameter overrides:
Example of a procedure:
1234//MYPROC PROC //STEP1 EXEC PGM=PROG1,REGION=4M,TIME=2 //STEP2 EXEC PGM=PROG2,REGION=6M,TIME=5 // PEND
Examples of overriding parameters:
1234//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:
Example 1: Sort Program with Parameters
1234//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
1234//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
1234//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.
EXEC statement parameters provide powerful capabilities for controlling program execution, procedure invocation, and resource allocation. By understanding and using these parameters effectively, you can:
These parameters, when used appropriately, can significantly enhance the flexibility, efficiency, and robustness of your JCL.
Write JCL for each of the following scenarios: