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 for Format 1 (Sequential, Relative and Indexed Files)


Syntax for General Format for Format 1 (Sequential, Relative and Indexed Files) for the USE statement
OSVSVSC2 

General Formats for Format 2 (Record Sequential Files)


Syntax for General Format for Format 2 (Record Sequential Files) for the USE statement
OSVSVSC2 

General Formats for Format 3 (Relative and Indexed Files)


Syntax for General Format for Format 3 (Relative and Indexed Files) for the USE statement

Syntax Rules for All Formats (All Files)

  1. Format 1 is the ERROR declarative.

    OSVSVSC2 Formats 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.

Syntax Rules for Format 1 (Sequential, Relative and Indexed Files)

  1. 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.

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

  2. The words ERROR and EXCEPTION are equivalent and can be used interchangeably.
OSVSVSC2 

Syntax Rules for Formats 2 and 3 (Record Sequential, Relative and Indexed Files)

  1. OSVSVSC2 If both BEGINNING and ENDING are omitted, the effect is as though both BEGINNING and ENDING had been specified.
OSVSVSC2 

Syntax Rules for Format 2 (Record Sequential Files)

  1. OSVSVSC2 REEL and UNIT are treated as equivalent.
  2. OSVSVSC2 If both FILE and REEL/UNIT are omitted, the effect is as though both REEL or UNIT and FILE had been specified.
  3. OSVSVSC2 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 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.

    OSVSVSC2MF This 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.

General Rules for Format 1 (Sequential, Relative and Indexed Files)

  1. 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.
  2. ANS85 When file-name-1 is specified explicitly, no other USE statement applies to file-name-1.
  3. The GIVING phrase is documentary only.
OSVSVSC2 

General Rules for Formats 2 and 3 (Record Sequential, Relative and Indexed Files)

  1. OSVSVSC2 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
    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
  2. OSVSVSC2 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
    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
  3. 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.