To navigate the Totaller tree

Parent Previous Next

 

Report Application Server .NET SDK Developer Guide

To navigate the Totaller tree


 







This example assumes that you have a report that contains at least one level of grouping.

You can navigate to a node in the Totaller tree by creating a group path that represents its location, or by recursively iterating through the tree using the GetSubTotallerNodes method.

  1. Create a new GroupPath object.

Visual Basic

Dim groupPath As ISCRGroupPath = New GroupPath()

C#

ISCRGroupPath groupPath = new GroupPath();

The GroupPath object represents where a node is positioned in the tree.

  1. Use thefromString method to specify the path to the node in the Totaller tree.

Visual Basic

groupPath.FromString("")

C#

groupPath.FromString("");

Visual Basic

groupPath.FromString("/Canada/BC")

C#

groupPath.FromString("/Canada/BC");

Visual Basic

groupPath.FromString("Country[Canada]/Region[MB]")

C#

groupPath.FromString("Country[Canada]/Region[MB]");

Visual Basic

groupPath.FromString("1-0")

C#

groupPath.FromString("1-0");

  1. Create a new Totaller node, and set it by calling the RowsetController.GetTotallerNode method using the group path as the argument.

Visual Basic

Dim totallerNode As ISCRTotallerNode = New TotallerNodeClass()
totallerNode = rcd.RowsetController.GetTotallerNode(groupPath)

C#

ISCRTotallerNode totallerNode = new TotallerNodeClass();
totallerNode = rcd.RowsetController.GetTotallerNode(groupPath);

  1. Retrieve the children of the node using the GetSubTotallerNodes method.

Visual Basic

Dim children As ISCRTotallerNodes = rcd.RowsetController.GetSubTotallerNodes(groupPath)

C#

ISCRTotallerNodes children = rcd.RowsetController.GetSubTotallerNodes(groupPath);

  1. Iterate through the children of the Totaller node.

Visual Basic

Dim nodeNames As [String] = "" 
For i As Integer = 0 To currentNodes.Count - 1
 nodeNames += currentNodes(i).Name & " "
Next

C#

String nodeNames = ""; 
for (int i = 0; i < currentNodes.Count; i++)
{
 nodeNames += currentNodes[i].Name + " ";
}

  1. Return the string that contains node information.

Visual Basic

Return nodeNames

C#

return nodeNames;

This sample recursively traverses the Totaller tree from the root level and returns the name of each node. Modify the traverseChildren method to manipulate each node of the totaller.

Visual Basic

Private Function TraverseTotaller(ByVal rcd As ISCDReportClientDocument) As String
 Dim groupPath As ISCRGroupPath = New GroupPath()
 groupPath.FromString("")
 Dim totallerNode As ISCRTotallerNode = New TotallerNodeClass()
 totallerNode = rcd.RowsetController.GetTotallerNode(groupPath)
 Dim children As ISCRTotallerNodes = rcd.RowsetController.GetSubTotallerNodes(groupPath)
 Dim nodeNames As String = ""
 TraverseChildren(rcd, children, nodeNames)
 Return nodeNames
End Function
Private Sub TraverseChildren(ByVal rcd As ISCDReportClientDocument, ByVal currentNodes As ISCRTotallerNodes, ByRef nodeNames As String)
 For i As Integer = 0 To currentNodes.Count - 1
  nodeNames += currentNodes(i).Name & " "
  Dim currentPath As ISCRGroupPath = currentNodes(i).GroupPath
  Dim childNodes As ISCRTotallerNodes = rcd.RowsetController.GetSubTotallerNodes(currentPath)
  TraverseChildren(rcd, childNodes, nodeNames)
 Next
End Sub

C#

private String TraverseTotaller(ISCDReportClientDocument rcd)
{
 ISCRGroupPath groupPath = new GroupPath();
 groupPath.FromString("");
 ISCRTotallerNode totallerNode = new TotallerNodeClass();
 totallerNode = rcd.RowsetController.GetTotallerNode(groupPath);
 ISCRTotallerNodes children = rcd.RowsetController.GetSubTotallerNodes(groupPath);
 String nodeNames = "";
 TraverseChildren(rcd, children, ref nodeNames);
 return nodeNames;
}
private void TraverseChildren(ISCDReportClientDocument rcd, ISCRTotallerNodes currentNodes, ref String nodeNames)
{
 for (int i = 0; i < currentNodes.Count; i++)
 {
  nodeNames += currentNodes[i].Name + " ";
  ISCRGroupPath currentPath = currentNodes[i].GroupPath;
  ISCRTotallerNodes childNodes = rcd.RowsetController.GetSubTotallerNodes(currentPath);
  TraverseChildren(rcd, childNodes, ref nodeNames);
 }
}

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: Produce Kindle eBooks easily