|
Purpose |
The .NET class library
guinet.dll provides a
comfortable interface for calling SAP GUI scripting functions from
.NET.
This can be a call of
.NET function from GuiXT by using the command
CallVBAsync
(component
GuiXT Controls) or an external .NET program that runs independently from
GuiXT. Also the mobile applications of Synactive GmbH (S10 technology,
CIS mobile) uses guinet.dll.
The events
triggered by guinet.dll are logged in the GuiXT InputScript trace.
Prerequisites:
- SAP GUI Scripting is
activated on the SAP server and also on the client PC
- The
interface-classLibrary Interop.SAPFEWSELib.dll exists in the
.NET directory. This file is created automatically by Visual
Studio after adding a reference to the COM-Object "SAP GUI Scripting
API" to the project.
Please make sure that you include this reference after having set
the .NET target framework to version 4.0. On compiling to target version 3.5 or
below and copying the file Interop.SAPFEWSELib.dll
to the .NET directory some incompatibility problems will occur.
|
|
Calling the scripting functions |
In order to call the scripting
functions please use the object guinet.GuiSession. The script will
automatically work with the SAP GUI sessions from where CallVBAsync was
called.
When using guinet.dll in your own .NET program, independently from
GuiXT CallVBAsync, it is necessary to start an SAP GUI session with
GuiSession.Logon().
Example 1:
' start transaction FB01
Dim guixt As New guinet.guixt
guixt.GuiSession.Enter("/NFB01")
' set company code
guixt.GuiSession.SetField("BKPF-BUKRS", "0001")
// start transaction FB01
var guixt = new guinet.guixt();
guixt.GuiSession().Enter("/NFB01");
// set company code
guixt.GuiSession().SetField("BKPF-BUKRS", "0001");
Example 2:
A more detailed example application can be found here:
GuiNET Demo
|
|
Calling
"native" SAP GUI Scripting |
If you may need to call
"native" SAP GUI scripting functions besides those provided by
guinet.dll from your .NET function, then you can reach them via guixt.GuiSession.GuiApplication
and guixt.GuiSession.GuiActiveWindow.
Example 1:
MsgBox("SAP GUI Version: "
& guixt.GuiSession.GuiApplication.MajorVersion)
MessageBox.Show("SAP GUI Version: "
+ guixt.GuiSession().GuiApplication.MajorVersion);
Example 2:
guixt.GuiSession.GuiActiveWindow.FindById(
"usr/ctxtBKPF-BUKRS").text = "0001"
guixt.GuiSession().GuiActiveWindow.FindById(
"usr/ctxtBKPF-BUKRS").Text = "0001";
The notation
of the native SAP GUI scripting reflects the internal subscreen
structure
of a SAP dynpro and is therefore only of much use in practise when
recording scripts. E.g. the SAP GUI scripting standard notation in
transaction VA01 is simplified from
guixt.GuiSession.GuiActiveWindow.findById
("usr/subSUBSCREEN_HEADER:SAPMV45A:4021/subPART-SUB:
SAPMV45A:4701/ctxtKUWEV-KUNNR").text = mykunnr
guixt.GuiSession().GuiActiveWindow.findById;
("usr/subSUBSCREEN_HEADER:SAPMV45A:4021/subPART-SUB:
SAPMV45A:4701/ctxtKUWEV-KUNNR").text = mykunnr;
with
the guinet-interface to
guixt.GuiSession.SetField("KUWEV-KUNNR", mykunnr)
guixt.GuiSession().SetField("KUWEV-KUNNR", mykunnr);
and which can also be written down without script-recording, if one knows
the technical fieldname "KUWEV-KUNNR" (e.g. by using F1 when the cursor
is inside a SAP field).
The sap standard help for the SAP GUI scripting containing the
description of all "native" functions is available in the SAP GUI via
menu "Help to SAP GUI scripting".
|
|
Click() |
Public Sub Click(ByVal name As String)
public void Click(string name)
Mouseclick (single) on the
given element (e.g. input/output field). Please provide the technical
name of the element as "name".
Example:
' click on
Ship-to party
guixt.guisession.Click( " KUWEV-KUNNR " )
// click on
Ship-to party;
guixt.guisession().Click( " KUWEV-KUNNR " )
|
|
ClickGridCell() |
Public Sub ClickGridCell(
ByVal row As Integer,
ByVal colname As String,
Optional ByVal index As Integer = 0)
public void ClickGridCell(
int row, string colname,
int index = 0)
Mouseclick onto a cell inside
a Grid Control.
|
|
ClickTableCell() |
Public Sub ClickTableCell(
ByVal row As Integer,
ByVal colname As String)
Public Sub ClickTableCell(
ByVal tabname As String,
ByVal row As Integer,
ByVal colname As String)
public void ClickTableCell(
int row, string colname)
public void ClickTableCell(
string tabname, int row,
string colname)
Mouseclick into a cell inside
a Table Control. The first variant can be used if there is only one
table on the screen.
|
|
DoubleClick() |
Public Sub DoubleClick(ByVal name As String)
public void DoubleClick(string name)
Doubleblick onto the given
element (e.g. input/output field). Please provide the technical name of
the element as "name".
Example:
' doubleclick on
Ship-to party
guixt.guisession.DoubleClick( " KUWEV-KUNNR " )
// doubleclick on
Ship-to party;
guixt.guisession().DoubleClick( " KUWEV-KUNNR " )
|
|
DoubleClickGridCell() |
Public Sub DoubleClickGridCell(
ByVal row As Integer,
ByVal colname As String,
Optional ByVal index As Integer = 0)
public void DoubleClickGridCell(
int row, string colname,
int index = 0)
Doubleclick onto a cell in a
Grid Control.
|
|
DoubleClickTableCell() |
Public Sub DoubleClickTableCell(
ByVal row As Integer,
ByVal colname As String)
Public Sub DoubleClickTableCell(
ByVal tabname As String,
ByVal row As Integer,
ByVal colname As String)
public void DoubleClickTableCell(
int row, string colname)
public void DoubleClickTableCell(
string tabname, int row,
string colname)
Doubleclick into a cell in a
Table Control. The first variant can be used if there is only one table
on the screen.
|
|
DoubleClickTreeNode() |
Public Sub DoubleClickTreeNode(
ByVal nodekey As String,
Optional ByVal index As Integer = 0)
public void DoubleClickTreeNode(
string nodekey, int index = 0)
Doubleclick into a tree-node (key).
|
|
DoubleClickTreeItem() |
Public Sub DoubleClickTreeItem(
ByVal nodekey As String,
ByVal item As String,
Optional ByVal index As Integer = 0)
public void DoubleClickTreeItem(
string nodekey, string item,
int index = 0)
Doubleclick onto an element of
the tree.
|
|
Enter() |
Public Function Enter(
Optional ByVal cmd As String = "",
Optional ByVal IgnoreWarning As Boolean = True,
Optional ByVal ReturnError As Boolean = False,
Optional ByVal IgnoreInfoPopup As Boolean = False,
Optional ByRef msg As String = "") As Boolean
public bool Enter(
string cmd = "",
bool IgnoreWarning = true,
bool ReturnError = false,
bool IgnoreInfoPopup = false,
ref string msg)
Enter of a function-code, e.g.
guixt.guisession.Enter("=V43D_GET")
guixt.guisession().Enter("=V43D_GET");
or
guixt.guisession.Enter("/NVA03")
guixt.guisession().Enter("/NVA03");
The additions options can be used to
define, of messages or popups should automatically be confirmed. |
|
FindField() |
Public Function FindField(
ByVal name As String) As GuiComponent
public GuiComponent FindField(string name)
Searches an element via
technical name and returns it as GuiComponent-object of the SAP GUI
scripting. If nothing was found: Returns Nothing.
|
|
GetField() |
Public Function GetField(
ByVal name As String,
Optional ByVal text As Boolean = False)
As String
public string GetField(
string name, bool text = false)
The content of any input/output
field, a checkbox, a radiobutton or a combobox. Please provide the
technical name as "name". Example:
vbapnetwr =
guixt.guisession.GetField("VBAP-NETWR")
- Returning "" or "X"
for checkboxes and radiobuttons
- For comboboxes the value of the key is
returned unless you
provide the optional parameter "text"
True,then the text instead of the value is returned.
|
|
GetFieldIcon() |
Public Function GetFieldIcon(
ByVal name As String) As String
public string GetFieldIcon(string name)
Searches an element via
technical name and returns the name of the icon, if the text starts with
an icon, "" else.
|
|
GetGridCell() |
Public Function GetGridCell(
ByVal row As Integer,
ByVal colname As String,
Optional ByVal index As Integer = 0,
Optional ByRef found As Boolean = False)
As String
public string GetGridCell(
int row, string colname,
int index = 0, ref bool found)
Reads the contenet of a cell
in a Grid Control.
|
|
GetTableCell() |
Public Function GetTableCell(
ByVal row As Integer,
ByVal colname As String) As String
Public Function GetTableCell(
ByVal tabname As String,
ByVal row As Integer,
ByVal colname As String) As String
public string GetTableCell(
int row, string colname)
public string GetTableCell(
string tabname, int row,
string colname)
Reads the content of a cell in
a Table Control. The first variant can be used if there is only one
table on the screen.
|
|
GuiGridView() |
Public ReadOnly Property GuiGridView()
As GuiGridView
public GuiGridView GuiGridView { get; }
Returns the current Grid
Control as GuiGridView object of the SAP GUI scripting or nothing, if
there is no active grid. If there is more than one grid, the first one
is returned.
|
|
GuiGridViews() |
Public ReadOnly Property GuiGridViews()
As List(Of GuiGridView)
public List GuiGridViews { get; }
Return a list of all current
grid controls.
|
|
GuiTableControl() |
Public ReadOnly Property GuiTableControl()
As GuiTableControl
public GuiTableControl GuiTableControl { get; }
Returns the current Table
Control as GuiTabelControl object of the SAP GUI scripting, or nothing,
of there is no active TableControl.
Optional: The technical name of the table can be provided e.g.
Dim tc As GuiTableControl
tc = guixt.guisession.GuiTableControl( _
"SAPMV45A_TCTRL_U_ERF_AUFTRAG")
GuiTableControl tc;
tc = guixt.guisession().GuiTableControl(
"SAPMV45A_TCTRL_U_ERF_AUFTRAG");
|
|
GuiTree() |
Public ReadOnly Property GuiTree() As GuiTree
public GuiTree GuiTree { get; }
Returns the current Tree as
GuiTree object of the SAP GUI Scripting or nothing, of there is no
active Tree. If there is more than one tree the first one is returned.
|
|
GuiTrees() |
Public ReadOnly Property GuiTrees()
As List(Of GuiTree)
public List GuiTrees { get; }
Returns a list of all currentr
Trees.
|
|
IsTabActive() |
Public ReadOnly Property IsTabActive(
ByVal tabid As String) As Boolean
public bool IsTabActive(string tabid)
Checks if a certain tab
is active. Example:
If guixt.guisession.IsTabActive("T/03") Then
End If
if (guixt.guisession().IsTabActive("T/03"))
{
}
|
|
Logoff() |
Public Function Logoff() As Boolean
public bool Logoff()
The SAP GUI session will be
closed.
|
|
Logon() |
Public Function Logon(
Optional ByRef ParErrorMessage As String = Nothing,
Optional ByVal HideWindow As Boolean = False)
As Boolean
public bool Logon(
ref string ParErrorMessage,
bool HideWindow = false)
Only required on working
without reference to GuiXT because with GuiXT the SAP GUI Scripting always
refers to the current SAP GUI window.
Logs on to the SAP system
using the parameters set on creating thte sapguisession-object (connectionstring,
username etc.)
Optional: The SAP GUI window can be switched to invisible mode by using
the parameter HideWindow. Then only the dialog-window of your .NET
program is visible to the user and all SAP GUI actions will be processed
in the background.
|
|
MessageId() |
Public ReadOnly Property MessageId() As String
public string MessageId { get; }
The message class, e.g. "02".
|
|
MessageNumber() |
Public ReadOnly Property MessageNumber() As String
public string MessageNumber { get; }
The message number, e.g.
"100".
|
|
MessageParameter1() |
Public ReadOnly Property MessageParameter1() As String
public string MessageParameter1 { get; }
Parameter 1 in the message.
|
|
MessageParameter2() |
Public ReadOnly Property MessageParameter2() As String
public string MessageParameter2 { get; }
Parameter 2 in the message.
|
|
MessageParameter3() |
Public ReadOnly Property MessageParameter3() As String
public string MessageParameter3 { get; }
Parameter 3 in the message.
|
|
MessageParameter4() |
Public ReadOnly Property MessageParameter4() As String
public string MessageParameter4 { get; }
Parameter 4 in the message.
|
|
MessageText() |
Public ReadOnly Property MessageText() As String
public string MessageText { get; }
The text of the message.
|
|
MessageType() |
Public ReadOnly Property MessageType() As String
public string MessageType { get; }
If a message is displayed
on the screen, the message type "E" for error, "I" for information and
"W" for warning. Else "".
|
|
New() |
Public Sub New(
ByVal ConnectionString As String,
ByVal LogonClient As String,
ByVal LogonUser As String,
ByVal LogonPassword As String,
ByVal LogonLanguage As String)
public sapguisession(
string ConnectionString,
string LogonClient, string LogonUser,
string LogonPassword,
string LogonLanguage)
Only required on working
without reference to GuiXT because with GuiXT the SAP GUI Scripting always
refers to the current SAP GUI window and you can get the
sapguisession-object by calling guixt.sapguisession().
Creates a new object of class
guinet.sapguisession using the given parameters for the following logon().
|
|
NewSession() |
Public Function NewSession(
ByVal tcode As String) As sapguisession
public sapguisession NewSession(string tcode)
Starts a new SAP GUI mode
with given transaction.
|
|
ReadGrid() |
Public Function ReadGrid(
ByVal dt As DataTable,
Optional ByVal index As Integer = 0)
As Boolean
public bool ReadGrid(
DataTable dt, int index = 0)
Read in the content of the
current Grid Control into a .NET object of class System.Data.DataTable.
Those columns
that have corresponding names in the DataTable object will be read.
If there is more than one Grid
Control on the screen, you can provide the number as index.
|
|
ReadComboBox() |
Public Function ReadComboBox(
ByVal dt As DataTable,
ByVal name As String) As Boolean
public bool ReadComboBox(
DataTable dt, string name)
Read in the content of a
combobox into a .NET object of class System.Data.DataTable.
The keys will be read into the
first column, the texts into the second column.
|
|
ReadTable() |
Public Function ReadTable(
ByVal dt As DataTable,
Optional ByVal tabname As String = "")
As Boolean
public bool ReadTable(
DataTable dt, string tabname = "")
Read the content of a Table
Control into a .NET object of class System.Data.DataTable.
Those columns
that have corresponding names in the DataTable object will be read.
As "tabname" you can provide
the technical name of the table.
|
|
ReadTree() |
Public Function ReadTree(
ByVal dt As DataTable,
Optional ByVal nodekey As String = "",
Optional ByVal index As Integer = 0,
Optional ByVal depth As Integer = 100000)
As Boolean
public bool ReadTree(
DataTable dt, string nodekey = "",
int index = 0, int depth = 100000)
Read the content of a tree as
Vb.NET object of class System.Data.DataTable.
The following columns will be
filled if they exist in the DataTable object:
- nodekey
- nodepath
- nodetext
- nodelevel
- nodelabel
Optional: You can provide a node "nodekey" that functions as root for
reading this sub-tree, the index 0,1,2 if there is more than one tree
and the depth until the structure of the tree should be resolved.
|
|
ScreenId() |
Public ReadOnly Property ScreenId() As String
public string ScreenId { get; }
Returns the current program
name and dynpro number e.g. " SAPMV45A.0100"
|
|
ScreenTitle() |
Public ReadOnly Property ScreenTitle() As String
public string ScreenTitle { get; }
Returns the current title,
e.g. "Create Sales Order: Initial Screen"
|
|
SetField() |
Public Sub SetField(
ByVal name As String,
ByVal value As String)
public void SetField(string name, string value)
Sets the content of an
inputfield, a checkbox, a radiobutton or a combobox. Please provide the
technical name as "name". Example:
guixt.guisession.SetField("RF02D-KUNNR",
customernumber)
- On using checkboxes or
radiobuttons only "" or "X" can be set
- On using a combobox,
you set the value of the key, not the text
|
|
SetLicense() |
Public Function SetLicense(
ByVal license As String) As Boolean
public bool SetLicense(string license)
If you would like to use
guinet.dll within your own .NET program without reference to GuiXT,
then you have to provide a valid licensekey before using the
logon-command. The "GuiXT controls" component includes this license; you
can obtain the licensekey from Synactive.
|
|
SetGridCell() |
Public Sub SetGridCell(
ByVal row As Integer,
ByVal colname As String,
ByVal value As String,
Optional ByVal index As Integer = 0)
public void SetGridCell(
int row, string colname,
string value, int index = 0)
Sets the content of a cell in
a Grid Control.
|
|
SetTableCell() |
Public Sub SetTableCell(
ByVal row As Integer,
ByVal colname As String,
ByVal value As String)
Public Sub SetTableCell(
ByVal tabname As String,
ByVal row As Integer,
ByVal colname As String,
ByVal value As String)
public void SetTableCell(
int row, string colname,
string value)
public void SetTableCell(
string tabname, int row,
string colname, string value)
Sets the content of a cell in
a Table Control. You can use the first variant if there is only one
table on the screen.
|
|
SelectTableRow() |
Public Sub SelectTableRow(
ByVal row As Integer)
Public Sub SelectTableRow(
ByVal tabname As String,
ByVal row As Integer)
public void SelectTableRow(int row)
public void SelectTableRow(
string tabname, int row)
Selects a table-cell.
You can use the first variant if there is only one table on the screen.
The table-cell will be
scrolled into the visible sector of the table if neccessary.
|
|
TableCellExists() |
Public Function TableCellExists(
ByVal row As Integer,
ByVal colname As String,
Optional ByRef g As GuiComponent = Nothing)
As Boolean
Public Function TableCellExists(
ByVal tabname As String,
ByVal row As Integer,
ByVal colname As String,
Optional ByRef g As GuiComponent = Nothing)
As Boolean
public bool TableCellExists(
int row, string colname,
ref GuiComponent g)
public bool TableCellExists(
string tabname, int row,
string colname, ref GuiComponent g)
Checks if a certain table-cell
exists. Optional: The table-cell will be provided as object of class
GuiComponent.
The table-cell will be
scrolled into the visible sector of the table if neccessary.
|
|
Component |
GuiXT +
Controls |