TOTALS [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
TOTALS
The TOTALS statement is a Report Writer statement that provides an easy
means for automatic accumulation of numeric data. It provides totaling
at the individual summary levels in a report.
A TOTALS statement can appear in a HEADER or TRAILER section only. There
cannot be more than one TOTALS statement for each summary level. The
TOTALS statement is not used if it is contained in a section with a level
of zero, as the section is unused.
Syntax
[{,} ]
TOTALS [ON] num_expr [{;} num_expr]...
Parameters
num_expr Any numeric expression can be totaled. There can be as
many expressions as desired. When referring to a
particular total, a sequence number is used. The first
expression is sequence number 1, the second is number 2,
and so on.
Examples
100 TOTALS ON My_var, TRUNC(Sales), Quantity*100
The BEGIN REPORT statement makes the TOTALS statement busy and it remains
busy until an END REPORT or STOP REPORT statement is executed. The
TOTALS statement is used ONLY if contained in a HEADER or TRAILER section
with a nonzero level number. There can only be one TOTALS statement per
summary level. All accumulated totals are set to zero by BEGIN REPORT.
The TOTALS calculation occurs when a DETAIL LINE statement executes, but
only when the totals flag of the DETAIL LINE is nonzero. The accumulated
values are reset to zero for any summary level where a break occurs.
This is done after the TRAILER sections are printed. After all break
conditions are processed, the totals are accumulated.
The TOTALS statements are evaluated starting with GRAND TOTALS and
working to level nine. For each statement, the expressions are evaluated
from left to right. The value of each expression is added to previous
totals.
All totals are stored in either REAL or DECIMAL data type, depending on
the data type option in effect when the report started. However, the
expressions themselves are evaluated as any other expression in HP
Business BASIC/XL. This means that an individual expression may cause an
overflow error without causing an overflow in the total.
MPE/iX 5.0 Documentation