The EXEC statement is a crucial component of JCL (Job Control Language) as it specifies the execution of a program or a procedure. This statement tells the system what program to run and how to run it. Understanding the EXEC statement is essential for creating effective JCL jobs.
Key Concepts
- Purpose: The EXEC statement is used to execute a program or a procedure within a JCL job.
- Syntax: The basic syntax of the EXEC statement is:
or//name EXEC PGM=program-name
//name EXEC PROC=procedure-name
- Parameters: The EXEC statement can include various parameters to control the execution environment.
Basic Structure
Executing a Program
To execute a program, you use the PGM
parameter:
STEP1
: The name of the step.PGM=IEFBR14
: Specifies the program to be executed.IEFBR14
is a utility program that does nothing and is often used for testing.
Executing a Procedure
To execute a procedure, you use the PROC
parameter:
STEP2
: The name of the step.PROC=MYPROC
: Specifies the procedure to be executed.MYPROC
is a predefined procedure.
Common Parameters
PARM
The PARM
parameter is used to pass parameters to the program being executed:
PARM='parameter-string'
: Passes the specified string to the programMYPROG
.
ACCT
The ACCT
parameter is used for accounting purposes:
ACCT='12345'
: Specifies the account number for billing or tracking purposes.
TIME
The TIME
parameter specifies the maximum amount of CPU time the step can use:
TIME=1440
: Allows the step to run for a maximum of 1440 minutes (24 hours).
REGION
The REGION
parameter specifies the amount of memory available to the step:
REGION=4M
: Allocates 4 megabytes of memory to the step.
Practical Example
Here is a practical example of an EXEC statement within a JCL job:
//MYJOB JOB 'ACCT123',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID //STEP1 EXEC PGM=IEFBR14 //STEP2 EXEC PGM=MYPROG,PARM='TEST',TIME=5,REGION=2M
MYJOB
: The name of the job.STEP1
: Executes theIEFBR14
program.STEP2
: Executes theMYPROG
program with the parameterTEST
, a maximum CPU time of 5 minutes, and 2 megabytes of memory.
Exercises
Exercise 1: Basic EXEC Statement
Write a JCL job that executes the IEFBR14
program in a step named INIT
.
Solution:
Exercise 2: EXEC Statement with Parameters
Write a JCL job that executes a program named MYPROG
with the parameter RUN
, a maximum CPU time of 10 minutes, and 3 megabytes of memory.
Solution:
//MYJOB JOB 'ACCT123',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID //STEP1 EXEC PGM=MYPROG,PARM='RUN',TIME=10,REGION=3M
Common Mistakes and Tips
- Misspelling Parameter Names: Ensure that parameter names like
PGM
,PROC
,PARM
,TIME
, andREGION
are spelled correctly. - Incorrect Parameter Values: Verify that the values provided for parameters are valid and within acceptable ranges.
- Omitting Required Parameters: Some programs or procedures may require specific parameters. Always check the documentation for requirements.
Conclusion
The EXEC statement is fundamental in JCL for specifying the execution of programs and procedures. By understanding its syntax and parameters, you can control how your jobs run and manage resources effectively. Practice writing EXEC statements with different parameters to become proficient in JCL job creation.
JCL (Job Control Language) Course
Module 1: Introduction to JCL
Module 2: JCL Statements and Syntax
Module 3: Data Definition (DD) Statements
Module 4: Procedures and Symbolic Parameters
Module 5: Advanced JCL Concepts
- Conditional Processing
- JCLLIB and INCLUDE Statements
- Generation Data Groups (GDGs)
- Restart and Checkpoint
Module 6: Error Handling and Debugging
- Common JCL Errors
- Interpreting JCL Error Messages
- Debugging Techniques
- Using JES2/JES3 for Troubleshooting