Consultor Eletrônico



Kbase 21170: How To keep a running total in a browse widget
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/19/2001
SUMMARY:

This article outlines one way of maintaining a running total of a column in a browse widget and display it as a sub-total column.

SOLUTION:

The below code was written against the Sports2000 database which ships with Progress.

/* Define a variable to display the sub total */
DEFINE VARIABLE deSubTotal AS DECIMAL NO-UNDO.
/* Define a variable to hold the total */
DEFINE VARIABLE deTotal AS DECIMAL NO-UNDO.

DEFINE QUERY q FOR customer SCROLLING.
DEFINE BROWSE b QUERY q
DISPLAY customer.custnum
customer.NAME
customer.salesrep
customer.balance
deTotal @ deSubTotal
WITH 8 DOWN.

DEFINE FRAME f b WITH WIDTH 130.

ON 'ROW-DISPLAY':U OF b DO:
/* When the row is displayed, increment the total amount */
deTotal = deTotal + customer.balance.
END.

OPEN QUERY q FOR EACH customer.
ENABLE ALL WITH FRAME f.
WAIT-FOR CLOSE OF THIS-PROCEDURE.