Opens a connection to the SAP server specified by the name of connection as specified in the Saplogon tool.
SapGui.bdh
SapGuiOpenConnectionByName( in sConnName : string, inout sId : dstring optional ) : boolean;
Parameter | Description |
---|---|
sConnName | The name of the connection profile as specified in the SapLogon tool |
sId | This parameter will be assigned the id of the connection. |
transaction TMain
var
sId : string;
begin
// Connecting to SAP
SapGuiOpenConnectionByName("incantation", sId);
SapGuiSetActiveConnection("/app/con[0]");
SapGuiSetActiveSession("ses[0]");
// SAP
SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_Exact);
SapGuiWindowResize(117, 28, false);
// Logon to SAP System
// Before running a test you have to customize the password parameter!
ThinkTime(5.3);
SapGuiLogon("bcuser", "*******", "000", "");
// Copyright
SapGuiSetActiveWindow("wnd[1]", "Copyright", SAPGUI_MATCH_Exact);
// Continue (Enter)
SapGuiPressButton("tbar[0]/btn[0]", "Continue (Enter)");
// SAP Easy Access
SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_Exact);
// Other menu
SapGuiPressButton("tbar[1]/btn[17]", " Other menu");
// Restrict Values
SapGuiSetActiveWindow("wnd[1]", "Restrict Values", SAPGUI_MATCH_Exact);
// Cancel (F12)
SapGuiPressButton("tbar[0]/btn[12]", "Cancel (F12)");
// SAP Easy Access
SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_Exact);
// Log off (Shift+F3)
SapGuiPressButton("tbar[0]/btn[15]", "Log off (Shift+F3)");
// Log Off
SapGuiSetActiveWindow("wnd[1]", "Log Off", SAPGUI_MATCH_Exact);
// Yes
SapGuiPressButton("usr/btnSPOP-OPTION1", "Yes");
end TMain;