Monday, March 8, 2010

3. The EXEC Statement

An EXEC statement identifies a step during the reading the reading process when a job is submitted to the system. When an EXEC is found, the system accepts all JCL statements that follow as belonging to the step, until a delimiter is found. There are four possible delimiters for a step during the reading process :
• Another EXEC statement in the input stream. It signals the end of (reading) one step and the beginning of (reading) of another.
• A JOB statement
• A null statement i.e //. All JCL statements will be ignored except for a JOB statement.
• End-of-file on the reading device, meaning there are no more statements to read.




General Syntax

//[stepname] EXEC parameters
stepname is optional. When the stepname is omitted no reference can be made. A job can contain a maximum of 255 steps.

The PGM Parameter
The PGM parameter identifies the program to be executed in a step.

General Syntax
PGM=pgmname positional parameter

Pgmname - Name of the program to be fetched from the loadlibrary and executed.

The program specified in PGM is always a member of library (PDS). This is commonly known as an executable program library or a load library. The EXEC statement can identify only the member. It has no parameter available to identify the library. If necessary, this must be done by using a JOBLIB or a STEPLIB DD statement.

E.g.3.1

//da0001ta job la2719,pcs,msglevel=(1,1),notify=&sysuid
//joblib dd dsn=da0001t.lib.loadlib=shr
//s1 exec pgm=ass1

OR

//da0001ta job la2719,pcs,msglevel=(1,1),notify=&sysuid
//s1 exec pgm=ass1
//steplib dd dsn=da0001t.lib.loadlib=shr

If neither JOBLIB or STEPLIB is coded, the system searches certain predefined libraries. They are the system default libraries. If the specified member is found, it is executed. If not found, the result is S806-04 ABEND failure.

The following keyword parameters can be specified at the EXEC statement. They are REGION, ADDRSPC, TIME , PARM and ACCT.

The REGION Parameter

This parameter specifies the limit of available storage for the step within the job’s address space.

General Syntax

REGION=value{K|M} keyword parameter
Value – 1 to 2096128 if K (1024 bytes) is used. It should be an even number, it will be rounded to the next higher even number.

Value – 1 to 2047 if M (1024K or 1048576 bytes) is used. M is not available to MVS/SP, only to MVS/XA and MVS/ESA

If the REGION parameter is omitted , the REGION parameter in the EXEC statements within the job will be used. If it is coded in neither the JOB nor the EXEC statement, an installation-defined default will be used. The default value of most installations is between 500K and 1000K.
If the REGION parameter is coded in both the JOB and an EXEC statement within the job, the value in the JOB statement will be used.
The REGION parameter in the JOB statement is used much more often than the one in the EXEC statement. Coding the same value for all steps would have the same effect as the REGION parameter in the JOB statement.

E.g. 3.2

//da0001ta job la2719,pcs,msglevel=(1,1),notify=&sysuid
//s1 exec pgm=ass1,region=500k
//steplib dd dsn=da0001t.lib.loadlib=shr


The TIME parameter

This parameter specifies the total amount of CPU time that the step is allowed to use.

General Syntax

TIME=([minutes][,seconds] | [1440]) keyword parameter

minutes - a number from 1 to 1439
seconds – a number from 1 to 59

1440 - The step will not be timed for CPU. It was also not “time out” (S522 ABEND failure) when a single wait state exceeds the installation-defined limit (often 10 to 20 minutes). Note that TIME=1440 is rarely used, and most installation disallow its use in a testing environment. TIME=1440 should be used by an on-line system like CICS OR ADS/O.

When the TIME parameter is omitted, an installation-defined default will be used. This default is usually very high and unlikely to cause an S322 ABEND failure.
If the TIME parameter is also coded in the JOB statement, both will be in effect and either can cause a S322 ABEND failure. It is not advisable to use them both.

Remark :
It is possible for a step to get more CPU time than that is specified in the TIME parameter or the default by a maximum 10.5 seconds. This is due to the fact that the system checks for violations every 10.5 seconds.

E.g 3.3


//da0001ta job la2719,pcs,msglevel=(1,0),notify=&sysuid
//s1 exec pgm=ass1,region=500k,time=(,3)
//steplib dd dsn=da0001t.lib.loadlib=shr



The ADDRSPC parameter

This parameter specifies if the step will use real or virtual storage.

General syntax

ADDRSPC={VIRT|REAL}
VIRT – The REGION will be virtual storage and is the default
REAL – The REGION will be real storage.

If the ADDRSPC parameter is also coded in the JOB statement, the value in the JOB will be used.

Remark:
This is the rarely used parameter because of the default. Note that ADDRSPC=REAL is a parameter that is disallowed in practically all installation because it can cause serious performance problems for other jobs.

The ACCT Parameter

The parameter specifies accounting information to be used for the step as opposed to the accounting information in the JOB statement.



General Syntax

ACCT=(acctno [additional-acct-info]) keyword parameter

Acctno – The account number to be used for the step
Additional-acct-info – same as in the JOB statement.

The ACCT parameter is seldom used, and when it is, only the account number normally appears. This is used to charge resource utilization for a step to a different account number other than the one coded in the JOB statement.

If an account number is also coded in the JOB statement, the account number in the EXEC statement will be used.

E.g 3.4

//da0001ta job la2719,pcs,msglevel=(1,0),notify=&sysuid
//s1 exec pgm=iefbr14,acct=(‘es0013,hr4200,iefbr14’)
//dd1 dd dsn=da0001t.pai.empfile,disp=(mod,delete),
// space=(trk,0),unit=sysda



The PARM Parameter

This parameter provides a way to supply data of limited size to the executing program

General Syntax
PARM=string keyword parameter

String –A string of characters up to 100. If commas are part of the string, the entire field must be enclosed in parenthesis (or apostrophes). If any portion of the string contains special characters (other than hyphen), that portion of the entire string must be enclosed in apostrophes. Note that any parenthesis used count toward the maximum. Apostrophes do not.

All information after the “=” in the PARM parameter, excluding apostrophes, will be saved by the system within the step’s own region. When the program begins execution by using the appropriate instructions, it can find the saved information in storage.

In COBOL, the following must be coded :

LINKAGE SECTION.
01 PARM.
05 PLENGTH PIC S9(04) COMP.
05 INFO PIC X(05).
PROCEDURE DIVISION USING PARM.
0000-MAIN-PARA.

Note that any valid name may be used in place of PARM. The string is stored in PARM and the PLENGTH is set to the length of the string.



E.g 3.5

//da0001ta job la2719,pcs,msglevel=(1,1),notify=&sysuid
//s1 exec pgm=ass2,parm=’g2 ‘,time=(,3)
//steplib dd dsn=da0001t.lib.loadlib=shr


Rules for continuation

E.g 3.6

//da0001ta job la2719,pcs,msglevel=(1,1),notify=&sysuid
//cob exec pgm=ikfcbl00,region=1024k,
// parm=(‘notrunc,nodynam,lib,size=4096k,buf=116k’,
// ‘apost,nores,seq’)
.
.
or

//da0001ta job la2719,pcs,msglevel=(1,1),notify=&sysuid
//cob exec pgm=ikfcbl00,region=1024k,
// parm=(notrunc,nodynam,lib,’size=4096k’,’buf=116k’,
// apost,nores,seq)
.
.
Note that an expression in quotes cannot be continued, we need to enclose the string in parenthesis and field containing special characters in apostrophes.

E.g.2 PARM=’29/06/00’ or (‘29/06/00’)
E.g 3 PARM=(A,B,C,D) or ‘A,B,C,D’
The two, however , are not the same. When parentheses are used, the information found by the program is (A,B,C,D). If apostrophes are used, the information found by the program is A,B,C,D.


The COND Parameter

The COND parameter can be coded in the JOB as well as the EXEC statement. It is mostly used in the EXEC statement. The main tool for controlling the execution of steps within a job is the COND parameter.

A Return (or Condition) code

A return code is a number between 0 and 4095, issued by an executing program just before its execution is finished. It is intended to identify an important event found (or not found) during the execution. For example, a program may issue a return code of 21 to indicate that a problematic event (such as a record is out of sequence) was detected during the execution or a return code of 0 to indicate that the execution was trouble free. The return code issued by a program is saved by the system for the duration of the job. Any subsequent step of the same job can interrogate this return code by using the COND parameter either in the JOB or EXEC statement. The result of this interrogation is to permit or bypass the execution of the step. Note that the return code is never available to a job other than the one issued it. In other words, the step that interrogates the return code must be in the same job as, and subsequent to, the step that issued it.

IBM-established conventions.
• Return code of 0 indicates a complete success.
• Return code of 4 indicates a warning. The warning is benign, so a return code will normally be treated as acceptable.
• Return code of 8 indicates a questionable results.
• Return code of 12 indicates bad results.
• Return code of 16 indicates a terminal condition.

The COND Parameter in the JOB statement.

The COND Parameter can perform a test (or multiple tests) at the beginning of each step against the return (condition) codes issued by the previous steps. If a test is satisfied , none of the steps from that point on will be executed.

General Syntax

COND=((code,operator) [,(code,operator)]…….) keyword parameter
Code - is a number between 0 and 4095
Operator – provides a comparison between a return code and the code. There are six operators : LT, LE, NE, EQ, GT, GE

There can be a maximum of eight tests in the COND parameter. Condition is evaluated from left to right and if a test is satisfied, the job stops execution at that point.

An example can best illustrate the mechanism of the COND parameter. Consider a job with five steps. Assume that none will ABEND.

//da0001ta job la2719,pcs,cond=((12,lt),(8,eq))

STEP1 issues a return code of 0
STEP2, if executed, issues a return code of 4
STEP3, if executed, issues a return code of 16
STEP4, if executed, issues a return code of 0
STEP5, if executed, issues a return code of 4
(warning : This example does not adhere to conventions.)

STEP 1 is executed by default, since no previous return codes exist and hence, the COND parameter in the JOB statement will be ignored for the first step.

Before STEP2 begins execution, the system interrogates the existing return code (0), using the tests in the COND parameter and reading the test from left to right,
• Is 12 less than 0? The answer is “no”. The first test of the COND parameter was not satisfied. The second test is tested.
• Is 8 equal to 0? . The answer is “no”. Neither of the two tests was satisfied, and therefore, STEP2 is executed.

Before STEP3 begins execution, the system interrogates the existing return codes (0 and 4), using the tests in the same COND parameter. Since the result for return code 0 is already known, only 4 will be tested :
• Is 12 less than 4? The answer is “no”. The first test of the COND parameter was not satisfied. The second test is tested.
• Is 8 equal to 4 . The answer is “no”. Neither of the two tests was satisfied, and therefore, STEP3 is executed.

Before STEP4 begins execution, the system interrogates the existing return codes (0 , 4 and 16), using the tests in the same COND parameter. Since the results for return code 0 and 4 are already known, only 16 will be tested :
• Is 12 less than 16? The answer is “yes”. The first test of the COND parameter was satisfied. There is no need for the second test . Executions of the job stops. STEP 4 and the remaining steps will not be executed.

A message will appear in the output:
IEF2011 DA0001TA STEP4-JOB TERMINATED BECAUSE OF CONDITION CODES.

A formula can be devised and used to code the COND parameter, if return code conventions are strictly adhered to :
COND=(last-good-return-code,LT)
Or
COND=(first-bad-return-code,LE)

Let us apply this formula to this example 0-4 is a good return code :
4 -is the last good return code….COND=(4,LT)
or
5 - is the first bad return code…..COND=(5,LE)
The two COND parameters are logically equivalent to each other, and it makes no difference which one is used.

Exercise : Code the COND parameter, where 0 is the only good return code.

The COND parameter in the EXEC statement
The COND parameter can perform a test (or multiple tests) before a step begins execution against the return (condition) codes issued by previous steps. If a test is satisfied, the step will not be executed.

General Syntax

COND=((code,operator[,stepname])[,(code,operator[,stepname])]……[,EVEN|ONLY]) keyword parameter

Code - is a number between 0 and 4095

Operator – provides a comparison between a return code and the code. There are six operators : LT, LE, NE, EQ, GT, GE
Stepname – Identifies the name of the preceding step whose return code will be interrogated. It can also appear as two names procexec.stepname where “procexec” identifies the name of the EXEC statement invoking a procedure and “stepname” the stepname within the procedure.
EVEN - requests that execution be permitted even though a previous (any previous) step has ABENDed.
ONLY - requests that execution be permitted only if a previous (any previous) step has ABENDed.

There can be a maximum of eight tests in the COND parameter. EVEN or ONLY counts toward eight. Condition is evaluated from left to right and if a test is satisfied, only that step is not executed.


Remark :
• EVEN and ONLY cannot make reference to a particular step. They refer to any previous step that has ABENDed.
• EVEN and ONLY are mutually exclusive
• EVEN and ONLY have no positional significance. Each can be coded anywhere in the COND parameter in relation to other tests
• Following an ABEND failure, a step cannot be executed unless it contains EVEN or ONLY in the COND parameter of its EXEC statement
• The first step will always be executed unless COND=ONLY appears in the exec statement. COND=ONLY would cause the first step to be bypassed, since no previous ABEND failures could have occurred. Any other COND parameter in the first EXEC statement will be ignored (i.e., COND=(4,LT) or COND=EVEN) or will result in JCL error (i.e., COND=(5,LT,stepname)) – since there are no previous step.
• A step that is not executed issues no return code because a program responsible for for issuing the return code was not even loaded into the storage. As a result no return code exists. An attempt to interrogate the return code of such a step in the COND parameter of a subsequent step will be ignored.
• A step that ABEND’s issues no return code because a program always issues a return code (conditionally or by default) if it reaches the end of its execution and intentionally returns control to the system. When an ABEND occurs, the program loses control instantly. And is evicted from from execution by the system. As a result when a step ABEND’s no return code exists ( a completion code exists). An attempt to interogate the return code of such a step in the COND parameter of a step will be ignored until it contains EVEN or ONLY.






An example can best illustrate the mechanism of the COND parameter. Consider a job with five steps. This is a class room exercise.

//da0001ta job la2719,pcs,notify=&sysuid,msglevel=(1,1)
//s1 exec pgm=p1 (4)
//s2 exec pgm=p2,cond=((0,lt,s1),even) (12)
//s3 exec pgm=p3,cond=(8,lt,s2) (0)
//s4 exec pgm=p4,cond=(4,lt) (8)
//s5 exec pgm=p5,cond=((4,lt,s1),(0,lt,s3)) abend
//s6 exec pgm=p6,cond=(even,(0,le,s5),) (16)*
//s7 exec pgm=p7,cond=((0,lt,s1),even) (0)
//s8 exec pgm=p8,cond=((0,lt,s1),(12,lt,s3) ) (0)
//s9 exec pgm=p9,cond=only) (4)
//s10 exec pgm=p10,cond=only (0)


If the COND parameter is coded neither at the JOB nor at the EXEC statement, the step will be executed regardless of previous return codes. However it will not be if a previous step has ABENDed.

If the COND parameter is coded in both the JOB statement as well as an EXEC statement within the JOB. The COND parameter of the JOB statement is tested first. If none of its tests are satisfied, then the COND parameter of the EXEC statement is tested. If a test is satisfied, none of the steps from that point on will be executed.




This is a class room exercise.

//DA0001TA JOB LA2719,PCS,COND=(5,EQ),NOTIFY=DA0001T
//S1 EXEC PGM=P1 (4)
//S2 EXEC PGM=P2,COND=(7,LT) (ABEND)
//S3 EXEC PGM=P3,COND=((20,GT,S1),EVEN) (6)
//S4 EXEC PGM=P4,COND=(3,EQ),ONLY) (8)
//S5 EXEC PGM=P5,COND=(2,LT,S3) -
//S6 EXEC PGM=P6 -
//S7 EXEC PGM=P7,COND=((6,EQ,S5),ONLY) (5)
//S8 EXEC PGM=P8,COND=EVEN (0)
//S9 EXEC PGM=P9 -

Back to JCL Index
Back to home page

1 comment:

Anonymous said...

blog is use full but change d background color when seen tutorial contrast so use cool color as back ground