Purpose When you call a JavaScript function using CallJS, a global "guixt" object is already defined (in IE mode) or can be retrieved using "let guixt = window.guixthost". It provides easy access to GuiXT script variables and offers several useful functions, such as the ability to execute a GuiXT script from JavaScript.

The same object is passed to an HTML page by  connectHTML: the function guixt_initialize(obj) is called up (if found in the HTML page), passing the guixt object:

JavaScript

If the HTML page was displayed with  WebView, you can use the object "guixthost" directly and do without the function guixt_initialize(). A call to connectHTML is nevertheless necessary.
 

Component "GuiXT Controls" is needed for this feature.
 

Get() r = guixt.Get(var)

If the content of var is "xxx", the GuiXT script variable V[xxx] is read and its content is stored into r.

Example:

menu_icon_path = guixt.Get("menu_icon_path"); 
 

Set() guixt.Set(var,value)

If the content of var is "xxx", the GuiXT script variable V[xxx] is set to the content of value.

Example:

guixt.Set("menu_icon_path", "C:\guixt\menu\icons"); 
 

Table and structure variables
If V[xxx] is a table variable created with CreateTable or a structure variable, you can set it as a whole by passing a string in JSON notation. For a table, this is an array with one object per row, the property names being the column names. This is the same notation that GuiXT uses for the string representation "&V[xxx]", so you can read a table with JSON.parse(guixt.Get("xxx")), change it in JavaScript and write it back with guixt.Set("xxx", JSON.stringify(...)).

Example:

// GuiXT script: CreateTable V[customers] account name city
var rows = JSON.parse(guixt.Get("customers"));
rows.push({ account: "3000", name: "XYZ Ltd.", city: "London" });
guixt.Set("customers", JSON.stringify(rows));

The column structure defined with CreateTable is kept: columns that are missing in the JSON objects remain empty, additional properties are ignored.

There is no size limit. The JSON conversion is fast even for large tables, so there is no need to use long text variables (SetText) instead.

Changed variables and the SAP screen
Setting a variable does not change the SAP screen by itself. Screen elements that display variables (e.g. input fields with V[...] or a table control based on a table variable) show the new content the next time the screen is built.

  • With CallJS, the JavaScript function runs synchronously during GuiXT script processing. The screen is built afterwards and shows the new values; no refresh is needed.
  • With CallJSAsync or in an event handler of an HTML page (connectHTML, WebView), the screen has already been built. To display the new values, a screen round trip is needed. We recommend guixt.Input("OK:?"): in contrast to "OK:/0" (Enter), the function code "?" does not trigger any action in the SAP application.
GetText() r = guixt.GetText(var)

If the content of var is "xxx", the  GuiXT long text variable text[xxx] is read and its content is stored into r.

SetText() guixt.SetText(var,value)

If the content of var is "xxx", the GuiXT long text variable text[xxx] is set to the content of value.
 

Value() r = guixt.Value(var)

GuiXT replaces all &-expressions in the given string, applying the usual GuiXT logic, and stores the result into r.

Example:

mat = guixt.Value("&F[Material]"); 
 

Input() guixt.Input(s)

The given string is interpreted as input to SAP GUI entry fields, together with a function code and optionally an InputScript, as described in the input= option of the  Image command.

Example:

guixt.input("U[VBELN]:" + ListView.selectedItem);
guixt.input("OK:/nVA03,process=va03_enter.txt");

 

Pressing Enter
There is no separate function guixt.Enter(). With guixt.Input() you trigger Enter exactly as if the user had pressed it; GuiXT and InputAssistant process it in the same way:

guixt.Input("OK:/0"); // Enter
guixt.Input("OK:?");  // Enter without any action in the SAP application

"OK:?" corresponds to Enter "?" in an InputScript (see Enter). Use it when you only need a new screen round trip, e.g. to display variables changed by JavaScript.

Process() guixt.Process(funcname, par1, par2, ...))

Corresponds to the GuiXT instruction Process.

From the first parameter funcname the script name "process_[funcname].txt" is formed. This script is executed, whereby the parameters of the script are occupied by the values of par1, par2,... . The string set at "Return" in the script is returned.

address = guixt.process("customeraddress", "K1032");

Example:

JavaScript
FilePath() guixt.FilePath(s, [cache=True])

The given string is interpreted as file name within the current GuiXT script folder.

  • The full file path, together with the script directory, is returned.
  • An absolute file path such as "C:\guixt\scripts\..." is not changed.
  • For files in SAP MIME Repository "SAPMR:..." the file is copied into the GuiXT cache folder and the local file name in the cache is returned
  • For http or ftp files "http://..."  or "ftp://..." the file is copied into the GuiXT cache folder and the local file name in the cache is returned

If cache=True is specified, external files are first searched in the GuiXT cache.

Example:

imgpath = guixt.FilePath("images\home.gif")
imgpath is now e.g. "C:\guixt\scripts1\images\home.gif"

imgpath = guixt.FilePath("http://www.synactive.com/images/s10logo_blue.gif")
imgpath is now e.g. "C:\Users\ADMINI~1\AppData\Local\Temp\guixt\GuiXT Cache\http\www.synactive.com\images\s10logo_blue.gif"

SetEventHandler() guixt.SetEventHandler(obj1,obj2)

You specify two objects. For each event, e.g. "Click", of obj1 the corresponding function "On...", e.g. "OnClick", of obj2 is called. The event parameters are passed to the function according to the event's interface specification; you have to define a matching number of function parameters.

In most cases obj1 will be a given control , e.g. a List View, and obj2 will be an object that you have specifically defined for event handling.

The GuiXT trace function can display all raised events with their actual parameters as soon as a (maybe still empty) event handler object is set.

DoEvents() guixt.DoEvents()

The function waits a few milliseconds and then processes all Windows messages from the message queue.

You need this function for controls that work with asynchronous processing. For example, the Internet Explorer control loads html pages asynchonously, and before you can access a new page you have to interrupt your own program with DoEvents() until the page has been loaded.

CreateObject() guixt.CreateObject(progid)

Creates an ActiveX object and returns a reference to it.

Example:

   let XXL = guixt.CreateObject("Excel.Application");

GetObject() guixt.GetObject(progid)

Returns a reference to an existing registered object provided by an ActiveX component.

Example:

    let XXL = guixt.GetObject("Excel.Application");