You can summarize the fields in a group. For example, you can group a report by region, and then summarize the sales for each region.
|
Visual Basic |
|
|
Dim dataDefController As DataDefController = rcd.DataDefController |
|
|
C# |
|
|
DataDefController dataDefController = rcd.DataDefController; |
|
|
Visual Basic |
|
|
Dim group As Group = dataDefController.DataDefinition.Groups(0); |
|
|
C# |
|
|
Group group = dataDefController.DataDefinition.Groups[0]; |
|
This example assumes that the report design contains a Last_Years_Sales field called from a table called Customer.
|
|
|
Not all fields can be summarized on. The CanSummarizeOn method of the SummaryFieldController class checks whether the field can be summarized. |
|
Visual Basic |
|
|
Dim resultFields As Fields = dataDefController.DataDefinition.ResultFields |
|
|
C# |
|
|
Fields resultFields = dataDefController.DataDefinition.ResultFields; |
|
|
Visual Basic |
|
|
Dim summaryFieldController As SummaryFieldController = myDataDefController.SummaryFieldController |
|
|
C# |
|
|
SummaryFieldController summaryFieldController = dataDefController.SummaryFieldController; |
|
|
Visual Basic |
|
|
Dim summaryField As SummaryField = new SummaryFieldClass() |
|
|
C# |
|
|
SummaryField summaryField = new SummaryFieldClass(); |
|
|
Visual Basic |
|
|
summaryField.Group = group |
|
|
C# |
|
|
summaryField.Group = group; |
|
The first parameter of the Add method specifies the location of the new sorting definition in the SummaryFields collection. A value of -1 indicates that the new sorting definition will be added to the end of the SummaryFields collection. However, the location in the collection makes no difference to the report. Apply a report template to ensure consistent formatting of your reports.
|
Visual Basic |
|
|
summaryFieldController.Add(-1, summaryField) |
|
|
C# |
|
|
summaryFieldController.Add(-1, summaryField); |
|
The following code adds a new summary field the first group in a report and based on a given field to perform a summary calculation on. This example checks whether the selected field is a valid field to summarize on before attempting to create the summary field.
|
Visual Basic |
|
|
Private Sub AddSummaryFieldToGroup(ByVal rcd As ISCDReportClientDocument) |
|
|
C# |
|
|
private void AddSummaryFieldToGroup(ISCDReportClientDocument rcd) |
|
This list includes the namespaces used by the sample code:
© 2021 SAP AG. All rights reserved.
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Created with the Personal Edition of HelpNDoc: Create help files for the Qt Help Framework