Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

Command return codes

&pagelevel(4)&pagelevel

Error handling in S procedures is based on the fact that commands and statements supply a defined return code. Using this return code, SDF-P can determine whether an error occurred during the execution of a command and what that error was.

The return code from a command always comprises three components:

Subcode1

Error class

Subcode2

Additional information on subcode1

Maincode

Error/message code

For more information on the return codes delivered by SDF-P commands, see section“Command return codes”.

The components of the return code can be queried by means of the predefined functions: SUBCODE2( ), SUBCODE1( ) and MAINCODE( ); the error message text can be queried using the predefined function MSG( ) (see chapter “Predefined functions”).

If the return code is to be checked even if no error has occurred, the SAVE-RETURNCODE command must first be called (except where IF-CMD-ERROR was specified). This makes the return code available so that it can be evaluated by means of the predefined functions.

Error handling is automatically activated when a command is executed and returns a return code with an error flag. SDF-P then branches to the next IF-BLOCK-ERROR or IF-CMD-ERROR command.

SAVE-RETURNCODE

The SAVE-RETURNCODE command serves to save the current return code so that it can be evaluated with the predefined functions. Thus, for example, the programmer can react to situations in which command execution was terminated without error (subcode1 = 0) but subcode2 and maincode must be evaluated.

Example

As a result of the command sequence below, the return code of the preceding command in a procedure can be evaluated if no error occurred.

/"Command which returns a warning but no error"
/SAVE-RETURNCODE
/WRITE-TEXT &(TO-C-LIT(MSG(MAINCODE()))) 

Error handling blocks

Error handling in structured procedures is block-oriented, i.e. it is applied to command blocks.

Error handling itself also takes place in blocks, called error-handling blocks. These blocks are described in detail in section “Creating the procedure body”.

SET-JOB-STEP command

For the sake of compatibility with non-S procedures, SDF-P supports the SET-JOB-STEP (or STEP) command; however, this command should not be used in S procedures. It has the same effect as an empty error handling block (/IF-BLOCK-ERROR; END-IF), but in addition it resets some of the task switches. There are also some restrictions with SET-JOB-STEP which must be noted (see chapter “Converting non-S procedures”).