This is a common problem that most of the beginners face.
How to open SAP through QTP?. I thought of posting about this.
There is an utility object from QTP for SAP . It is “SAPGuiUtil”.
SAPGuiUtil supports multiple methods. Below is the list of
them with small description.
1. Autologon --
-- Connects and logs on to an SAP
Server
2. AutoLogonByIP -----
Connects and logs on to SAP server according to its IP address.
3. CloseConnections-----
Closes any SAP connections that were opened by QTP or by user.
4. OpenConnection ----- Opens a connection to the specified SAP
server.
5. OpenConnectionByIP --- Opens a connection to the specified SAP
server according to its IP.
Let’s have a look at each one of them.
1. Autologon : The AutoLogon method opens a new
connection even if an open session already exists.
Syntax :
SAPGuiUtil.Autologon
<ServerDescription>,<Client>,<User>,<Password>,<Language>
'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 Table.
SAPGuiUtil.AutoLogon "Calderone", 800,
"MUSTER", DataTable("Password",dtLocalSheet),”EN”
2. AutoLogonByIP : Connects
and logs on to an SAP server according to its IP address.
“SAPGuiUtil.AutoLogonByIP
<ConnectionString>, <Client>, <User>, <Password>, <Language>,
[SystemNumber], [RoutingServers]”
Below is the 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 Table.
SAPGuiUtil.AutoLogonByIP "/H/212.199.95.5/S/3200",
"800", "QA01", DataTable("Password",
dtGlobalSheet), "en", "00"
3. CloseConnections : Closes any SAP connections that were opened
by QuickTest or by the user.
Syntax: SAPGuiUtil.CloseConnections
4. OpenConnection : Opens a connection to the specified SAP
server.
SAPGuiUtil.OpenConnection ServerDescription
Below is an
example.
Sapguiutil.OpenConnection “A:Test Server”
SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("User").Set
strUserID
SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Password").SetSecure
strPassword
SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiButton("Enter").Click
5. OpenConnectionByIP : Opens a
connection to the specified SAP server according to its IP address.
Syntax: object.OpenConnectionByIP ConnectionString,
[SystemNumber], [RoutingServers]
Below is the example.
SAPGuiUtil.OpenConnectionByIP
"10.168.11.57", 0
Hope this would help my readers. Please note this reference
was taken from QTP help.