The USE BEFORE REPORTING Statement (Report Writer)

The USE BEFORE REPORTING statement specifies Procedure Division statements that are executed just before a report group named in the Report Section of the Data Division of this program, and optionally a contained program, is presented.

General Format


Syntax for the General format of the USE BEFORE REPORTING statement

Syntax Rules

  1. A USE BEFORE REPORTING statement, when present, must immediately follow a section header in the declaratives portion of the Procedure Division and must appear in a sentence by itself. The remainder of the section must consist of zero, one, or more procedural paragraphs that define the procedures to be used.
  2. Identifier-1 must reference a report group. The same identifier-1 must not appear in more than one USE BEFORE REPORTING statement in the same Procedure Division.
  3. The GENERATE, INITIATE, or TERMINATE statements must not appear in a paragraph in a USE BEFORE REPORTING procedure. A PERFORM statement in a USE BEFORE REPORTING procedure must not have GENERATE, INITIATE, or TERMINATE statements in its range.
  4. A USE BEFORE REPORTING procedure must not alter the value of any control data item.
  5. The USE BEFORE REPORTING statement itself is never executed; it merely defines the conditions calling for the execution of the USE procedures.

General Rules

  1. A declarative procedure is invoked just before the named report group is produced during the execution of the program. The report group is named by identifier-1 in the USE BEFORE REPORTING statement which prefaces the declarative.
  2. Within a declarative procedure, there must be no reference to any nondeclarative procedures.
  3. Procedure-names associated with a USE BEFORE REPORTING statement can be referenced in a different declarative section or in a nondeclarative procedure only with a PERFORM statement.
  4. In the USE BEFORE REPORTING statement, the designated procedures are executed by the RWCS just before the named report group is produced. (See the section The TYPE Clause.)
  5. Within a USE procedure, there must not be the execution of any statement that would cause the execution of a USE procedure that had previously been invoked and had not yet returned control to the invoking routine.
  6. Special precedence rules are followed when programs are contained within other programs. In applying these rules, only the first qualifying directive will be selected for execution. The declarative which is selected for execution must satisfy the rules for execution of that declarative. The order of precedence for selecting a declarative is:
    1. The declarative within the program that contains the statement which caused the qualifying condition.
    2. The declarative in which the GLOBAL phrase is specified and which is within the program directly containing the program which was last examined for a qualifying declarative.
    3. Any declarative selected by applying rule 6b to each more inclusive containing program until rule 6b is applied to the outermost program. If no qualifying directive is found, none is executed.