Adding a Top N sorting definition is similar to adding a normal sort, with a few exceptions. You create a Top N sort based on a specific summary field in the report that summarizes grouped data.
|
Visual Basic |
|
|
Dim dataDefController As DataDefController = rcd.DataDefController |
|
|
C# |
|
|
DataDefController dataDefController = rcd.DataDefController; |
|
|
Visual Basic |
|
|
Dim summaryField As ISCRField = myDataDefController.DataDefinition.SummaryFields(0) |
|
|
C# |
|
|
ISCRField summaryField = dataDefController.DataDefinition.SummaryFields[0]; |
|
|
Visual Basic |
|
|
Dim sortController As SortController = myDataDefController.SortController |
|
|
C# |
|
|
SortController sortController = dataDefController.SortController; |
|
|
Visual Basic |
|
|
Dim myTopNSort As TopNSort = New TopNSort |
|
|
C# |
|
|
TopNSort topNSort = new TopNSort(); |
|
In this example, the top five groups are considered. Groups not in the top five are not discarded, but rather grouped together in a group called "Other".
|
Visual Basic |
|
|
myTopNSort.NIndividualGroups = 5 |
|
|
C# |
|
|
topNSort.NIndividualGroups = 5; |
|
The first parameter of the Add method specifies the location of the new sorting definition in the Sorts collection. A value of -1 indicates that the new sorting definition will be added to the end of the Sorts collection. This means that the new sorting definition will be applied to records last after all other sorting definitions have been applied.
|
Visual Basic |
|
|
sortController.Add(-1, myTopNSort) |
|
|
C# |
|
|
sortController.Add(-1, topNSort); |
|
The following code adds a new top five sort to a report based on the first summary field.
|
Visual Basic |
|
|
Private Sub AddTopNSort(ByVal rcd As ISCDReportClientDocument) |
|
|
C# |
|
|
private void AddTopNSort(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: Generate EPub eBooks with ease