Previous Topic: IDMS Communications BlockNext Topic: Housekeeping Statements


Error Handling

CA IDMS reports the completion status of a requested DML function by placing a 4-digit alphanumeric code in the ERROR-STATUS field of the IDMS communications block. The ERROR-STATUS field should be examined following every executable DML command to determine whether the request was successful or not.

The following table identifies some of the most common error status values that can be returned and the corresponding condition names that are generated as part of the IDMS communications block record description (SUBSCHEMA-CTRL) for COBOL. For PL/I, these names may optionally be generated as named constants.

Code

Explanation

Level-88 Name

0000

Request completed successfully

DB-STATUS-OK

0326

Record not found on a FIND or OBTAIN using a CALC key, db-key, index, or sort key

DB-REC-NOT-FOUND

0307

End of set or end of area was encountered on a FIND or OBTAIN NEXT or PRIOR in a set or area.

DB-END-OF-SET

For COBOL and PL/I programs, CA IDMS provides an error checking routine called IDMS-STATUS that can be copied into the program. IDMS-STATUS checks the completion status of the latest DML request that was issued. If the function did not complete successfully, IDMS-STATUS performs a user-supplied routine called IDMS-ABORT (COBOL only), displays status information, and aborts the program. The status information, retrieved from the IDMS communications block, includes PROGRAM-NAME, ERROR-STATUS, ERROR-RECORD, ERROR-SET, ERROR-AREA, RECORD-NAME, AREA-NAME, DBKEY, page group, dbkey format and DML-SEQUENCE.

CA IDMS delivers IDMS-STATUS in 2 flavors. The new flavor includes DBKEY, page group and dbkey format and is defined in the dictionaries as versions 11 and higher. The old flavor does not expand any additional call to the internal formatting routine and thus does not display DBKEY, page group or dbkey format. The old flavor is defined as versions 1 to 5. The higher versions always take precedence. If you prefer to use an older version, you can drop the new versions 11 and higher from the dictionary which causes the old versions to be copied into the program instead. Another option is to select the requested version in the program using the VERSION clause of the COPY IDMS statement (INCLUDE IDMS statement in PL/I).

The COBOL example below shows how the IDMS-STATUS routine is copied into the program using the COPY IDMS statement. The example also shows the user-supplied IDMS-ABORT routine that must be coded by the COBOL programmer.

COPY IDMS IDMS-STATUS.
IDMS-ABORT SECTION.
IDMS-ABORT-EXIT. EXIT.

After every executable DML function, the program should do the following:

For example, after issuing an OBTAIN CALC request, the program should check for an ERROR-STATUS value of '0326' (DB-REC-NOT-FOUND) and otherwise perform the IDMS-STATUS routine as follows:

OBTAIN CALC STUDENT.
IF DB-REC-NOT-FOUND
    ...
    ...
ELSE PERFORM IDMS-STATUS.

CA IDMS provides a set of protocols (operating modes) for COBOL programs that automatically perform the IDMS-STATUS routine as part of expanding the DML statement. These modes are referred to as "autostatus" protocols and have names such as BATCH-AUTOSTATUS. When using an autostatus protocol, expected ERROR-STATUS values can be specified as ON parameters in the DML statement. The following example illustrates the use of the ON clause to check for an '0326' ERROR-STATUS value when issuing an OBTAIN CALC request.

OBTAIN CALC STUDENT
ON DB-REC-NOT-FOUND
  ...
  ...