Calculating Subtotals
Use
You want to display subtotals after a sort level break of a sort criterion . In the example below, we use the currency field CURRENCY as the sort criterion. Thus, each subtotal refers to one currency.
Prerequisites
The same prerequisites as for Examples .
Procedure
-
For table BUSINESS define a global structure to contain the result of the calculation, for example, R_BUSINESS .
-
On the Data tab enter CURRENCY as sort criterion and mark Event on Sort End .
-
In the navigation tree create a table line as inferior node of the event node CURRENCY Event on Sort End and select a line type for subtotal output. In our example, we assume that the line type consists only of one line.
-
Before the output of the subtotal create a program lines node in the cell. To display the subtotal after the current currency, assign it to the result field in the program lines node: R_BUSINESS-CURRENCY = WA_BUSINESS-CURRENCY .
-
After the program lines node insert a text node and include the fields R_BUSINESS-PRICE and R_BUSINESS-CURRENCY into this text.
-
Go to the Calculations tab of your table node and fill the following fields:
|
Column |
Value |
|
Operation |
Total |
|
Field Name |
WA_BUSINESS-PRICE |
|
Target Field Name |
R_BUSINESS-PRICE |
|
Event |
After Loop |
|
Initialization |
(active) |
|
Reset |
Sort Criterion |
|
Sort Criterion |
CURRENCY |
Result
The subtotals are formatted according to the relevant currency and displayed after each sort level.