Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Setting the type of error handling

&pagelevel(5)&pagelevel

Error handling can be activated either in a way that is compatible with the previous spin-off behavior, or on the basis of the command return codes. It is performed by error handling blocks defined in the procedure body.

The ERROR-MECHANISM operand of the SET-PROCEDURE-OPTIONS command can be used to set the applicable type of error handling. The possible operand values are *SPIN-OFF-COMPATIBLE and *BY-RETURNCODE.

  • If *SPIN-OFF-COMPATIBLE is set, error handling will be activated in a manner compatible with the spin-off behavior. Subcode1 will be ignored. This ensures that the error behavior of S procedures which were created under BS2000 V10.0 remains compatible. *SPIN-OFF-COMPATIBLE is the default setting.

  • If the setting is *BY-RETURNCODE, error handling will be activated if Subcode1 of the last command return code is not zero. No account is taken of the spin-off behavior. The setting *BY-RETURNCODE is appropriate for procedures in which commands are used that have their own command return codes. This enables differentiated programming to be used.

Example 1 (for ERROR-MECHANISM=*SPIN-OFF-COMPATIBLE)

/SET-PROCEDURE-OPTIONS ERROR-MECHANISM=*SPIN-OFF-COMPATIBLE
/...
/PRINT-FILE DOES-NOT-EXIST
/...
/
/IF-BLOCK-ERROR
/                   “IF-BLOCK-ERROR is not initiated, since /PRINT-FILE ”
/                   “(with correct syntax) does not cause a spin-off”
/END-IF
/...

Example 2 (for ERROR-MECHANISM=*BY-RETURNCODE)

/SET-PROCEDURE-OPTIONS ERROR-MECHANISM=*BY-RETURNCODE
/...
/PRINT-FILE DOES-NOT-EXIST
/...
/IF-BLOCK-ERROR
/                   “IF-BLOCK-ERROR is initiated in accordance”
/                   “with the return codes for /PRINT-FILE”
/END-IF
/...

Error behavior when changing versions

Although the behavior of most commands is related to the current version, conversion of a command to defined command return codes does not depend on the BS2000 version, but rather on the version of the system product or subsystem.

If ERROR-MECHANISM=*BY-RETURNCODE is specified, the conversion of a system product to command return codes may affect the error behavior of the related commands in the same BS2000 version.

Error behavior of programs

Error handling also affects user programs; such programs can return their own return codes. For programs which do not return their own command return codes, SDF simulates the command return code in the same way as for spin-off handling.

By default, error handling by SDF-P does not take place until after program termination. The default setting *SPIN-OFF-C0MPATIBLE causes error handling to be performed in accordance with the UNIT=STEP parameter of the TERM macro which triggers spin-off, rather than on the basis of the command return codes. (Refer to the manual “Executive Macros” [7] for more details about the TERM macro, and to the description of the CMDRC macro in the manual “SDF-A” [16] for more information about command return codes.)

Setting PROPAGATE-STMT-RC=*TO CMD-RC in the BEGIN block (see the BEGIN-
BLOCK command) permits error handling and evaluation of return codes by SDF-P to be performed during program execution. Error handling is in this case based exclusively on the return codes; the setting for EROR-MECHANISM is irrelevant.