SapGuiOpenConnection Function

Action

Opens a connection to the SAP server specified by a connection string.

Include file

SapGui.bdh

Syntax

SapGuiOpenConnection( in sConnString : string ) : string;
Parameter Description
sConnString SAP Connection String

Return value

  • Connection ID if successful
  • Null otherwise

Example

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

    // 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;