Purpose
This guide demonstrates techniques for creating, manipulating, and optimizing table variables in GuiXT. It covers structured variables, memory management, performance considerations, and integration with SAP database tables.

Table of Contents

  • Creating a Table Variable
  • Deleting a Table Variable
  • Writing Data into Table Cells
  • Understanding Memory Requirements
  • Performance: CPU Time for Cell Updates
  • Populating Tables Using Structured Variables
  • Modifying Table Row Count
  • Copying Table Data 
  • Deleting Table Rows
  • Exporting Table Data to CSV
  • Importing SAP Data into Table Variables

1. Creating a Table Variable
Choose a suitable name (e.g., "ctab") and define the table using CreateTable. Example:

GuiXT

CreateTable V[ctab] account name street city country
You may define a structured variable first:

GuiXT

CreateStructure V[customeraddress] account name street city country
CreateTable V[ctab] include=V[customeraddress]

Please note: All names (table name and column names) are case sensitive.

To  view the full content of a table variable in the debugger, click the [...] icon:

This opens a temporary file with TAB-delimited text:


2. Deleting a Table Variable
Free memory by deleting unused table variables:

GuiXT

DeleteTable V[ctab]

Structured variables can also be deleted, though they typically consume minimal memory.

To clear table content without deleting the definition:
GuiXT

Clear V[ctab]

Tables defined in a "process" functions are automatically deleted when the function is left.


3. Writing Data into Table Cells
Set values directly into table cells. Rows are auto-allocated up to the specified index:

Example:

GuiXT

Set V[ctab.account.5000] "K1032"

This creates rows 1 to 5000 if not already present.

Avoid extremely high indices:

GuiXT

Set V[ctab.account.100000000] "K1032"
This will trigger a memory error popup in 32-Bit SAP GUI:

"Not enough memory: Memory request of 1907 MB failed"

 In 64-Bit SAP GUI the operation takes ~5 sec; the process memory increases by ~4 GB.


4. Understanding Memory Requirement

  • Each empty cell uses 4 bytes of memory in 32-bit SAP GUI, 8 bytes in 64-bit SAP GUI.
  • Example: 100,000 rows × 5 columns ≈ 4MB in 64-Bit SAP GUI:

GuiXT

Set V[ctab.rowcount] "100000"
  • Filled cells use ~24 + value length (in bytes).

If you want to use GuiXT for mass data processing with several million data records, 64-Bit SAP GUI can be necessary due to the 32-bit memory limit (~2GB).


5. Performance: CPU Time for Cell Updates
GuiXT takes ~5 seconds to fill 1 million cells (200,000 rows × 5 columns) via loop in InputScript.

  • Adequate for most UI applications


6. Populating Tables Using Structured Variables

  • Method A: Set Each Cell Individually

    GuiXT

    Set V[k] 0
    label next_row
    if V[k<100]
       Set V[k] &V[k] + 1
    
      Set V[ctab.account.&V[k]] "..."
       Set V[ctab.name.&V[k]] "..."
      Set V[ctab.street.&V[k]] "..."
      Set V[ctab.city.&V[k]] "..."
      Set V[ctab.country.&V[k]] "..."
    
      goto next_row
    endif

  • Method B: Use AppendRow with Structured Variable

    GuiXT
    Set V[k] 0
    label next_row
    if V[k<100]
       Set V[k] &V[k] + 1
        
      Set V[customeraddress.account] "..."
      Set V[customeraddress.name] "..."
      Set V[customeraddress.street] "..."
      Set V[customeraddress.city] "..."
      Set V[customeraddress.country] "..."
    
      AppendRow V[customeraddress] table=V[ctab]
    
      goto next_row

Please note: AppendRow can use a subset of columns; missing cells remain empty.


7. Modifying Table Row Count
Use V[tab.rowcount] to adjust the row count:

  Set
V[tab.rowcount] "n"

  • n=0
    Same as Clear V[tab], i.e. all rows are removed.
  • n higher than current rowcount
    Appends empty rows until rowcount equals n
  • n below current rowcount
    Removes rows at the end of the table until rowcount equals n


8. Copying Table Data
GuiXT offers two primary methods for copying table variables: Method A (JSON-based) and Method B (cell-by-cell). Each has distinct advantages and limitations depending on the table structure and performance needs.

Method A: JSON-Based Copy  

GuiXT
// copy table V[tab1] into V[tab2]
Set V[tab2] "&V[tab1]"
  • Supports differently structured tables. Column names are matched by name. Columns in the target table that do not exist in the source remain empty.
  • Safe for structural mismatches. Ideal when source and target tables have different column sets.
  • Slower for large tables. Example: Copying 50,000 cells took approximately 0.4 seconds.

Method B: Cell-by-Cell Copy

Use CopyText to/from a temporary text:

GuiXT
// copy table V[tab1] into V[tab2]
CopyText fromTable=V[tab1] toText="temp"
CopyText fromText="temp" toTable=V[tab2]

// clear temporary text
Clear text[temp]
  • Requires identical structure. Column names are not observed—cells are copied by position only.
  • May abort if source and target structures differ.
  • Faster for large, equally structured tables. Example: Copying 50,000 cells took approximately 0.1 seconds.


9. Deleting table rows
Use "DeleteRow" to remove specific rows. To remove many rows at the end, reduce V[tab.rowcount]
.

10. Exporting Table Data to CSV
Set  delimiter ";" or "," and use CopyText:
GuiXT

CopyText fromTable=V[ctab] toText="temp" delimiter=";"
CopyText fromText="temp" toFile="C:\temp\customers.csv"
Clear text[temp]

To add column headers:

GuiXT
// column headers
Set text[temp] "Account;Name;Street;City;Country"

CopyText fromTable=V[ctab] toText="temp" delimiter=";"  -appendLine
CopyText fromText="temp" toFile="C:\temp\customers.csv"
Clear text[temp]


11. Importing SAP Data into Table Variables
Use BAPI calls or, for direct database access, the function module /guixt/dbselect.

As an example, we read all customers from database table KNA1 whose name contains the string "computer"

  • Method A: Using an Intermediate Text Variable
    Define the table variable so that the columns exactly match the result set of the select call. The column names can be different from the database column names.

    GuiXT
    CreateTable V[ctab] account name street city country
    
    Clear text[r]
    Call /guixt/dbselect _
      in.table="KNA1" _
      in.condition="UPPER( NAME1 ) LIKE '%COMPUTER%' " _
      in.fields="KUNNR,NAME1,STRAS,ORT01,LAND1" _
      table.values="r"
    
    CopyText fromText="r" toTable=V[ctab]


  • Method B: Using the Open Call Interface
    Same as Method A, but we use the GuiXT Open Call Interface. No intermediate text variable is necessary in this case.

     

    GuiXT
    CreateTable V[ctab] account name street city country
    
    Set V[saptable] "KNA1"
    Set V[condition] "UPPER( NAME1 ) LIKE '%COMPUTER%' "
    Set V[fields] "KUNNR,NAME1,STRAS,ORT01,LAND1"
    
    Call /guixt/dbselect _
      export.table="saptable" _
      export.condition="condition" _
      export.fields="fields" _
      import.values="ctab"

Components
InputAssistant