Show TOC Start of Content Area

Background documentation Working with Tables  Locate the document in its SAP Library structure

Use

Business data is frequently organized into tables, multi-row structures of fields. In a visual application, tables are easily displayed as a grid control, allowing the display and manipulation of multiple rows on screen.

However, in a voice application only one row at a time can usually be presented to the caller. Therefore, NetWeaver Voice provides a comprehensive set of functions for working with tabular data to allow flexibility in iterating over and modifying tabular data.

Generally, you retrieve data in tabular form from a back-end system. The data is then stored in the dataStore in the workspace.

Working with the Row Pointer

Tables use the concept of a row pointer or cursor, which treats one (and only one) row as the current row. When you refer to one of the fields of a table, either for reading from it or for overwriting it, this reference always implies a reference to the field in the current row.

Note

There is no way to refer to a field by row and column position.

When a table is loaded with data from a data service, the row pointer is placed on the first row. To move to a different row, create a Process element and use the Move To Row function, which accepts either first, last, next, previous, or row. If row is selected, then the row field is enabled, which allows you to enter a row number (rows are numbered starting at 1).

Modifying Table Data

There are several ways to modify the data in a table:

      Overwriting values on the fields of the current row using the Set Variable function

Fields can also be specified as the receiving variables for Listen elements, so that caller input can be written directly into tables.

      Using Revert Row to revert any overwrites to the fields on the current row

This sets the values in the row back to the ones the row contained when the row pointer last moved there. Thus, you can revert the data on a row any time as long as you have not moved the row pointer since making the changes.

      Creating a new empty row by using the Add Row function and leaving the Source attribute blank

A new row is added to the Destination table at the position indicated (before first, after last, before current, and after current) and the row pointer is placed on the new row.

      Copying one or more rows from another table by using the Add Row function and specifying both a source and destination table

Select or deselect Copy All Rows to specify whether all or only the current source row are copied.

      Deleting the current row with the Delete Row function

      Deleting all rows with the Clear Table function

Working with Table Shadow Variables

Every table contains a set of predefined read-only variables that reflect its state. These variables are referred to as table shadow variables. They are updated whenever a table operation takes place. They can be used in expressions to help control the behavior of the dialog when working with tables.

There are a number of Boolean variables related to the row pointer position, such as #isfirst, #islast, and so forth:

      The variable #index contains the current row number.

      The variable and #size contains and total number of rows.

      The variable #action returns the last attempted row pointer operation, such as first, last, next, previous, or row.

      The Boolean variable #actionIgnored indicates whether or not the attempted operation actually took place.

Example

For example, if the table pointer is already on the last row and the next action is requested, the action will be ignored, because it is not possible to move beyond the last row. In this case, the #actionIgnored variable would be set to true. If operations are successful, #actionIgnored is set to false. This is useful for writing dialog behavior that gives a appropriate feedback to the caller when the action they request is not possible.

Finding Data in Tables

The Find Row function will iterate over the rows of the table, starting from the current row pointer, and will evaluate an expression on each row. If the expression is true, it will stop on that row, otherwise, it will continue to the next row.

Thus you can search for any combination of data in any of the fields of the table. The row pointer will stop on the first match found. The find function can be set to go forward or backward from the current row.

After calling Find Row, an expression can determine the outcome by checking the shadow variables:

      If a row was found, then #actionIgnored is false.

      If the search reached the end of the table without finding a row, then #actionIgnored will be true.

Once a row has been found, the row pointer is moved to this row and all shadow variables are updated. Values from the row can be spoken, copied, or used in any way desired. If Find Row is called again, then the search will continue from the row immediately after the previously found row, in the specified direction, as long as the row pointer was not manually moved to a different row between repeated Find Row calls.

 

End of Content Area