TOTAL


The TOTAL statement accumulates subtotals and grand totals in output and update processes.

    ••••• TOTAL    ••• •••••••••••••••••••••• ••• •  ••• •••••••••••••••••••••• •••
    (1)            (2) (3)                    (4)(5) (6) (7)                    (8)

(1) T/F execution conditions

(5) Operator (+, -, P, M)

(2) 1st application ID

(6) 2nd application ID

(3) 1st field name or PDF

(7) 2nd field name, PDF, or constant

(4) 1st occurrence (constant/index)

(8) 2nd occurrence (constant/index)

Using the Statement

TOTAL adds to (+), hash-adds to (P), subtracts from (-), or hash-subtracts from (M) the first operand using the amount indicated in the second operand. However, rather than storing the result in the the first operand, the total is accumulated internally within APPX.

TOTAL is a special use of a numeric field that occurs only in output and update processes. TOTAL maintains running totals that can be retrieved and used in End of Range frames. Totaled fields can also be automatically displayed on end of range images.

APPX dynamically maintains a numeric field for each sort level of a totaled field. It does not alter the contents of the field being totaled. As each level is subtotaled, the corresponding value of the totaled field is added to the next level and then cleared. In a subtotal image, a user can define the field being totaled on the image and request a display of the “range” value. This causes APPX to display the value that was totaled for that sort level.

Using the sample code in the Example section below, assume that a cash receipts report is being printed with subtotals by account number and date, as well as grand totals. In this case, APPX allocates three work fields for total receipts. When the TOTAL statement is executed, APPX adds to the account number subtotal. When the account number subtotal prints, APPX adds the account number subtotal to the date subtotal and then zeros the account number subtotal. When the date subtotal prints, APPX adds the date subtotal to the grand total and then zeros the date subtotal. At the end of the report, APPX prints the grand total.

A user can retrieve a totaled value by using the SET TOT statement at the subtotal or grand total level. Thus, in our example, you can retrieve the value of WORK CASH RECEIVED in any subtotal or grand total image with the following statement:

          SET TOT  TAR WORK AMOUNT                =  TAR WORK CASH RECEIVED

Related Statements

SET TOT

Example

In the following example, the TOTAL statement is used to accumulate daily cash receipts. Subtotals or grand totals can be printed on reports, or extracted using the SET TOT statement.

          TOTAL    TAR WORK CASH RECEIVED         +  TAR RECEIPT2 CHECK AMOUNT