Progress
Language Reference


ACCUM Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns the value of an aggregate expression that is calculated by an ACCUMULATE or aggregate phrase of a DISPLAY statement.

SYNTAX

ACCUM aggregate-phrase expression 

aggregate-phrase

A phrase that identifies the aggregate value it should return. This is the syntax for aggregate-phrase.

SYNTAX
{   AVERAGE
  | COUNT
  | MAXIMUM
  | MINIMUM
  | TOTAL
  | SUB-AVERAGE
  | SUB-COUNT
  | SUB-MAXIMUM
  | SUB-MINIMUM
  | SUB-TOTAL
} [ BY break-group ] 

For more information on aggregate items, see the Aggregate Phrase reference entry.

expression

An expression that was used in an earlier ACCUMULATE or DISPLAY statement. The expression you use in the ACCUMULATE or DISPLAY statement and the expression you use in the ACCUM function must be in exactly the same form. (For example, “on-hand * cost” and “cost * on-hand” are not in exactly the same form.) For the AVERAGE, SUB-AVERAGE, TOTAL, and SUB-TOTAL aggregate phrases, expression must be numeric.

EXAMPLE

This procedure shows a total for the extended price of each item on an order. The running total of the order is displayed as well as the order total and grand total for all orders. This procedures accumulates totals at three levels in this procedure, as indicated by the arrows.

r-accum.p
FOR EACH order:
  DISPLAY order-num cust-num order-date promise-date ship-date.
  FOR EACH order-line OF order:
    DISPLAY line-num item-num qty price.
    DISPLAY qty * price LABEL "Ext Price".
    ACCUMULATE qty * price (TOTAL).
    DISPLAY (ACCUM TOTAL qty * price) LABEL "Accum Total".
  END.
  DISPLAY (ACCUM TOTAL qty * order-line.price) LABEL "Total".
END.
DISPLAY (ACCUM TOTAL qty * order-line.price) LABEL "Grand Total"
  WITH ROW 1. 

SEE ALSO

ACCUMULATE Statement, DISPLAY Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095