Connecting Table Views and Table Objects 

Although the SAP Table View control can be used alone, you must connect it to a Table object’s Views collection to exploit its full functionality. Connecting the view control to the Table object means that data is transported automatically between both controls in both directions. Any change of data either by user interaction or through the control’s automation is transferred to the Table object. The same scenarios work when data is changed in the Table object. Any formatting or data conversion done within the Table object is immediately reflected in the view control.

Connecting and Disconnecting the Controls

The connection is easily established. Every Table object exports a Views collection. This collection maintains all objects using the Table object as data source. By adding an instance of a Table View control to this View collection (in the Table object), the connection is established. The connection is released by removing the Table View object from the Table object’s Views collection.

Dim oTableFactory As Object

Dim oTable As Object

‘ Create TableFactory and Object

Set oTableFactory = CreateObject( " SAP.TableFactory.1 " )

Set oTable = oTableFactory.NewTable

‘ Establish view - connection

oTable.Views.Add SAPTableView1.Object

‘... Do anything

‘ Remove view - connection

OTable.Views.Remove(1)

How the Connection is Managed

The connection between the Table View and Table Factor controls is configured through:

The TableIndex properties in the Table View object are the key to the connection mechanism. These indexes tell which Table View row or column corresponds to which Table Factory row and column. Thus each Table View cell may address data in the Table object using its TableIndex properties. The AutoConfig property in the Table View object distinguishes between four different modes:

Value

Description

tvaAutoConfigDisabled = 0

The TableIndex of the Row and Column objects are provided and maintained by the application using the control. No automated mechanism works for these properties. If all TableIndex properties are set to 0, the behavior is the same as if there were no connection.

tvaAutoConfigRows = 1

The TableIndex of all Row objects are provided and maintained automatically through the connection. If rows are inserted or removed in the Table object, all TableIndex properties (in the relevant Table View Rows) are updated automatically. The relevant new or outdated Rows in the Table View are also automatically inserted or deleted.

tvaAutoConfigCols = 2

The TableIndex of all Column objects are provided and maintained automatically through the connection. If columns are inserted or removed in the Table object, all TableIndex properties (in the relevant Table View Columns) are updated. The relevant new or outdated Columns in the Table View are also automatically inserted or deleted.

tvaAutoConfigAll = 3

All TableIndex properties are provided and maintained automatically through the connection. All modifications in the Table object are reflected automatically for all Table View rows and columns.

The entire connection is driven by the Row object and Column object’s TableIndex properties. Nevertheless it is possible to insert and remove rows and columns through the SAP Table View control’s Rows and Columns collections. These rows and columns are not configured automatically in any case. This allows the application to insert or remove rows and columns from the Table View without any effect on the Table object. If the Table View object and the Table object need to be kept synchronous, the application should always work on the Table object.

How Events are Communicated

The following rules apply to the connection:

Event

Reaction

Data changed in the Table object

Corresponding cell data in the Table View object is changed immediately.

Data changed in the Table View object

Corresponding cell data in the Table object is changed immediately.

Row deleted in the Table object

Corresponding row is deleted in the Table View object.

Row deleted in the Table View object

No modification of the Table object.

Column deleted in the Table object

Corresponding column is deleted in the Table View object.

Column deleted in the Table View object

No modification to the Table object.

Row inserted in the Table object

A new row is inserted in the Table View object if it is possible to determine the position. Otherwise a new row is added.

Row inserted in the view object

No modification to the Table object.

Column inserted in the Table object

A new column is inserted in the view object if it is possible to determine the position, otherwise a new column is added.

Column inserted in the Table View object

No modification to the Table object.

Table object cleared

All Table View rows with a connection to the Table object are cleared.

Table View object cleared

Each Table View cell with a connection to the Table object clears the corresponding value in the Table object.

Table object deleted

Each Table View row and each column with a connection to the Table object is removed.

Table View object deleted

No modification to the Table object.