\
\ APIs Used: QLRSETCE - Set COBOL Error Handler
\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
PROGRAM-ID. CBLERR1.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-AS4ðð.
OBJECT-COMPUTER. IBM-AS4ðð.
INPUT-OUTPUT SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
\
\ Error Code parameter include. As this sample program
\ uses COPY to include the error code structure, only the first
\ 16 bytes of the error code structure are available. If the
\ application program needs to access the variable length
\ exception data for the error, the developer should physically
\ copy the QSYSINC include and modify the copied include to
\ define additional storage for the exception data.
\
COPY QUSEC OF QSYSINC-QLBLSRC.
\
\ Miscellaneous elements
\
ð1 MISC.
ð5 Y PIC S9(ð9) VALUE ð.
ð5 ERROR-HANDLER PIC X(2ð) VALUE "ERRHDL1 \LIBL ".
ð5 SCOPE PIC X(ð1) VALUE "C".
ð5 ERROR-HANDLER-LIBRARY PIC X(1ð).
ð5 PRIOR-ERROR-HANDLER PIC X(2ð).
ð1 NUMERIC-GROUP.
ð5 X PIC 9(ð3).
\
\ Beginning of mainline
\
PROCEDURE DIVISION.
MAIN-LINE.
\
\ Register the COBOL Error Handler.
\
\ Initialize the error code parameter. To signal exceptions to
\ this program by the API, you need to set the bytes provided
\ field of the error code to zero. Because this program has
\ exceptions sent back through the error code parameter, it sets
\ the bytes provided field to the number of bytes it gives the
\ API for the parameter.
\
MOVE 16 TO BYTES-PROVIDED.
\
\
\ Call the API to register the exit point.
\
CALL "QLRSETCE" USING ERROR-HANDLER OF MISC,
SCOPE OF MISC,
ERROR-HANDLER-LIBRARY OF MISC,
Appendix B. Original Examples in Additional Languages B-113