$Jobcode: Difference between revisions
mNo edit summary |
|||
Line 1: | Line 1: | ||
<p>The $ | <p> | ||
<p>The completion code must fall within the range 0-4095. If the specified completion code exceeds 4095, <var class="product">Model 204</var> forces the completion code to 4095. No message is output. </p> | The <var>$Jobcode</var> function allows a request that is part of one step of a <var class="product">Model 204</var> batch run to communicate with a subsequent step. <var>$Jobcode</var> can be used both to examine and to set a completion code by invoking <var>$Jobcode</var> with the desired completion code as its one argument. </p> | ||
<p><var class="product">Model 204</var> returns the current step completion code and sets the completion code to the specified value if that value is greater. You can examine the step completion code without changing it by invoking $ | <p> | ||
The completion code must fall within the range 0-4095. If the specified completion code exceeds 4095, <var class="product">Model 204</var> forces the completion code to 4095. No message is output. </p> | |||
<p>You can include calls to $ | <p> | ||
<var class="product">Model 204</var> returns the current step completion code and sets the completion code to the specified value if that value is greater. You can examine the step completion code without changing it by invoking <var>$Jobcode</var> without an argument or with a null argument. </p> | |||
===Using with Online runs=== | |||
<p> | |||
You can include calls to <var>$Jobcode</var> in the CCAIN stream. In Online sessions, <var class="product">Model 204</var> maintains two return code values for each user:</p> | |||
<ul> | <ul> | ||
<li>Highest batch return code value received</li> | <li>Highest batch return code value received</li> | ||
<li>Highest Online value</li> | <li>Highest Online value</li> | ||
</ul> | </ul> | ||
<p>When $ | <p> | ||
<p>The $ | When <var>$Jobcode</var> is used to set the return code for a user, it sets both values. The value returned from the function, however, is always the batch value. When <var>$Jobcode</var> was invoked by an Online user in V4R1.1 and earlier, it always returned 0 and did not set the return code.</p> | ||
<p> | |||
The <var>$Jobcode</var> return codes set in an Online run are local to the user who invoked <var>$Jobcode</var>; they do not affect the return code for other users or for the <var class="product">Model 204</var> Online.</p> | |||
> | ==Example== | ||
<p> | |||
In the following example the first <var>$Jobcode</var> value, 9, returns a value of 16 because 9 is less that 16, so batch return code is not reset by <code>$JOBCODE(9)</code>. The second <var>$Jobcode</var> value, 21, returns a value of 21 because 21 is greater than 16, so batch return code was reset by <code>$JOBCODE(21)</code>.</p> | |||
<p class="code"><b>>MSGCTL M204.1030 RETCODEO=8 RETCODEB=16 | |||
>@#$%^</b> | |||
*** 1 M204.1030: INVALID MODEL 204 COMMAND | *** 1 M204.1030: INVALID MODEL 204 COMMAND | ||
>B;PRINT $JOBCODE(9);END | <b>>B;PRINT $JOBCODE(9);END</b> | ||
16 | 16 | ||
>B;PRINT $JOBCODE(21);END | <b>>B;PRINT $JOBCODE(21);END</b> | ||
21</p> | |||
<p> | |||
See [[Program Communication facilities#BATCH2 facility|BATCH2 facility]] for syntax details.</p> | |||
===Use to avoid completing jobs=== | |||
<p> | |||
You can use <var>$Jobcode</var> in conjunction with other functions to avoid completing large jobs that would produce incorrect or unusable results. Suppose a <var class="product">Model 204</var> run includes a <var>PRINT ALL INFORMATION</var> (<var>PAI</var>) statement that causes all of the fields in a record to be output. A <var>PAI</var> statement sometimes is used to dump the contents of a file before the file is reorganized. After the <var>PAI</var>, new parameters can be specified and the file can be loaded again. </p> | |||
<p> | |||
<p>You can use $ | The file manager often does this with the [[File Load utility]]. If the file being dumped has field level security, it is possible for the <var>PAI</var> run to omit certain fields without issuing error messages. The missing fields are those for which the user does not have READ access. If the output from the <var>PAI</var> run is then reentered to a File Load run, fields are lost. The following technique can be used to avoid this type of problem.</p> | ||
<p>The file manager often does this with the File Load utility | |||
<p class="code">OPEN MYFILE | <p class="code">OPEN MYFILE | ||
BEGIN | BEGIN | ||
Line 51: | Line 59: | ||
END | END | ||
</p> | </p> | ||
<p>A File Load step in the same job could be skipped if it were based on a nonzero step completion code. If it is desirable to trigger an ABEND, $ | <p> | ||
A File Load step in the same job could be skipped if it were based on a nonzero step completion code. If it is desirable to trigger an ABEND, <var>$Jobcode</var> can be used in conjunction with the <var>[[SYSOPT parameter|SYSOPT]]</var> parameter. The 64 (X'40') option for the <var>SYSOPT</var> parameter forces an ABEND without a dump at termination, when the step completion code is nonzero. </p> | |||
[[Category:SOUL $functions]] | [[Category:SOUL $functions]] |
Latest revision as of 20:34, 20 October 2014
The $Jobcode function allows a request that is part of one step of a Model 204 batch run to communicate with a subsequent step. $Jobcode can be used both to examine and to set a completion code by invoking $Jobcode with the desired completion code as its one argument.
The completion code must fall within the range 0-4095. If the specified completion code exceeds 4095, Model 204 forces the completion code to 4095. No message is output.
Model 204 returns the current step completion code and sets the completion code to the specified value if that value is greater. You can examine the step completion code without changing it by invoking $Jobcode without an argument or with a null argument.
Using with Online runs
You can include calls to $Jobcode in the CCAIN stream. In Online sessions, Model 204 maintains two return code values for each user:
- Highest batch return code value received
- Highest Online value
When $Jobcode is used to set the return code for a user, it sets both values. The value returned from the function, however, is always the batch value. When $Jobcode was invoked by an Online user in V4R1.1 and earlier, it always returned 0 and did not set the return code.
The $Jobcode return codes set in an Online run are local to the user who invoked $Jobcode; they do not affect the return code for other users or for the Model 204 Online.
Example
In the following example the first $Jobcode value, 9, returns a value of 16 because 9 is less that 16, so batch return code is not reset by $JOBCODE(9)
. The second $Jobcode value, 21, returns a value of 21 because 21 is greater than 16, so batch return code was reset by $JOBCODE(21)
.
>MSGCTL M204.1030 RETCODEO=8 RETCODEB=16 >@#$%^ *** 1 M204.1030: INVALID MODEL 204 COMMAND >B;PRINT $JOBCODE(9);END 16 >B;PRINT $JOBCODE(21);END 21
See BATCH2 facility for syntax details.
Use to avoid completing jobs
You can use $Jobcode in conjunction with other functions to avoid completing large jobs that would produce incorrect or unusable results. Suppose a Model 204 run includes a PRINT ALL INFORMATION (PAI) statement that causes all of the fields in a record to be output. A PAI statement sometimes is used to dump the contents of a file before the file is reorganized. After the PAI, new parameters can be specified and the file can be loaded again.
The file manager often does this with the File Load utility. If the file being dumped has field level security, it is possible for the PAI run to omit certain fields without issuing error messages. The missing fields are those for which the user does not have READ access. If the output from the PAI run is then reentered to a File Load run, fields are lost. The following technique can be used to avoid this type of problem.
OPEN MYFILE BEGIN IF $FLSCHK (,'R') THEN JUMP TO END.PROCESS END IF PRINT 'INVALID ACCESS TO FILE' PRINT 'STEP COMPLETION CODE WAS' AND - $JOBCODE (16) PRINT 'IT MAY HAVE BEEN SET TO 16' STOP END.PROCESS: IF $JOBCODE () THEN STOP END IF FIND.RECS: FIND ALL RECORDS . . . END
A File Load step in the same job could be skipped if it were based on a nonzero step completion code. If it is desirable to trigger an ABEND, $Jobcode can be used in conjunction with the SYSOPT parameter. The 64 (X'40') option for the SYSOPT parameter forces an ABEND without a dump at termination, when the step completion code is nonzero.