$Jobcode

From m204wiki
Revision as of 18:12, 21 July 2014 by Mlarocca (talk | contribs) (Mlarocca moved page $JOBCODE to $Jobcode: Lower case change)
Jump to navigation Jump to search

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 (see the Rocket Model 204 File Manager's Guide for details). 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.