SAP Reports 2011, WIN, INTL, NUL 7090310 用户手册

产品代码
7090310
下载
页码 706
9.2.4 Creating running totals in a one-to-many linking relationship
A one-to-many linking relationship occurs in linked tables when a single record in one table can be
matched with many records in another table. For example, a one-to-many link might occur when you
link a customer table to an orders table. It wouldn't be unusual in such a case for each customer in the
primary table to have many orders in the second (lookup) table. In your report, the field values from the
primary table are repeated for each new field value in the lookup table.
Creating a subtotal on a field from the primary table provides an incorrect result because the repeated
values are included in the calculation. You can avoid this problem by creating a running total.
This concept can be demonstrated with the sample Xtreme database by using the Customer and Orders
tables.
9.2.4.1 To create a running total in a one-to-many linking relationship
1.
From the Field Explorer dialog box, place the following fields from left to right in the Details section
of your report:
{customer.CUSTOMER NAME}
{customer.LAST YEAR'S SALES}
{orders.ORDER ID}
{orders.ORDER AMOUNT}
2.
On the Insert Tools toolbar, click Insert Group and create a group based on the
Customer.Customer Name field.
3.
Right-click the Customer.Last Year's Sales field and select Summary from the Insert submenu.
4.
Choose Group #1: Customer.Customer Name - A as the location for your summary.
If you look at the subtotals for each group, you will notice they aren't accurate. This is because the
Customer.Last Year's Sales field is duplicated for each order in the report. Follow the rest of this
procedure to see how a running total produces an accurate result in the same situation.
5.
In the Field Explorer dialog box, select Running Total Fields and click New.
The Create Running Total Field dialog box appears.
6.
Enter the name "LYSrunning" in the Running Total Name box.
7.
Highlight Customer.Last Year's Sales in the Available Tables and Fields box, and use the first
arrow button to move it over to the Field to summarize box.
8.
Select sum from the Type of Summary list.
9.
In the Evaluate section of the dialog box, click On change of field and add the Customer.Customer
Name field from the Available Tables and Fields box.
2011-05-16
187
Running Totals