Purpose |
With
CallVBS
you can call a VBScript function from a GuiXT Script or InputScript.
Component "GuiXT Controls" is needed for this command. In the 64-bit SAP GUI, CallVBS and CallVBSAsyync are not automatically available because Microsoft does not provide a 64-bit version of the script control that GuiXT uses for VBScript execution. You can install alternatives such as "Tablacus Script Control 64" if needed. CallVBS / CallVBAsync will then work again without requiring any adjustments to the GuiXT profile or script. Alternatively, especially for new developments, use JavaScript (CallJS) or VB.NET/C# (CallVB). |
Example |
CallVBS
msg = test1
The VBScript function "test1"
is called. The function result is stored in string format into variable
V[msg]. |
Format 1 |
CallVBS
funcname
"par1" "par2 "par2" ...
The VBScript function "funcname"
is called. The specified strings "par1", "par2",... are passed to the function.
You can use the notation "&V[varname]" as parameter if you want to
pass the value of a GuiXT variable. |
Format 2 |
CallVBS
varname
= funcname "par1" "par2 "par2"
The VBScript function "funcname"
is called. The specified strings "par1", "par2",... are passed to the function.
The function result is stored in string format into the variable V[varname]. |
Security | VBScript
is able to perform critical operations such as destroying files or changing
registry values, comparable to Visual Basic, Java or C++ . As a consequence,
the same security rules that apply for programs written in these languages
have to be applied to VBScript functions that you rollout to other users.
|
Details |
When the first CallVBS commmand is performed in a SAP GUI mode, all VBScript library files specified in GuiXT profile are loaded. The functions and global variables in these .vbs files need to have a unique name across all files, since a single namespace is used when loading the files. Please observe that any commands outside of function or class declarations will be executed when the files are loaded. Global VBScript variables retain their values within each SAP GUI mode. You may store the VBScript files in the SAP Web Repository and maintain them centrally, facilitating quality control and rollout. For example, the following statements in the configuration file "guixt.ini" will load three VBScript files from SAP Web Repository: VBSLibrary SAPWR:ZGUIXT.vbslib01.vbs Syntax errors in any one of the VBScript files should be avoided, since in this case the loading of the functions is terminated with a syntax error message. If you write your VBScript functions in a special VBScript editor such as VbsEdit (recommendable for complex functions), you can run the script there to have its syntax checked. All parameters are passed to the VBScript function as string values, and the return value is stored as a string value in the specified script variable. There is only one exception to this rule: object references are handled differently; see next section. It is possible to read and
write GuiXT variables within the VBScript function; for details on how to
proceed see Object "guixt"
in VBScript. This allows you to implement a kind of parameter passing
by reference: simply pass the name of the GuiXT script variable instead
of its value, and use guixt.get() and guixt.set() to access the variable
using its name. |
Object references | VBScript
is an object based programming language that allows you to deal with dynamically
created objects: ActiveX components that you create with CreateObject()
or that have been created in the GuiXT script with the Control command,
or objects of self-defined VBScript classes (Class ... End Class)
that you create in VBScript with the New command . GuiXT supports parameter passing of object references in both directions. It uses a string representation of the object reference when it is stored into a GuiXT script variable, and converts automatically to or from the object reference (technically: an IDispatch interface). For example, you can define a VBScript class, create an object of this class in VBScript, pass the object reference to GuiXT and store it into a GuiXT script variable, then call a second VBScript function, pass GuiXT variable that contains the object reference and access attributes and methods of the object. VBScript, being an untyped
programming language, has its limitations when programs are above a certain
level of complexity. In this case you can implement an ActiveX component
in a better suited typed language such as Visual Basic .NET or C#
and make use of this component in your VBScript code. |
Debugging | You can
invoke the debugger with a "Stop" command in a VBScript function.
If no special script debugger is installed on your PC, for example the Microsoft
Script Debugger (free of charge) or MS Visual Studio, the script debugger
that comes with Internet Explorer will be called.
Please note: If you have disabled
script debugging in the Internet Explorer settings: |
Example 2 | We start
Excel and pass some demo values:
// GuiXT Script Set V[sales.1] "2584" Set V[region.2] "Europe" Set V[sales.2] "1228" Set V[region.3] "Asia" Set V[sales.3] "1628" // call excel
' VB Script |
Components | GuiXT + Controls |