The USE statement specifies procedures for input-output error handling, that are in addition to the standard procedures provided by the input-output control system.
General Formats for Format 1 (Sequential , Relative and Indexed Files)
General Formats for Format 2 (Record Sequential Files)
General Formats for Format 3 (Relative and Indexed Files)
Syntax Rules for All Formats (All Files)
- Format 1 is the ERROR declarative.
Formats 2 and 3 are the LABEL declarative.
- A USE statement, when present, must immediately follow a section header in the Declaratives Section and must be followed by a period followed by a space.
- The USE statement itself is never executed; it merely defines the conditions calling for the execution of the USE procedures.
- The files implicitly or explicitly referenced in a USE statement need not all have the same organization or access.
Syntax Rules for Format 1 (Sequential, Relativeand Indexed Files)
- The same file-name can appear in a different specific arrangement of the format. Appearance of a file-name in a USE statement must not cause the simultaneous request for execution of more than one USE procedure.
The same file-name must not appear in more than one USE AFTER EXCEPTION statement within the same Procedure Division.
- The words ERROR and EXCEPTION are equivalent and can be used interchangeably.
Syntax Rules for Formats 2 and 3 (Record Sequential,Relative and Indexed Files)
- If both BEGINNING and ENDING are omitted, the effect is as though both BEGINNING and ENDING had been specified.
Syntax Rules for Format 2 (Record Sequential Files)
- REEL and UNIT are treated as equivalent.
- If both FILE and REEL/UNIT are omitted, the effect is as though both REEL or UNIT and FILE had been specified.
- Any one file-name and any one OPEN mode can appear in only one declarative for each of the possible combinations of BEGINNING/ENDING and FILE/REEL as shown below:
- BEGINNING FILE
- BEGINNING REEL/UNIT
- ENDING FILE
- ENDING REEL/UNIT
General Rules for Format 1 (Sequential,Relative and Indexed Files)
- The designated procedures are executed by the input-output system after completing the standard input-output error routine, or upon recognition of the AT END condition, when the AT END phrase has not been specified in the input-output statement.
- When file-name-1 is specified explicitly, no other USE statement applies to file-name-1.
- The GIVING phrase is documentary only.
General Rules for Formats 2 and 3 (Record Sequential,Relative and Indexed Files)
- If the BEGINNING phrase is specified explicitly or implicitly, the following actions are taken during the execution of an applicable OPEN statement:
Open Mode
|
Action
|
INPUT
|
- Read header labels
- Execute beginning declarative
|
OUTPUT
|
- Execute beginning declarative
- Write header labels
|
I/O
|
- Read header labels
- Execute beginning declarative
- Write header labels
|
EXTEND
|
- Read header labels
- Execute beginning declaratives (trailer labels treated as header)
- Write header labels
|
- If the ENDING phrase is specified explicitly or implicitly, the following actions are taken during the execution of an applicable CLOSE statement:
Open Mode
|
Action
|
INPUT
|
- Read trailer labels
- Execute ending declarative
|
OUTPUT
|
- Execute ending declarative
- Write trailer labels
|
I/O
|
- Read trailer labels
- Execute ending declarative
- Write trailer labels
|
EXTEND
|
- Execute ending declaratives
- Write trailer labels
|
- The statement GO TO MORE-LABELS appearing in a declarative procedure is treated as a simple jump to the start of the declarative procedure in which it appears.