The USE Statement

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
Format 1 (Sequential , Relative and Indexed Files)
OSVSVSC2Format 2 (Record Sequential Files)
OSVSVSC2Format 3 (Relative and Indexed Files)
Syntax Rules
    All Formats (All Files)
  1. Format 1 is the ERROR declarative.

    OSVSVSC2Formats 2 and 3 are the LABEL declarative.

  2. 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.
  3. The USE statement itself is never executed; it merely defines the conditions calling for the execution of the USE procedures.
  4. The files implicitly or explicitly referenced in a USE statement need not all have the same organization or access.
  5. Format 1 (Sequential, Relativeand Indexed Files)
  6. 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.

    ANS85The same file-name must not appear in more than one USE AFTER EXCEPTION statement within the same Procedure Division.

  7. The words ERROR and EXCEPTION are equivalent and can be used interchangeably.
  8. OSVSVSC2Formats 2 and 3 (Record Sequential,Relative and Indexed Files)
  9. OSVSVSC2If both BEGINNING and ENDING are omitted, the effect is as though both BEGINNING and ENDING had been specified.
  10. OSVSVSC2Format 2 (Record Sequential Files)
  11. OSVSVSC2REEL and UNIT are treated as equivalent.
  12. OSVSVSC2If both FILE and REEL/UNIT are omitted, the effect is as though both REEL or UNIT and FILE had been specified.
  13. OSVSVSC2Any 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:
General Rules
    All Formats (All Files)
  1. After execution of a USE procedure, control is returned to the invoking routine. Note that control is not returned if an exception is trapped.
  2. Within a USE procedure, there must not be any reference to any non-declarative procedures. Conversely, in the non-declarative portion there must be no reference to procedure-names that appear in the declarative portion, except that PERFORM statements can refer to a USE statement.

    OSVSVSC2MFThis restriction can be ignored.

  3. Within a USE procedure, there must be no execution of any statement that would cause the execution of a USE procedure that has previously been invoked and has not yet returned control to the invoking routine.
  4. Format 1 (Sequential,Relative and Indexed Files)
  5. 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.
  6. ANS85When file-name-1 is specified explicitly, no other USE statement applies to file-name-1.
  7. The GIVING phrase is documentary only.
  8. OSVSVSC2Formats 2 and 3 (Record Sequential,Relative and Indexed Files)
  9. OSVSVSC2If 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
    1. Read header labels
    2. Execute beginning declarative
    OUTPUT
    1. Execute beginning declarative
    2. Write header labels
    I/O
    1. Read header labels
    2. Execute beginning declarative
    3. Write header labels
    EXTEND
    1. Read header labels
    2. Execute beginning declaratives (trailer labels treated as header)
    3. Write header labels
  10. OSVSVSC2If 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
    1. Read trailer labels
    2. Execute ending declarative
    OUTPUT
    1. Execute ending declarative
    2. Write trailer labels
    I/O
    1. Read trailer labels
    2. Execute ending declarative
    3. Write trailer labels
    EXTEND
    1. Execute ending declaratives
    2. Write trailer labels
  11. OSVSVSC2 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.