This post shows how to add breaks to a VPE report.

Lets assume we have a report that prints order detail lines. Now we decide that we want a sub header and a sub total for each order. Lets add another sub header and sub total for the customer so that the report will show each customer than all the customers orders and then the detail to each order.

The following code will define the break conditions

SZBREAK_BEGIN
    SZBREAK orderhdr.customer_no
    SZBREAK orderdtl.order_no
SZBREAK_END

this code defines two break conditions. One on ordhdr.customer_no and one on orddtl.order_no

the subheader and subtotal section can be defined as follows

SZDEFINE_SECTION SZSUBHEADER 1 "SubHeader1" 100 FORCE_PAGEBREAK_NONE False
    Procedure DoOutputSection                
        // printing code goes here
    End_Procedure
SZEND_SECTION

SZDEFINE_SECTION SZSUBTOTAL 2 "Subtotal2" 100 FORCE_PAGEBREAK_NONE False
    Procedure DoOutputSection                
        // printing code goes here
    End_Procedure
SZEND_SECTION

we can also define values to be calculated for subtotals. For example lets say we would like to keep track of the number of orders as well as the order amount total

// subtotals for break#1 
SZDEFINE_SUBTOTALS 1
    SZADD_SUBTOTAL "ORDERS" 1
    SZADD_SUBTOTAL "AMOUNT" orddtl.amount
SZENDDEFINE_SUBTOTALS

// subtotals for break#2
SZDEFINE_SUBTOTALS 1
    SZADD_SUBTOTAL "ORDERS" 1
    SZADD_SUBTOTAL "AMOUNT" orddtl.amount
SZENDDEFINE_SUBTOTALS

to print the subtotal value we can use the following code

SZDEFINE_SECTION SZSUBHEADER 1 "SubHeader1" 100 FORCE_PAGEBREAK_NONE False
    Procedure DoOutputSection                
        // print total amount for this customer
        Send szWritelnPos (GetSubtotal(Self,1,"AMOUNT"))
    End_Procedure
SZEND_SECTION