LMS supports statement return codes analogous to the command return codes (see [4 (Related publications)]). The statement return code allows the user to react as necessary to specific conditions after each LMS statement.
Structure of the statement return codes
The statement return code has three parts:
Maincode:
Message code; the meaning can be retrieved with /HELP-MSG-INFORMATION.
Subcode1:
Error class (decimal); indicates the gravity of the error.
Subcode2:
Supplementary information (decimal); e.g. subcode2 = 2 in conjunction with
subcode1 = 0 indicates a warning.
Controlling the output of statement return codes
The output of statement return codes is activated with the command:
/BEGIN-BLOCK PROGRAM-INPUT=*MIXED-WITH-CMD( -
/ PROPAGATE-STMT-RC=*TO-CMD-RC )
The statement return codes can then be evaluated in S procedures with SDF-P means (see the SDF-P manual "Programming in the Command Language" [12 (Related publications)]). The SDF-P built-in functions MAINCODE() or MC(), SUBCODE1() or SC1() and SUBCODE2() or SC2() can be used for evaluation.
Error handling at the command level is triggered when statement return codes are output, i.e. a jump to the next /IF-CMD-ERROR, /IF-BLOCK-ERROR or /STEP command.
The error handling is triggered if subcode1 of the statement return code is not equal to 0. This is the case with all error messages. The setting of MAX-ERROR-WEIGHT has no effect.
The statement return code can be saved with the /SAVE-RETURNCODE command. /IF-CMD-ERROR implicitly executes the /SAVE-RETURNCODE command.
Note
With maincodes LMS1002, LMS1003 and LMS1004, the true error must be taken from the LMS protocol, if this is present. Maincode LMS1003 after a statement with a wildcard entry may mean that several errors have occurred.
The following possible statement return codes are defined for LMS.
(SC2) | SC1 | Maincode | Meaning |
| 0 | CMD0001 | No error |
(SC2) : Subcode2 = 0 is represented by blanks
The possible return codes are shown again in the descriptions of the separate LMS statements.
Example
Search for member A in LIB1 or LIB2 :
/BEGIN-BLOCK PROGRAM-INPUT=*MIXED-WITH-CMD( - / PROPAGATE-STMT-RC=*TO-CMD-RC ) /START-LMS //SHOW-ELEM-ATTR *LIB(LIB = LIB1, ELEM = A, TYP = S),TEXT-OUT=*NONE /IF-CMD-ERROR // SHOW-ELEM-ATTR *LIB(LIB = LIB2, ELEM = A, TYP = S),TEXT-OUT=*NONE / IF-CMD-ERROR / SET-VAR LIB = 'none' / ELSE / SET-VAR LIB = 'LIB2' / END-IF /ELSE / SET-VAR LIB = 'LIB1' /END-IF /WR-TEXT 'Member A is in the &LIB library' //END /END-BLOCK