table

The table command is used to define and modify table controls in WS.

This command can both add columns to an existing table and change existing columns in a given table. You can specify the column headings, widths, positions within the table and other options for new columns. The syntax is as follows:

column("heading", {"size":x, "name":"column_name", "option":value…});

In addition to being capable of operating on a native SAP table control, the Column command also can be used in conjunction with the WS table command to create new columns in a user-created table, as shown in the following example. First we will use the table command to create a new table:

table([2,1], [20,50], {"name":"va01_lnitms", "title":"All Items", "rows":100});

Then we will use the column command to add columns to our new table control as follows:

column('Item', {"table":"[All items]", "size":5, "name":"va01_clitm", "position":1});
column('Material', {"table":"[All items]", "size":18, "name":"va01_clitm", "position":2});
column('Quantity', {"table":"[All items]", "size":10, "name":va01_clitm", "position":3});
column('Item Category', {"table":"[All items]", "size":10, "name":va01_clitm", "position":4});
		

Please note that you should always specify the table when adding columns to a GuiXT table as in the preceding example. You can employ either the name value or the title value in the table option - both are supported from the XXX release. However, when using the table option in the column command, Synactive recommends using the value of the 'name' option instead of the value from the 'title' option as that will eliminate the possibility of confusion.

Note: Please see the column section for a more complete explanation of the column command and some examples of its use. You can also use the setcursor command with native SAP tables.

Parameters

The table command takes the following parameters from a GuiXT table:

name
Defines the name of a GuiXT table control.
title
Defines the on-screen label of a GuiXT table control.
rows
Defines the number of rows in a GuiXT table control.

Options

The table command takes the following options:

fixedcolumns

The number of columns that will be fixed during a horizontal scrolling operation. 'X' is the column count. The syntax is:

{"fixedcolumns":X}
rowselection

Specifies one or more rows in the table as being selected. The syntax is:

{"rowselection":true}
singlerowselection

Specifies a single row in the table as being selected. The syntax is below:

{"singlerowselection":true}
columnselection

Specifies one or more columns in a table as being selected. The syntax is:

{"columnselection":true}
singlecolumnselection

Specifies a single column in the table as being selected. The syntax is:

{"singlecolumnselection":true}

The table command allows for both row and column selection to be executed together. This is useful when a user wishes to select rows and columns and retrieve data from the cells at the intersection of the designated rows and columns. The code is as follows:

        table([2,1], [20,50], {"name":"va01_lnitms", "title":All Items", "rows":100, "fixedcolumns":2, "rowselection":true});
        table([2,1], [20,50], {"name":"va01_lnitms", "title":"All Items", "rows":100, "fixedcolumns":2, "columnselection":true});
      

Scrolling

Table controls created using the table command automatically support vertical scrolling. If you create more than one table, then scrolling will be enabled for the table in which the cursor currently resides. If the cursor does not rest in any tables, then scrolling will be enabled for the first table displayed on the screen.

Horizontal scrolling is supported with the 'fixedcolumn' option. If you define a value for the 'fixedcolumns', then the 'firstvisiblecolumn' will automatically contain the value immediately following the value defined for 'fixedcolumns'.

System Variables

There are several system variables that you can use with the table command. These can be used to retrieve data contained in any cell. You can use either of the following syntaxes:

         V[cursortabname.cell.column_name.row_number]
V[cursortabname.cell.column_number.row_number]
        
      

The available system variables are as follows:

_tabrow

Retrieves the number of rows in a table. An example is shown below:

println("The number of rows is >> " +_tabrow);
_tabcol

Retrieves the number of columns in a table. An example is shown below:

println("The table columns are >> " +_tabcol);
_cursortabname

Retrieves the title of the specified table. See the following example:

println("Table title is: " + _cursortabname);
_cursortabtechname

Retrieves the technical name of the table. This value can be defined in the 'name' option introduced earlier. An example is below:

println("Table name is: " +_cursortabtechname);
_cursorcolname

Retrieves the title of a column in the table. This value is set via the 'title' option of a column keyword. An example follows:

println("Column title is: " +_cursorcolname);
_cursorcoltechname

Retrieves the technical name of a column in the table. This value is set via the 'name' option of a column keyword. An example follows:

println("Column title is: " +_cursorcoltechname);
_tabrowabs

Retrieves the absolute row number of the cursor's position in a GuiXT table if there is a scroll operation. An example follows:

println("Absolute cursor row is: " +_tabrowabs);
_cursorrow

Retrieves the starting row of the table. See the following example:

println("Row where table begins: " +_cursorrow);
_cursorcol

Retrieves the value of the column where the table starts as shown in the following example:

println("Column where table begins: " +_cursorcol);