ENFORM User's Guide
Specifying Computations for a Report
Developing an ENFORM Query
058058 Tandem Computers Incorporated 3–33
Specifying
Computations for a
Report
To prepare a complete report, arithmetic operations are often necessary. Besides
arithmetic expressions and aggregates (refer to the ENFORM Reference Manual for
information about these language elements), ENFORM also provides clauses that
allow you to:
Calculate a total or subtotal value for numeric elements.
Calculate a percentage value for numeric elements.
Calculate a running total for the values of a numeric element based either on all
values or the grouped values of the element.
Table 3-5 shows the ENFORM clauses that can be used only with the LIST statement to
specify arithmetic operations for a report.
Table 3-5. Clauses Used to Specify Computations
Clause Function
SUBTOTAL Generates a subtotal for an element.
TOTAL Generates a total for an element.
PCT Generates a percentage of the total for an element.
CUM Generates a running total for an element.
When specifying any of the clauses shown in Table 3-5, consider the number of digits
you expect to be returned. If that number exceeds the number of digits defined in the
dictionary for the field over which the calculation is performed, an overflow condition
results. When an overflow condition occurs, overflow characters (asterisks by default)
appear on the report instead of the figure you expect. To avoid this situation, use an
AS clause (described later in this section ) to modify the element. The AS clause can
increase the number of digits displayed.
When a reference to a user variable is modified by any of these clauses, an overflow
condition does not result in the printing of overflow characters.
Calculating a Subtotal Use the SUBTOTAL clause to generate a subtotal for the values of a numeric element
within one or more by-items. When the value of a by-item changes, ENFORM prints
the subtotal on the report under the column of the element being subtotaled.
ENFORM marks the subtotal with a subtotal string (the default is an asterisk *) in the
by-item column to which the subtotal relates.