Connecting Tree Views and Table Objects 

The SAP Table Tree control becomes an R/3-aware control by connecting it to a SAP Table object. A Table object is part of the Table Factory control.

The connection is defined through the Structures TableIndex properties and the structure TableIndex property. These properties define the column from which the associated values are taken. If a Table Tree object is added to the Views collection of a Table object, a node is inserted for each row in the table. All necessary information is taken from the table to initialize the new nodes.

Special treatment is reserved for the first Structure item’s TableIndex. This property is used as a row index in the Table object to define the parent of a node. Consequently, the content of the Table object has to define a completely consistent subtree and may not add any nodes elsewhere.

In addition, the application must define the node that indicates where to insert the new subtree through the Table Tree object’s TableInsertRoot property. If this property equals nothing, the subtree is inserted into the root. Otherwise this property must point to an already existing node. In this case, this node is used as parent for the subtree.

Unlike the connection between a Table View control and a Table object, the connection to the Table Tree is only temporary. After the new nodes are inserted, the Table Tree control cancels the connection.

Dim oStructs As Object

 

Set oStructs = oTree.Structs

Set oTree.TableInsertRoot = Nothing

oStructs.TableKeyIndex = 1

oStructs.TableForceExpanderIndex = 2

oStructs.Item(1).TableIndex = 3

oStructs.Item(3).TableIndex = 4

 

oTab.Views.Add oStructs.Object

...

Table Object’s Content

"KeyRoot"

1

0

"Root"

"KeyFo1"

1

1

"Folder"

"KeyLe1"

0

1

"Leaf1"

"KeyLe2"

0

1

"Leaf2"

"KeyLe3

0

2

"Leaf3"

 

Tree’s appearance: