Define report totals (Genero BDL)

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

  1. Open the .4gl file.
  2. 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)
  3. 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 
  4. Calculate the group and report totals, and output them in the FORMAT section.
    Tip: Restrict your use of control blocks to FIRST PAGE HEADER, BEFORE GROUP OF, ON EVERY ROW, AFTER GROUP OF, and ON LAST ROW.
    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