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.
The table command takes the following parameters from a GuiXT table:
The table command takes the following options:
The number of columns that will be fixed during a horizontal scrolling operation. 'X' is the column count. The syntax is:
{"fixedcolumns":X}
Specifies one or more rows in the table as being selected. The syntax is:
{"rowselection":true}
Specifies a single row in the table as being selected. The syntax is below:
{"singlerowselection":true}
Specifies one or more columns in a table as being selected. The syntax is:
{"columnselection":true}
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});
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'.
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:
Retrieves the number of rows in a table. An example is shown below:
println("The number of rows is >> " +_tabrow);
Retrieves the number of columns in a table. An example is shown below:
println("The table columns are >> " +_tabcol);
Retrieves the title of the specified table. See the following example:
println("Table title is: " + _cursortabname);
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);
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);
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);
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);
Retrieves the starting row of the table. See the following example:
println("Row where table begins: " +_cursorrow);
Retrieves the value of the column where the table starts as shown in the following example:
println("Column where table begins: " +_cursorcol);