Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

8.1.15.1 EXCEPTION/ERROR Declarative



The EXCEPTION/ERROR declarative specifies procedures for input/output exception or error handling that are to be executed in addition to the standard system procedures.

The words EXCEPTION and ERROR are synonymous and can be used interchangeably.


    ___ Format 1--USE (EXCEPTION ERROR Declarative) ________________________ 
   |                                                                        |
   | >>__USE__ ________ __AFTER__ __________ __ _EXCEPTION_ __PROCEDURE___> |
   |          |_GLOBAL_|         |_STANDARD_|  |_ERROR_____|                |
   |                                                                        |
   |              <_____________                                            |
   | >__ ____ __ ___file-name-1_|_ ______________________________________>< |
   |    |_ON_|  |_INPUT___________|                                         |
   |            |_OUTPUT__________|                                         |
   |            |_I-O_____________|                                         |
   |            |_EXTEND__________|                                         |
   |                                                                        |
   |________________________________________________________________________|
file-name-1
Valid for all files. When this option is specified, the procedure is executed only for the file(s) named. No file-name can refer to a sort or merge file. For any given file, only one EXCEPTION/ERROR procedure can be specified; thus, file-name specification must not cause simultaneous requests for execution of more than one EXCEPTION/ERROR procedure.

A USE AFTER EXCEPTION/ERROR declarative statement specifying the name of a file takes precedence over a declarative statement specifying the open mode of the file.

INPUT
Valid for all files. When this option is specified, the procedure is executed for all files opened in INPUT mode or in the process of being opened in INPUT mode that get an error.

OUTPUT
Valid for all files. When this option is specified, the procedure is executed for all files opened in OUTPUT mode or in the process of being opened in OUTPUT mode that get an error.

I-O
Valid for all direct-access files. When this option is specified, the procedure is executed for all files opened in I-O mode or in the process of being opened in I-O mode that get an error.

EXTEND
Valid for all files. When this option is specified, the procedure is executed for all files opened in EXTEND mode or in the process of being opened in EXTEND mode that get an error.

The EXCEPTION/ERROR procedure is executed:

After execution of the EXCEPTION/ERROR procedure, control is returned to the invoking routine in the input/output control system. If the input/output status value does not indicate a critical input/output error, the input/output control system returns control to the next executable statement following the input/output statement whose execution caused the exception.

The EXCEPTION/ERROR procedures are activated when an input/output error occurs during execution of a READ, WRITE, REWRITE, START, OPEN, CLOSE, or DELETE statement. To determine what conditions are errors see "Common Processing Facilities" in topic 6.1.8.9.

Within a declarative procedure, there must be no reference to any non-declarative procedures. In the non-declarative portion of the program, there must be no reference to procedure-names that appear in an EXCEPTION/ERROR declarative procedure, except that PERFORM statements can refer to an EXCEPTION/ERROR procedure or to procedures associated with it.


X As IBM extensions to the COBOL 85 Standard, the following apply to
X declarative procedures:

Within an EXCEPTION/ERROR declarative procedure, no statement should be included that would cause execution of a USE procedure that had been previously invoked and had not yet returned control to the invoking routine.


X You can include a statement that executes a previously invoked USE
X procedure that is still in control. However, to avoid an infinite loop,
X you must be sure that there is an eventual exit at the bottom.

EXCEPTION/ERROR procedures can be used to check the status key values whenever an input/output error occurs.

Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.