Creates a new SAP session for the current SAP connection. The SAP system normally allows 6 sessions per connection.
SapGui.bdh
SapGuiCreateSession( );
transaction TMain
var
begin
// Connecting to SAP
SapGuiOpenConnection(" /SAP_CODEPAGE=1100 /FULLMENU lab77 00/3");
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", "");
SapGuiCreateSession();
SapSetActiveSession("ses[1]");
// 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);
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;