In a .NET
function that has been invoked with
CallVB
or
CallVBAsync
you can access GuiXT script variables via the class "guinet.guixt".
This class also provides several additional functions. e.g.
SAP GUI scripting interface.
Prerequisites:
component "GuiXT
Controls" is active
A reference to guinet.dll
has been included in your .NET project
In order to use the class "guinet.guixt"
it suffices to create an object of this class:
Private guixt As New guinet.guixt
private guinet.guixt guixt = new guinet.guixt();
GetVariable()
r = guixt.GetVariable(var)
Reads a GuiXT script variable
and returns its content.
Example:
Dim menu_icon_path As String
menu_icon_path = guixt.GetVariable("menu_icon_path")
Native interface to a special
control currently displayed in the SAP GUI window. As "id" you may use
the following strings:
"grid" GridView Control "tree"
TreeView Control "textedit" TextEdit Control "htmlviewer" HTML
Viewer Control "toolbar" Toolbar Control "splitter" Splitter
Control "picture" Picture Control "*" any type
If several
controls of the same type exist in the SAP GUI window you can use the
second parameter n=1,2,3,... to identify further controls of this type.
Example:
Imports GRIDVIEWLIB
Imports SAPTOOLBARLib
...
Dim gridview As GridView = guixt.GetControl("grid")
Dim tb1 As ISAPToolBar = guixt.GetControl("toolbar", 1)
Dim tb2 As ISAPToolBar = guixt.GetControl("toolbar", 2)
using GRIDVIEWLIB;
using SAPTOOLBARLib;
...
GridView gridview = (GridView)guixt.GetControl("grid");
ISAPToolBar tb1 = (ISAPToolBar)guixt.GetControl("toolbar", 1);
ISAPToolBar tb2 = (ISAPToolBar)guixt.GetControl("toolbar", 2);
Please note that the native
control interface should be used for special cases only. Normally SAP
GUI Scirpting is the best way of dealing with the SAP GUI controls. For
further details see "Tips, Tricks and Samples" -> "Native Control
Interface"
Value()
r = guixt.Value(var)
Replaces all GuiXT &-variables
with their values and returns the resulting string.
Example:
Dim matnr As String
matnr = guixt.Value("&F[Material]")
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.
FilePath()
guixt.FilePath(s, [cache=True])
The given string is
interpreted as a relative path in the current GuiXT script folder.
The absolute path,
including the script folder path, is returned
A given absolute path
e.g. C:\guixt\scripts\..." is not changed.
If a path points to
SAP MIME Repository "SAPMR:...",
an http server "http://..." or ftp
server "ftp://..." , a local file copy is
created in GuiXT cache and the cache path of the replicated file is
returned
WIth the default option cache=True
external files are first looked up in cache.
Examples:
imgpath = guixt.FilePath("images\home.gif")
' imgpath is set to e.g. "C:\guixt\scripts1\images\home.gif"
Dim url As String = "http://www.synactive.com/" & _
"images/s10logo_blue.gif"
imgpath = guixt.FilePath(url)
' imgpath is set to e.g.
' "C:\Users\ADMINI~1\AppData\Local\Temp\
' guixt\GuiXT Cache\http\
' www.synactive.com\images\s10logo_blue.gif"
imgpath = guixt.FilePath(@"images\home.gif");
// imgpath is set to e.g. "C:\guixt\scripts1\images\home.gif"
var url = "http://www.synactive.com/images/" +
"s10logo_blue.gif";
imgpath = guixt.FilePath(url);
// imgpath is set to e.g.
// "C:\Users\ADMINI~1\AppData\Local\Temp\
// guixt\GuiXT Cache\http\
// www.synactive.com\images\s10logo_blue.gif"
EmbedForm()
guixt.EmbedForm(ByVal
f As Form, ByVal c As Object) As Boolean
Embeds an interactive
Windows form into the SAP GUI window. Use the ActiveX object "Shell.Explorer" as
a place holder in the SAP GUI screen.
Example:
GuiXT
Control (10,20) (18,80) progID="Shell.Explorer" _
name="d1" initFlag="d1init"
if V[d1init]
CallVB utilities.customer.preview "&V[d1]"
endif
Imports guinet
....
Public Sub preview(ByVal w As Object)
' create new form
Dim f As New Dialog1()
' embed into SAP GUI window
guixt.EmbedForm(f, w)
End Sub
using guinet;
....
public void preview(object w)
{
// create new form
Dialog1 f = new Dialog1();
// embed into SAP GUI window
guixt.EmbedForm(f, w);
}
GuiSession()
guixt.GuiSession()
Returns an object of class guinet.sapguisession
that you can use to execute SAP GUI scripting functions. For details see
GUI Scripting in .NET
Example:
guixt.GuiSession().Enter("/NFB01")
guixt.GuiSession().Enter("/NFB01");
GuiWindow()
guixt.GuiWindow()
Returns an object of class System.Windows.Forms.NativeWindow,
allowing the unique identification of the SAP mode.