SAPGuiUtil Object
Description
A utility object in a SAP GUI for Windows application.
IMPORTANT
Enables you to perform connection operations on your SAP Gui for Windows application during the test run.
Operations
The sections below list the built-in methods and properties that you can use as operations for the SAPGuiUtil object.
Methods
AutoLogon | Connects and logs on to an SAP server. |
AutoLogonByIP | Connects and logs on to an SAP server according to its IP address. |
AutoLogonByTargetSystem | Connects and logs on to an SAP server according to its target system. |
CloseConnections | Closes any SAP connections that were opened by UFT One or by the user. |
OpenConnection | Opens a connection to the specified SAP server. |
OpenConnectionByIP | Opens a connection to the specified SAP server according to its IP address. |
OpenConnectionByTargetSystem | Opens a connection to the specified SAP server according to its target system. |
StartBPCATracing | Begins running the Business Process Change Analyzer to detect changes in a transaction's objects (as compared to the TBOM). |
StopBPCATracing | Stops running the Business Process Change Analyzer. |
AutoLogon Method
Description
Connects and logs on to an SAP server.
Syntax
object.AutoLogon ServerDescription, Client, User, Password, Language
Arguments
Parameter | Description |
---|---|
ServerDescription |
Required. A String value. The server to which you want to log on. The string is case-sensitive and must be identical to the one displayed in the SAP Logon dialog box. |
Client |
Required. A String value. The SAP client you want to use. |
User |
Required. A String value. The username with which you want to log on to the SAP Server. |
Password | Required. A String value. The encrypted value of the password for the specified username. To find the encrypted value to use, do one of the following:
For more information, refer to the UFT One User Guide. |
Language |
Required. A String value. The 2-letter code for the language you want to use. |
Return Type
None
IMPORTANT
The AutoLogon method opens a new connection even if an open session already exists.
Tip: You can also use the SAP tab of the Record and Run Settings dialog box to instruct UFT One to connect and log on to a specific server and client at the beginning of each record and run session.
Example
'The following example uses the AutoLogon method to connect to client "800" of the "Calderone" SAP server, 'using the logon information for the MUSTER user. 'The Password argument is parameterized to take the encrypted value from the Data Pane. SAPGuiUtil.AutoLogon "Calderone", 800, "MUSTER", DataTable("Password", dtLocalSheet), "EN"
AutoLogonByIP Method
Description
Connects and logs on to an SAP server according to its IP address.
Syntax
object.AutoLogonByIP ConnectionString, Client, User, Password, Language, [SystemNumber], [RoutingServers]
Arguments
Parameter | Description |
---|---|
ConnectionString |
Required. A String value. The connection string for the SAP server to which you want to log on. |
Client |
Required. A String value. The SAP client you want to use. |
User |
Required. A String value. The username with which you want to log on. |
Password | Required. A String value. The encrypted value of the password for the specified username. To find the encrypted value to use, do one of the following:
For more information, refer to the UFT One User Guide. |
Language |
Required. A String value. The 2-letter code for the language you want to use. |
SystemNumber |
Optional. A long integer value. The server system number. Default value = 0 |
RoutingServers |
Optional. A String value. The servers that are required in order to reach the server with which you want to connect. Default value = "" |
Return Type
None
Example
'The following example uses the AutoLogonByIP method to log on to the "Calderone" SAP server 'using its IP address instead of its name. 'The Password argument is parameterized to take the encrypted value from the Data Pane. SAPGuiUtil.AutoLogonByIP "/H/212.199.95.5/S/3200", "800", "myuser01", DataTable("Password", dtGlobalSheet), "en", "00"
AutoLogonByTargetSystem Method
Description
Connects and logs on to an SAP server according to its target system.
Syntax
object.AutoLogonByTargetSystem TargetSystem, Client, User, Password, Language
Arguments
Parameter | Description |
---|---|
TargetSystem | Required. A String value. The SAP system environment under test. |
Client | Required. A String value. The SAP client you want to use. |
User | Required. A String value. The username with which you want to log on. |
Password | Required. A String value. The encrypted value of the password for the specified username. To find the encrypted value to use, do one of the following:
For more information, refer to the UFT One User Guide. |
Language | Required. A String value. The 2-letter code for the language you want to use. |
Return Type
None
IMPORTANT
The AutoLogonByTargetSystem method can be used only when you open a GUI test from Solution Manager in integrated mode.
To instruct UFT One to connect and log on to an SAP server according to its target system, use the AutoLogonByTargetSystem method or the Record and Run Settings dialog > SAP tab.
To find the value to use for the TargetSystem parameter, you can check the values suggested for the Target System field in the Record and Run settings dialog > SAP tab.
Example
'The following example uses the AutoLogonByTargetSystem method to log on to the SAP session 'using the target system instead of the session name. SAPGuiUtil.AutoLogonByTargetSystem "C5P", "004", "myuser1", "mypassword", "EN" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SAPGuiOKCode("OKCode").Set "va01" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SendKey ENTER
CloseConnections Method
Description
Closes any SAP connections that were opened by UFT One or by the user.
Syntax
object.CloseConnections
Return Type
None
IMPORTANT
All open SAP connections are closed, both those opened by UFT One, and those opened by the user.
The exception to this is if the Do not record and run on settings that are already open check box is selected in the SAP tab of the Record and Run Settings dialog box. In this case, any sessions that were opened prior to the current session are not closed.
Example
'The following example uses the CloseConnections method to close any connections that were opened by UFT One '(after opening a session on "Calderone" and setting the correct login information). SAPGuiUtil.OpenConnection "Calderone" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Client").Set "800" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("User").Set "myuser01" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Password").SetSecure DataTable("Password_Text", dtGlobalSheet) SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Language").Set "en" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Language").SetFocus SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SendKey ENTER SAPGuiUtil.CloseConnections
OpenConnection Method
Description
Opens a connection to the specified SAP server.
Syntax
object.OpenConnection ServerDescription
Arguments
Parameter | Description |
---|---|
ServerDescription |
Required. A String value. The server to which you want to open a connection. The string is case-sensitive and must be identical to the one displayed in the SAP Logon dialog box. |
Return Type
None
Example
'The following example uses the OpenConnection Method to open a session on the "Calderone" SAP server. It then enters 'the logon information for the user. When the logon is complete, it closes all connections that were opened by UFT One. SAPGuiUtil.OpenConnection "Calderone" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Client").Set "800" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("User").Set "myuser01" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Password").SetSecure DataTable("Password_Text", dtGlobalSheet) SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Language").Set "en" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Language").SetFocus SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SendKey ENTER SAPGuiUtil.CloseConnections
OpenConnectionByIP Method
Description
Opens a connection to the specified SAP server according to its IP address.
Syntax
object.OpenConnectionByIP ConnectionString, [SystemNumber], [RoutingServers]
Arguments
Parameter | Description |
---|---|
ConnectionString |
Required. A String value. The connection string for the SAP server to which you want to open a connection. |
SystemNumber |
Optional. A long integer value. The server system number. Default value = 0 |
RoutingServers |
Optional. A String value. The servers that are required in order to reach the server with which you want to connect. Default value = "" |
Return Type
None
Example
'The following example uses the OpenConnectionByIP Method to open a session on the "Calderone" SAP Server using 'its IP address instead of its name. It then enters the login information for the user and logs on. If the login 'is unsuccessful, it reports this to the run results. SAPGuiUtil.OpenConnectionByIP "10.168.11.57", 0 If SAPGuiSession("Session").Exist Then SAPGuiSession("Session").SAPGuiWindow("SAP").Resize 142, 27 SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("User").Set "myuser01" SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Password").SetSecure DataTable("Password", dtGlobalSheet) SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Language").Set "en" SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Language").SetFocus SAPGuiSession("Session").SAPGuiWindow("SAP").SendKey ENTER Else Reporter.ReportEvent micFail, "Session was not invoked", "Session was not invoked. Please verify your connection string!" End If
OpenConnectionByTargetSystem Method
Description
Opens a connection to the specified SAP server according to its target system.
Syntax
object.OpenConnectionByTargetSystem TargetSystem
Arguments
Parameter | Description |
---|---|
TargetSystem |
Required. A String value. Note: To find the value to use for this parameter, see AutoLogonByTargetSystem Method. |
Return Type
None
IMPORTANT
The OpenConnectionByTargetSystem method can be used only when you open a GUI test from Solution Manager in integrated mode.
Example
'The following example uses the OpenConnectionByTargetSystem Method to open a session using 'the target system instead of the session name. It then enters the login information for the user 'and logs on. If the login is unsuccessful, it reports this to the run results. SAPGuiUtil.OpenConnectionByTargetSystem ("C5P") SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("User").Set "myuser01" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SAPGuiEdit("Password").Set "mypassword" SAPGuiSession("Session").SAPGuiWindow("SAP R/3").SendKey ENTER SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SAPGuiOKCode("OKCode").Set "va01" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SendKey ENTER Else Reporter.ReportEvent micFail, "Session was not invoked", "Session was not invoked. Please verify your connection string!" End If
StartBPCATracing Method
Description
Begins running the Business Process Change Analyzer to detect changes in a transaction's objects (as compared to the TBOM).
Syntax
object.StartBPCATracing
Return Type
None
Example
'The following example uses the AutoLogonByTargetSystem Method to open a session using 'the target system instead of the session name. It then begins running the Business Process 'Change Analyzer to detect changes in a transaction's objects (as compared to the TBOM). 'Finally, it stops the running the Business Process Change Analyzer. SAPGuiUtil.AutoLogonByTargetSystem "C5P", "004", "user1", "mypassword", "EN" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SAPGuiOKCode("OKCode").Set "va01" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SendKey ENTER SAPGuiUtil.StartBPCATracing SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Order Type").Set "10" SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Sales organization").Set "1000" SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Distribution channel").Set "10" SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Distribution channel").SetFocus SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SendKey ENTER SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiStatusBar("StatusBar").Sync SAPGuiUtil.StopBPCATracing
StopBPCATracing Method
Description
Stops running the Business Process Change Analyzer.
Syntax
object.StopBPCATracing
Return Type
None
Example
'The following example uses the AutoLogonByTargetSystem Method to open a session using 'the target system instead of the session name. It then begins running the Business Process 'Change Analyzer to detect changes in a transaction's objects (as compared to the TBOM). 'Finally, it stops the running the Business Process Change Analyzer. SAPGuiUtil.AutoLogonByTargetSystem "C5P", "004", "user1", "mypassword", "EN" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SAPGuiOKCode("OKCode").Set "va01" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SendKey ENTER SAPGuiUtil.StartBPCATracing SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Order Type").Set "10" SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Sales organization").Set "1000" SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Distribution channel").Set "10" SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiEdit("Distribution channel").SetFocus SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SendKey ENTER SAPGuiSession("Session").SAPGuiWindow("Create Sales Order: Initial").SAPGuiStatusBar("StatusBar").Sync SAPGuiUtil.StopBPCATracing
See also: