Handling errors when calling programs
When a program dynamically calls a separately compiled
program, the called program might be unavailable. For example, the
system might be out of storage or unable to locate the program
object. If the
CALL statement does not have
ON EXCEPTION or
ON OVERFLOW phrase,
your application might abend.
ON EXCEPTION phrase to perform
a series of statements and to perform your own error handling. For
example, in the code fragment below, if program
unavailable, control passes to the
ON EXCEPTION phrase.
MOVE "REPORTA" TO REPORT-PROG
DISPLAY "Program REPORTA not available, using REPORTB."
MOVE "REPORTB" TO REPORT-PROG
ON EXCEPTION phrase applies only to the availability
of the called program on its initial load. If the called
program is loaded but fails for any other reason (such as initialization), the
EXCEPTION phrase is not performed.
Enterprise COBOL for z/OS® Migration Guide