We
start with the VBScript function call in GuiXT scripts, a feature that is useful
in its own right and in its application to ActiveX controls.
This is how you proceed:
Create a
file of type ".vbs", e.g. "lib1.vbs".
In this file write a VBScript function, for example:
Function test1
test1 = "Hello World"
End Function
If you want to implement a big project with GuiXT Controls we recommend
you install a special VBScript editor that supports useful
features such as syntax check, pretty print and online help. Various
tools are available on the internet, for example, "VbsEdit":
Make sure
you
choose a tool whereby the interfaces of ActiveX components
can be viewed; this will make it much easier to deal with complex
controls.
Enter the .vbs
filename you have chosen in GuiXT profile:
Later on you can add more ".vbs" files,
separated
by semicolons, if an
individual
file becomes too large.
You can define an unlimited number of functions in one VBScript file.
Please note: If
you change your VBScript code and want to perform a new test in a SAP GUI
window that is still running, you have to
open
a new SAP GUI mode with "/O...", since the old version of your VBScript
file is still active in the old mode. The
entire
VBScript
program is loaded once only in each SAP GUI mode so that global
variables retain their value.
Use the "CallVBS"
keyword in your GuiXT Script or InputScript to call your VBS function.
You can display the returned value with a "Message"
command:
CallVBS msg = test1
Message
"S: &V[msg]"
-statusline
This means that the VBS function "test1" is called and that the result is set into the GuiXT variable V [msg]. If you are not interested in receiving the value returned by the function, you simply use the syntax
CallVBS test2
As a result we see a SAP GUI message with the text from the
VBScript function: