Liquid UI - Documentation - 5.10 table()

5.10 table()


Purpose

The table() is used to create or modify a table on an SAP screen. The table() allows you to:

  • Add columns using column()
  • Populate and display data
 

Note: You can specify the table's position using various methods. Click here for more details on positioning the screen elements.

 

Syntax

You can easily create a table using the following formats:

Format 1: Basic table with coordinates

Creates a table by specifying its name, title, and the desired number of rows and columns.

 
// Creates a table using start and end coordinates
table([startrow,startcol],[endrow,endcol],{"name":"table name","title":"table title","rows":number});
 

Note: A table becomes visible only after at least one column is added.

 

To add a column, use the following command:

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

Click here for details on column().

Format 2: Table with reference to screen elements

 
// Creates a table with reference to screen elements
table("F[screen element]+[startrow,startcol]",[endrow,endcol],{"name":"table name","title":"table title","rows":number});
 

Liquid UI provides two categories of commands to manage tables:

  • Options to manage Rows and Columns

Parameters

The table command takes the following parameters for a Liquid UI table:

  • name - Defines the name
  • title - Defined the title
  • rows - Defines the number of rows

Properties

  • startrow, startcol - Starting row and column coordinates
  • endrow, endcol - Ending row and column coordinates
  • screen element - field name

Available Options

You can use the following options with the table command:

"columnselection":".."

"columnselection":true - Enables selecting one or more columns from a table.

"fixedcolumns":".."

"fixedcolumns":X - Fixes ‘X' number of columns during horizontal scroll.

"rowselection":".."

"rowselection":true - Enables selecting one or more rows.

"singlecolumnselection":".."

"singlecolumnselection":true - Enables selecting a specific column from the table.

"singlerowselection":".."

"singlerowselection":true - Enables selecting a specific row from the table.

Options Detail

The following options are demonstrated using the existing table in the SAP screen.

columnselection

  1. This option determines the number of columns that remain fixed while scrolling horizontally.
     
    // Creates a table for multi-column selection
    table([1,2],[10,95],{"name":"va02_all_items","title":"Sales Order Items","rows":row_max,"columnselection":true});
     
    Fixed column option for horizontal scrolling in table
     
  2. The columnselection option enables the selection of all columns within a table.

fixedcolumns

  1. This option determines the number of columns that remain fixed while scrolling horizontally.
     
    // Determines the columns that remains fixed
    table([2,1],[8,68],{"name":"va02_all_items","title":"All items","rows":20,"rowselection":true,"fixedcolumns":2});
     
    Sets fixed columns during horizontal scroll
     
  2. As per the code, the initial two columns are fixed in the table, and horizontal scrolling begins from the third column onwards.

rowselection

  1. This option specifies one or more rows in the table for selection.
     
    // Creates a table for multi-row selectiontable([2,1],[8,68],{"name":"va02_all_items","title":"All items","rows":20,"rowselection":true});
     
    Specifies rows for selection in the table
     
  2. Row selection is only possible when it's set to true.

singlecolumnselection

  1. The singlecolumnselection option specifies a single column in the table as being selected.
     
    // Creates a table for single-column selectiontable([2,1],[8,68],{"name":"va02_all_items","title":"All items","rows":20,"singlecolumnselection":true});
     
    Restricts selection to a single column in the table
     
  2. As per the code, when a user clicks on a column, only that particular column will be selected.

singlerowselection

  1. The singlerowselection option specifies a single row in the table as being selected.
     
    // Creates a table for single-row selectiontable([2,1],[8,68],{"name":"va02_all_items","title":"All items","rows":20,"singlerowselection":true});
     
    Restricts selection to a single row in the table
     
  2. As per the code, when a user clicks on a row, only that particular row will be selected.

Other system variables can be associated with SAP tables in addition to those listed above. The capabilities include:

Populating and displaying table data

Data Population

  1.  Liquid UI offers the following methods for populating data into tables.

  2. Populating single values:

    table_name.Col_name[row_index] ="xyz";
  3. Populating multiple values:

    var x; 
    for(x=0;x<10;x++) 
    proj.qty[x]=x;
    

Data Display

  1.  Liquid UI offers the following methods for retrieving data from tables.

  2. First and last visible rows:
    println("firstvisiblerow" + <'T[All items]'>.firstvisiblerow);
    println("lastvisiblerow" + <'T[All items]'>.lastvisiblerow);
  3. Table Cell values:
    var i;
    for(i=0;i< table name.column name.length;i++)
    println("table name.column name.[" + i + "] " + table namej.column name[i]);
    
  4. Selected rows and columns:
    var k;
    for (k=0;k< table name.selected rows.length;k++)
    println ("-----table name.selectedrows.["+ k +"] "+ table name.selected rows[k]);
    
Displays values in all items table

Note: You can use the table name and column name instead of the table title and labels to reference a column.

Displaying table data using System Variables

The table() function supports various system variables that allow you to display data from any cell within the table. You can use either of the following syntax options:

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

The available system variables are as follows:

_tabrow

Displays the count of rows in a table.

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

Displays the count of columns in a table.

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

Displays the title of a table, which is shown on the screen; Liquid UI scripts use the technical name.

The table title is visible on the screen, while Liquid UI scripts employ the technical name.

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

Displays the technical name of a table, used by Liquid UI scripts.

The technical name used by Liquid UI scripts appears while the table title appears on the screen.

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

Displays the heading of the current table column, visible on the screen; Liquid UI scripts use the technical name.

Column heading appears on the screen while the column name (technical name) is used by Liquid UI scripts.

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

Displays the technical name of a column in a table, used by Liquid UI scripts.

Column technical name is used by Liquid UI scripts while the column heading appears on the screen.

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

Displays the absolute row number of the cursor's position in a Liquid UI table, even during scrolling.

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

Displays the first row of a table.

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

Displays the absolute column number of the cursor in a Liquid UI table, accounting for scrolling.

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

Example 1: Displaying sales order items table in va02: dynamic selection and custom row limits.

This example provides a simplified view of sales order items, illustrating how to effectively display required data in the Change Sales Order: Initial Screen from the all items table.

//Create the file SAPMV45A.E0102.sjs inside your scripts folder for customizing the Change Sales Order: Initial Screen
//Now, add the Liquid UI script to the above file and save it.

  1. Create a toolbar push button labeled Get Table Data to display the values in the all items table.
     
    // Creates a table to display the values
    pushbutton([TOOLBAR], "Get Table Data", "?", {"process":va02Get5235TableValue}); 
    
     
    Displays values in all items table
     

    Click here for details about how to display sales order items in VA02 screen.

Example 2: Selection of rows and columns at run time

Using the table(), you can easily pre-select rows and columns in a Liquid UI table by utilizing the selectedrows and selectedcols parameters.

Syntax

You can select a specific row in a table using the following syntax.

table_name.selectedrows[row_index] = “X”;

You can select a specific column in a table using the following syntax.

table_name.selectedcols[col_index] = “X”;
  • table_name - Represents the name of the Liquid UI table.
  • row_index - Represents the row number you want to select.
  • col_index - Represents the column number you want to select.

User Interface

To pre-select rows and columns in the Liquid UI table, follow the steps below:

//Create the file SAPLSMTR_NAVIGATION.E0100.sjs inside your scripts folder for customizing the SAP Easy Access screen
//Now, add the Liquid UI script to the above file and save it.

  1. Delete the image container on the SAP Easy Access screen using del().
     
    // Deletes image container on the SAP Easy Access Screen 
    del("X[IMAGE_CONTAINER]");
     
    Deletes images container from SAP screen
     
  2. Create a table labeled All items with 10 rows and 2 columns labeled Material and Quantity.
     
    // Creates a table labeled All items
    table([1,1], [12,48],{"name":"proj", "title":"All items", "rows":10,"rowselection":true,"columnselection":true});  
    column('Material', {"table":"T[All items]", "size":30, "name":"matnr", "position":1, "table":"T[All items]"});        
    column('Quantity', {"table":"T[All items]", "size":10, "name":"qty", "position":2, "table":"T[All items]"});
     
    Creates a table with rows and columns
     

    Note: selectedrows and selectedcols are arrays, and their index starts from ‘0’

     

Tips and Tricks

  • Arrays using Key/Value Pairs

    Inserts and display values from an array using Key/Value pairs.

     
    table([1,1],[20,50],{"name":"matl_table","title":"Material Info","rows":20});
     

    Click here for details on Arrays using Key/Value Pairs

  • Clear Liquid UI Table

    Clears all or a few of the columns of a Liquid UI table.

     
    table([1,1],[20,50],{"name":"matl_table","title":"Material Info","rows":20});
     

    Click here for details on how to clear the Liquid UI table

  • Dynamic create table and read/write value into table cell

    This example is to create the logic of displaying multiple Liquid UI tables on the screen and read or write values from the table.

     
    table([start_row,10],[start_row+5,40],{"name":"z_table_"+i,"title":"Record"+i,"rows":50});
     

    Click here for information about Dynamic Table Data Handling

  • Change the width of the SAP table

    In this example, you can see how easy it is to change the width of a SAP table.

     
    tablewidth([T[table_name]],50);
     

    Click here for details about how to change the width of the SAP table.

Usage Details


Can't find the answers you're looking for?