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

  1. Purpose: The EXEC statement is used to execute a program or a procedure within a JCL job.
  2. Syntax: The basic syntax of the EXEC statement is:
    //name EXEC PGM=program-name
    
    or
    //name EXEC PROC=procedure-name
    
  3. 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    EXEC PGM=IEFBR14
  • 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    EXEC PROC=MYPROC
  • 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:

//STEP1    EXEC PGM=MYPROG,PARM='parameter-string'
  • PARM='parameter-string': Passes the specified string to the program MYPROG.

ACCT

The ACCT parameter is used for accounting purposes:

//STEP1    EXEC PGM=MYPROG,ACCT='12345'
  • 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:

//STEP1    EXEC PGM=MYPROG,TIME=1440
  • 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:

//STEP1    EXEC PGM=MYPROG,REGION=4M
  • 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 the IEFBR14 program.
  • STEP2: Executes the MYPROG program with the parameter TEST, 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:

//MYJOB    JOB  'ACCT123',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//INIT     EXEC PGM=IEFBR14

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, and REGION 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.

© Copyright 2024. All rights reserved