HP 3000 Manuals

ACCUMULATE TOTALS [ USING VPLUS/V AN INTRO. TO FORMS DESIGN Self-Paced Training Guide ] MPE/iX 5.0 Documentation


USING VPLUS/V AN INTRO. TO FORMS DESIGN Self-Paced Training Guide

ACCUMULATE TOTALS 

In the previous version of ORDFORM1, the total price for the order was
calculated and stored in the TPRICE field.  This value was then
transferred to the TOTNET field in the next form.  Now that the order
line is a repeating form, you must accumulate the individual values
calculated for the TPRICE field in the ORDER_LINE form and transfer the
total amount of all the orders to the TOTNET field in the ORDER_TOTALS
form.

The field specifications on TPRICE are currently specified as:

     SET TPRICE TO QTY * UPRICE
     SET STOTNET

These statements calculate a value for the order line and then save this
value in the STOTNET save field, which allows you to store the total
price calculated for a single order line.  The next step is to accumulate
the total price for all order lines.

Action 

Change the second statement on the Field Menu for TPRICE as shown in
Figure 7-12.  Press ENTER.

This statement increments the current value of the STOTNET save field by
the calculated value in TPRICE. As the ORDER_LINE form is repeated a new
value for TPRICE is calculated and this value is added to the total value
for the order in STOTNET.

[]
Figure 7-13. The Field Menu for ORDNUM However, in order for the accumulation specified for TPRICE to work, you must reset the value of STOTNET to zero at the beginning of each order. In the first place, STOTNET must have an initial value for it to be used in a calculation; and in the second place, you only want to store the totals for a single order, not keep incrementing the value as the user progresses from one order to another. Action Return to the Field Menu for the first field in the order, ORDNUM in ORDER_HEAD, and add a statement to initialize STOTNET to zero, as shown in Figure 7-13. Press ENTER. The STOTNET save field is now cleared for each new order. Then, as totals are calculated for individual order lines, STOTNET is incremented. Finally, in the initialization phase of the last form, ORDER_TOTALS, the value accumulated into STOTNET is moved to TOTNET and displayed.


MPE/iX 5.0 Documentation