Print group totals and report totals

In the Genero BDL report program

In your Genero BDL report application, define variables for the totals, calculate the values, and output them to the report engine.

In the REPORT program block, define variables:
DEFINE
 data store_order_data,
 --Add variables for totals 
 store_total, order_total, item_total, report_total DECIMAL(10,2)
Identify the data columns by which the data is grouped in the ORDER EXTERNAL command:
ORDER EXTERNAL BY 
data.orders.store_num, 
data.orders.order_num 
Calculate the group and report totals, and output them in the FORMAT section.
FORMAT

  --Add FIRST PAGE HEADER, BEFORE GROUP OFs 
  FIRST PAGE HEADER
    LET report_total = 0

  BEFORE GROUP OF data.orders.store_num 
    LET store_total = 0

  BEFORE GROUP OF data.orders.order_num 
    LET order_total = 0

  ON EVERY ROW
    --Add statements to calculate totals 
    LET item_total = data.items.price*data.items.quantity 
    LET order_total = order_total + item_total 
    LET store_total = store_total + item_total 
    LET report_total = report_total + item_total 
    PRINT data.*, order_total, store_total, report_total

In the report design document (.4rp)

Consider this example:

This figure shows the Report Structure created by modifying the report application to include an order_total, store_total, and report_total in the report. See the surrounding text for more information about modifying the report application and Report Structure to add group and report totals.

Figure 1. Example Report Structure

In this example, the order_total Stripe is the last child of the Group order_num, the store_total Stripe is the last child of the Group store_num. The report_total Stripe was dropped onto the Page Root, the main page for the report. This positions the Stripe as a child of the Page Root, and will place it at the very bottom of the child list for that trigger.

On each change of data, the specified data for every corresponding row will print out, and the appropriate Stripe will print out after each change of Group. The report_total Stripe will be the last thing to print out on the report. The values of any data objects in the Stripe will be taken from the immediately preceding row of data (the last report line of the container for onEveryRow trigger.)