Syntax
DETERMINE TOTAL <qualifier> <attribute name> (<key arguments>) [ MULTI records ] [ GS status ]
Parameters
Determine Total can be abbreviated as DT Total.
qualifier
The profile or persistent class to read. If a class is specified, records are read using the class's default profile. You can also specify an external class with persistent members.
attribute_name
The numeric attribute to total.
key arguments
The key values specifying the records to read.
GS status
Indicates if there are no records in the set, using the specified qualifier.
Description
The Determine Total logic command reads persistent class records that match the specified key values into memory from the database and totals the specified attribute in the Glb.Total built-in segment attribute. You can also specify an external class with persistent members and a profile to access an external database.
The Determine Total logic command functions similarly to a combination of the Determine Every and Add logic commands, except that a loop is implicit within the Determine Total logic command.
Refer to Determine Variants for more information on the Determine logic command.
Example
This example illustrates code from a report that reads records from the product table by using a profile called P_ProductName, retrieving the records based on the product name. The ProductID and ProductName are moved from each retrieved record into a ProductDetail frame. Additionally, the Determine Total command is used to read through all of the SaleEvent records for the specified product and add the values in the SoldQuantity field, producing a total held in Glb.Total. That value is also moved into the ProductDetail frame, and one line for each product is printed.
Determine Actual Product.P_ProductName Determine Total SaleEvent.P_ProductID SaleEvent.SoldQuantity \ (Product.ProductID) ProductDetail.TotalQty := Glb.Total ProductDetail.ProductID := Product.ProductID ProductDetail.ProductName := Product.ProductName ProductDetail.Print() End If (GLB.STATUS = "*****") Message Attention "No Product records found" End
For this example, output from the report is as follows, in product name order.
Product Name |
Product ID |
Total Sold Quantity |
---|---|---|
CatBathSoap | 7 | 00 |
Chips for cats | 2 | 64 |
DogBelt | 6 | 00 |
Gimborn R-7 | 3 | 00 |
KittenCaps | 4 | 40 |
Leather Belt | 9 | 00 |
Outfit for Dogs | 1 | 60 |
PetOutfit | 8 | 00 |
Toys for Cats | 5 | 40 |
ToyPet | 10 | 00 |