Task description

Solution

Sample code, images Restrictions, SAP Release, SAP GUI version, GuiXT version
31 Creating a new column with larger maximum input size than visible width

When you create a new table column with the Column command, the size= parameter describes both the visible column width and the maximum input size of your new column. Additional ColumnWidth or ColumnSize commands for this column will also  change both the visible width and the maximum input size.

In order to create a new column with small visible size (e.g. 10) and large input size (e.g.120), use the following trick. It is based on the fact that the input size of a cell is at least the size of the value that is contained in the cell. So all you need to do is to define the column with size=10 but add enough padding space characters to each cell value. This operation is somewhat tricky, since most  GuiXT commands will ignore space characters at the end of a string.  There is one exception that you can use: A Set command with substring notation, e.g.

Set V[x](1-20) “abc”

changes the given positions 1 to 20 of V[x],  inserting space characters at the end. This means that the command

Set V[x](1-120) “&V[x]“

enlarges the variable V[x] to a size of 120, adding space characters at the end if necessary.

Now all we need to do is to apply this command to each visible cell of our new column. Let us assume that the table name is “Table” and the new column title is “Barcode”. The complete script is then as follows:

// Create the new column
Column “Barcode” size=“10″ name=“bv” position=“5″

// Determine visible part of the table
GetTableAttribute T[Table] firstVisibleRow=“i” lastVisibleRow=“n”

// Loop through all visible cells
label nextrow
if V[i>&V[n]]
  goto done
endif

// Enlarge cell no.i
Set V[bv.&V[i]](1-120) “&V[bv.&V[i]]”

// next row
Set V[i] &V[i] + 1
goto nextrow

label done
 

 

 Last update: 
May 28, 2008

 

 

InputAssistant

 

 

Creating a new column with larger maximum input size than visible width