Previous Topic Next topic Print topic


CONTROL

Identify control data items (Report Writer controls), which are tested for a change each time a detail line is printed. Create a control hierarchy for the report control headings and footings (control breaks). This clause is part of the RED (see RED) keyword statement block.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.

Syntax: for Format 1

CONTROL [IS] [FINAL] dataname

Syntax: for Format 2

CONTROLS [ARE] [FINAL] dataname1 ... datanameN

Parameters:

dataname Data item that causes a control break when it changes.
FINAL Inclusive report control group not associated with a control dataname. It represents the highest level of control.

Comments:

  • Datanames can be qualified, but cannot be subscripted or indexed, or have a subordinate data item with a variable size defined in an OCCURS clause. Each dataname must be a different data item.
  • List the datanames from the highest to lowest level. An implicit FINAL is the highest control. The first dataname is the major control; the last dataname is the minor (lowest) control.
  • When identifing controls in the CONTROL clause, dataname must be an elementary data name. In the following example, B cannot be used as a control variable because it is a group data item. To make B into an elementary data item, use the REDEFINES clause.
    WS01  A                         PIC X(2).
    WS01  B.
          02  B-1                   PIC 9(4).
          02  B-2                   PIC 9(4).
    WS01  B-REDEF  REDEFINES B      PIC X(8).
          .
          .
          .
    RED TEST-REPORT
        CONTROLS ARE A B-REDEF
  • You can omit the CONTROL clause when the only control is FINAL.
  • The first time a GENERATE builds a report, all control values are saved. The next GENERATE tests Report Writer controls for changes every time a detail line is printed, by comparing the contents with the contents saved from the last GENERATE of the same report.
    • If the control is numeric, the relation test compares two numeric operands.
    • If the control is an index, the test compares two index data items.
    • If it is neither numeric nor an index, it compares two non-numeric operands.
  • A change in dataname (a control) causes a control break that
    • Prints control footings for lower level datanames, followed by the control footing for the dataname causing the control break
    • Clears counters associated with the datanames
    • Prints control headings for the dataname and lower level datanames
    • Prints the detail line causing the break

Examples:

See Sample Programs.

Previous Topic Next topic Print topic