Purpose The VB.NET class library  guinet.dll provides a comfortable interface for calling SAP GUI scripting functions from VB.NET.

This can be a call of VB.NET function from GuiXT by using the command CallVBAsync (component GuiXT Controls) or an external VB.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 VB.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 VB.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 VB.NET program, independently from GuiXT CallVBAsync, it is neccessary 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")

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 VB.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)

Example 2:
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

with the  guinet-interface to

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)

Mouseclick (single) on the given element (e.g. input/output field). Please provide the technical name of the element as "name".

Exampel:

' 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)

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)

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)

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")

DoubleClickGridCell() Public Sub ClickGridCell(ByVal row As Integer, ByVal colname As String, Optional ByVal index As Integer = 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)

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)

Doubleclick into a tree-node (key).

DoubleClickTreeItem() Public Sub DoubleClickTreeItem(ByVal nodekey As String, ByVal item As String, Optional ByVal index As Integer = 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

Enter of a function-code, e.g.

guixt.guisession.Enter("=V43D_GET")

or

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

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

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

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

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

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

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)

Return a list of all current grid controls.
 

GuiTableControl() Public ReadOnly Property GuiTableControl() As GuiTableControl

Returns the current Table Control as GuiTabelControl object of thte 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")

GuiTree() Public ReadOnly Property GuiTree() As GuiTree

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 GuiTrees)

Returns a list of all currentr Trees.
 

IsTabActive() Public ReadOnly Property IsTabActive(ByVal tabid As String) As Boolean

Checks if a certain tab is active. Example:

If guixt.guisession.IsTabActive("T/03")

Endif

Logoff() Public Function Logoff() As Boolean

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

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 VB.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

The message class, e.g. "02".

MessageNumber() Public ReadOnly Property MessageNumber() As String

The message number, e.g. "100".

MessageParameter1() Public ReadOnly Property MessageParameter1Id() As String

Parameter 1 in the message.

MessageParameter2() Public ReadOnly Property MessageParameter1Id() As String

Parameter 2 in the message.

MessageParameter3() Public ReadOnly Property MessageParameter1Id() As String

Parameter 3 in the message.

MessageParameter4() Public ReadOnly Property MessageParameter1Id() As String

Parameter 4 in the message.

MessageText() Public ReadOnly Property MessageText() As String

The text of the message.

MessageType() Public ReadOnly Property MessageType() As String

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
)

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

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

Read in the content of the current Grid Control into a VB.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

Read in the content of a combobox into a VB.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

Read the content of a Table Control into a VB.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

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

Returns the current program name and dynpro number e.g. " SAPMV45A.0100"
 

ScreenTitle() Public ReadOnly Property ScreenTitle() As String

Returns the current title, e.g. "Create Sales Order: Initial Screen"

SetField() Public Sub SetField(ByVal name As String, ByVal value As String)

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

If you would like to use guinet.dll within your own VB.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)

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)

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)

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

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