The <<ERROR>> procedure specifies a set of actions to invoke when a run‑time error occurs. The <<ERROR>> procedure can provide additional information for debugging (such as return codes) or override the default procedure and continue processing following an error.
The <<ERROR>> procedure overrides the CA Ideal default error procedure. The default procedure issues a LIST ERROR statement, performs a BACKOUT, issues a standard message, and QUITs the RUN. You can write your own <<ERROR>> procedure, for example, to display other information and to execute a PROCESS NEXT statement.
This procedure has the following format:
<<ERROR>> PROCEDURE
statements
[ENDPROC ]
[ENDPROCEDURE]
<<ERROR>> PROCEDURE The statements in the body of the <<ERROR>> procedure can consist of any CA Ideal/PDL statements and functions needed to process the error. If the last statement is not a QUIT RUN, QUIT statement, or PROCESS NEXT statement, then the default error procedure runs (following the <<ERROR>> procedure).
A program can contain only one error procedure.
The PDL internal functions used in error handling are described in the Programming Reference Guide. These functions return meaningful information about CA Ideal errors only in the <<ERROR>> procedure.
Example
The following illustration describes the usage of <<Error>> procedure:
<<ERROR>> PROCEDURE :--------------------------------------------------------------------- : The following <<ERROR>> PROC uses a PDL function $ERROR-CLASS to : trap dataview errors, arithmetic errors and reference errors. : When the $ERROR-CLASS is 'DVW', the PDL functions $ERROR-TYPE and : $ERROR-DVW-STATUS further qualify the error. : : The PROCESS NEXT statement is used for recoverable errors; fatal : errors result in the termination of the program. :--------------------------------------------------------------------- SELECT FIRST ACTION WHEN $ERROR-CLASS = 'DVW' SELECT FIRST ACTION WHEN $ERROR-TYPE = 'D71' NOTIFY 'Record changed; retry' PROCESS NEXT TRANS-LOOP WHEN $ERROR-TYPE = 'D72' NOTIFY 'Record deleted; retry' PROCESS NEXT TRANS-LOOP WHEN $ERROR-TYPE = 'DB2' NOTIFY 'DB2 problem: Run Terminated' SET $RC = $SQLCODE WHEN $ERROR-TYPE = 'SQL' NOTIFY 'DATACOM SQL problem: Run Terminated' SET $RC = $SQLCODE WHEN $ERROR-TYPE = 'DVW' SELECT FIRST ACTION WHEN $ERROR-DVW-STATUS = 'I3' NOTIFY 'Record changed; retry' PROCESS NEXT TRANS-LOOP WHEN $ERROR-DVW-STATUS = '16' NOTIFY 'Record in use; retry' PROCESS NEXT TRANS-LOOP WHEN OTHER NOTIFY 'DATACOM CBS problem: Run Terminated' SET $RC = '66' ENDSEL ENDSEL WHEN $ERROR-CLASS = 'ARI' DO ARITHMETIC-ERR PROCESS NEXT MAIN-LOOP WHEN $ERROR-CLASS = 'REF' DO REFERENCE-ERR PROCESS NEXT MAIN-LOOP WHEN OTHER : Non-recoverable errors NOTIFY 'System error: Run Terminated' SET $RC = 12 ENDSEL LIST ERROR BACKOUT QUIT RUN ENDPROC
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|