Purpose
You want to work with a GuiXT table variable in JavaScript as an array.

Solution
You can convert the GuiXT variable to an JSON Object, modify it and convert it back.

  GuiXT table variable to JSON: JSON.parse()

  JSON Object to GuiXT variable: JSON.stringify()
 

Example:
We read all sales orders for a given customer number with BAPI_SALESORDER_GETLIST. Then we round and format the net value of each item.


GuiXT script

GuiXT
InputField    (5,87) "Customer"  (5,107) _
  size=8        _
  name="KUNNR"

 Pushbutton (5,71)       "Read sales" _
  process="read_orders.txt" size=(2,14) 

 if V[rowsCount=]
  set V[rowsCount] 10
endif 

Table   (8,71)   (23,137) title="Sales" _
  name="salesorders" rows="&V[rowsCount]" 

Column "Description" table="salesorders"  _
  -readOnly       size=40 name="SHORT_TEXT"

Column  "Price" table="salesorders"  _
  -readOnly       size=16 name="NET_VALUE"   


InputScript script

CreateStructure V[return] _
  MESSAGE 

// items
CreateTable V[salesorders] _
  MATERIAL NET_VALUE SHORT_TEXT 

 Set V[SALESORG] "1010" 

// read order
Call "BAPI_SALESORDER_GETLIST"   _
  export.CUSTOMER_NUMBER="KUNNR" _
  export.SALES_ORGANIZATION="SALESORG" _
  import.SALES_ORDERS="salesorders" _
  import.RETURN="return"

 Sort table="salesorders" columns="NET_VALUE" -descending 

CallJS read_sales "salesorders" 

return 

 

JavaScript

JavaScript

Components InputAssistant + Controls