JOB and EXEC statements - IBM Mainframe

In this chapter we will discuss the parameters that are common to both JOB and EXEC statements. A JOB statement is used to specify information related to the job being submitted, while and EXEC statement is used to specify information related to the program or procedure that is being executed.

If storage is limited, then the operating system can be instructed to assign only a specific amount of storage for a job or job step. We have seen condition codes in the earlier chapter. Condition codes are generated at the end each job step, and indicates the status of the job. A job often contains several job steps, and sometimes the input of one job step is the output of a previous step. So we need to know whether the first job step was executed successfully or not. The operating system can be instructed on what to do, based on the condition code generated at the end of a job or each job step, thereby controlling the execution of subsequent jobs/job steps. CPU time is always valuable and it is be necessary to limit the amount of time that a job of job step is allowed to utilize. The operating system can be instructed as to how much time it should allow a job or job step to execute before it is terminated.

The instructions to the operating system regarding storage,conditional execution and time can be achieved by using the following parameters in the JOB & EXEC statements:

  • REGION coded in JOB statement - storage space for all job steps.
  • REGION coded in EXEC statement - storage space for specified job step.
  • COND coded in JOB statement - check condition codes of all job steps.
  • COND coded in EXEC statement - checks condition code of a specified job step.
  • TIME coded in JOB statement - amount of time that a job can utilize.
  • TIME coded in EXEC statement - amount of time a job step can utilize.

The REGION Parameter

At the time that a job is run, a default amount of workspace is automatically assigned to it. The default can be overridden by using the REGION parameter. You must specify enough storage space for the job or job step that is being submitted, otherwise your job will abend. The syntax of the REGION parameter can be in one of the following formats:

  • REGION=valuelK
  • REGION=value2M

Where valuel is the storage in multiples of 1024 bytes and value2 is storage in multiples of one million bytes. The 'K' and 'M* must follow valuel or value2, REGION is an optional keyword parameter. If storage is specified in the 'K' format, then the value can be up to 7 digits long. If storage is specified in the 'M* format, then the value can be up to 4 digits. If REGION is specified in the 'K' format, then ft should be specified as an even- number. If it is not even, the system will automatically round it off. If REGION is specified in the 'M' format, then an even or odd number can be specified. If REGION is coded on both the JOB and EXEC statements, the REGION specification on the JOB statement will override that on the EXEC statement. If this parameter is omitted, a default region is assigned. All available storage is assigned to the job or job step, if REGION is coded as REGION =0K or REGION=0M.

The COND Parameter

Each step within a job sends a return code to the system upon completion. This is called the condition code. A condition code of 00 is returned upon successful completion of each job step. A non-zero condition code means unsuccessful completion of the job step. Sometimes, the execution of one job step depends upon the successful execution of a prior job step. The COND parameter is used to control the execution of subsequent job steps, depending on the condition code that is returned for a prior job step.

For example, consider a job with two steps. The first step backs up a file, and the second deletes the source file, if the back up operation is successful. If the file is not backed up successfully, it should not be deleted. The COND parameter can be used to control the execution of the second step based on the first step.

A return code is a number between 0 and 4095, and is issued by the system just before a program finishes executing. It is highly recommended that all executing programs issue meaningful return codes based on IBM established conventions. Some of the most common return codes are given below:

  • 0 - implies successful completion of the job step.
  • 4 - implies that warning messages have been issued to the job step
  • 8 - implies a serious error in the job step
  • 16 - implies a fatal error in the job step and execution of subsequent job step is halted.

A COND parameter coded on the JOB statement applies to all job steps within that job, and it overrides COND parameters coded on the EXEC statement, if they exist.

The syntax of the COND parameter is COND= (comparison-code, condition), where comparison-code is number between 0 and 4095, and condition specifies the type of comparison to be made between the comparison-code that has been coded, and the return code of the prior step. You can specify more than one condition code within sets of parentheses. Each condition is OR'ed with the next. The valid operators are listed below: C

  • T - Bypasses current step if comparison-code is greater than return code.
  • GE - Bypasses current step if comparison-code is greater than or equal to the return code.
  • LT - Bypasses current step if comparison-code is less than return code.
  • LE - Bypasses current step if comparison-code is less than or equal to the return code.
  • EQ - Bypasses current step if comparison-code is equal to the return code.
  • NE - Bypasses current step if comparison-code is not equal to the return code.

In the above example, assume that the step one (SEGS1) executes successfully. It will return a code of zero. Since the comparison code ^4) is not less than the retune code (0), the next step (SEGS2) will execute. Now if the SEGS2 returns a code of 004. Since the comparison code (4) is not less than the retune code (004), the next step (SEGS3) will also be executed.

In the above example, if the return code is less than 4 or return code is greater than 9 the job step SEGS2 will be skipped and the job will be terminated.

The COND parameter coded in the EXEC statement applies only to the job step that it is coded in. The job step is executed or bypassed, depending on the condition codes issued by one or more prior job steps. The COND parameter in the EXEC statement can be in any of the following formats:

  • COND=(comparison-code, condition)
  • COND=(comparison-code, condition, stepname, ..)
  • COND=(comparison-code, condition, stepname, EVEN)
  • COND=(comparison-code, condition, stepname, ONLY)

The syntax of the COND parameter coded on the EXEC statement is similar to that coded on the JOB statement, except for a few optional additional parameters. Comparison-code as before is a number between 0 and 4095. Condition specifies the type of comparison to be made between the comparison-code that has been coded, and the return code of the prior step. The designations for condition are the same as for the JOB statement.

Stepname specifies the name of the preceding step whose return code is to be checked. If the test is true, then the job step that contains the COND parameter will be bypassed. If the test is not true the job step will be executed. The keyword EVEN is used to specify that the stepname specified is to execute, even if any prior steps terminate, abnormally. The keyword ONLY is used to specify that the stepname specified must be executed only if any prior steps have terminated abnormally.

In the above example, the COND parameter is used to specify that SEGS2 should be bypassed if 8 is equal to the return code issued by SEGS1.

In this example we are specifying that SEGS3 should be bypassed if 8 is greater than or equal to the return code issued by any of the prior job steps. In addition to this, SEGS2 is to be bypassed is 80 is less than or equal to the return code issued by SEGS1. Thus, a return code less than 8 or greater than 80 will result in step 3 being executed.

In the above example, the keyword EVEN is used to specify that the step SEGS2 is to be executed even if any previous steps terminate abnormally.

In the above example, the keyword ONLY is used to specify that the step SEGS2 is to be executed only if SEGS1 terminates abnormally.

If the condition parameter is not coded in the JOB or EXEC statements, then all the steps will be executed, regardless of the return codes of the prior step. This could prove to be dangerous and undesirable under some circumstances. A successful test for the COND parameter coded on the JOB statement results in all subsequent steps being bypassed. A successful test for the COND parameter coded on the EXEC statement results only in that job step being bypassed. Often, you only want to bypass a step, as opposed to bypassing the entire job. If the COND parameter is coded on the JOB statement as well as the EXEC statement, then the specification on the JOB statement nullifies the specification on the EXEC statement.

The TIME Parameter

This is an optional keyword parameter and is used to specify the amount of CPU time that a job or job step is permitted to utilize before it is terminated. Note that this parameter specifies the CPU time and not the clock time, system time or wait time. CPU time is the time that a job takes to execute. System time is the same as clock time. Wait time is the time that a job waits for I/O devices in order to execute.

If this parameter is coded on the JOB statement, it specifies the amount of CPU time that the job is allowed to use. If it is defined on the EXEC statement, it specifies the amount of CPU time that the job step is allowed to use. If this parameter is not specified, then the installation defined TIME parameter is used.

When coding the TIME parameter, always estimate a little more time than you expect your job to take. A job that exceeds the specified time limit, regardless of whether the TIME parameter is coded on the JOB or EXEC statement, will results in its termination. The TIME parameter can have any of the following formats:

  • TIME-minutes
  • TIME= (minutes, seconds)
  • TIME=(, seconds)

Where minute is a number from 1 to 1439 (24 hrs.) and second is a number from 1 to 59. If you code only the minutes field the seconds defaults to zero. If you code only the seconds field the minutes defaults to zero. Coding TIME=0, will result in unpredictable behavior, and it is recommended that you avoid coding it this way.

If the TIME parameter is coded on the JOB statement as well as the EXEC statement, then the specification on the EXEC statement nullifies the specification on the JOB statement.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM Mainframe Topics