SapGuiRestart Function

Action

Restarts the SapGui engine. The restart is not performed gracefully, and open sessions or open connections will not be closed gracefully. Instead, the whole SapGui engine will be restarted, which involves starting a new process. Therefore, this function should only be called in exceptional situations where the script detects an unstable or inconsistent state from which it cannot recover to a consistent starting state for the next transaction.

Include File

SapGui.bdh

Syntax

SapGuiRestart() : boolean;

Return Value

  • true if successful
  • false otherwise

Example

transaction TMain
  var
    inconsistentStateDetected : boolean;
    gsConnID : string;
  begin
    // Connecting to SAP
    gsConnID := SapGuiOpenConnection("/SAP_CODEPAGE=1100  /FULLMENU  atlis-minisap 00 /3 /UPDOWNLOAD_CP=2", "SapGuiOpenConnection");
    SapGuiSetActiveConnection(gsConnID);
    SapGuiSetActiveSession("ses[0]");
	
    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_ExactNoCase);
    SapGuiWindowAction(SAPGUI_WND_MAXIMIZE, "SapGuiWindowAction\\SAPGUI_WND_MAXIMIZE");
	
    // Logon to SAP System
    // Before running a test you have to customize the password parameter!
    ThinkTime(5.8);
    SapGuiLogon("bcuser", "minisap", "001", "", "SapGuiLogon");
	
    // SAP Easy Access
    SapGuiIgnoreError(SAPENGINE_STATUSBAR_CHANGED, SEVERITY_SUCCESS);
    SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_ExactNoCase);
	

    // do some SapGui actions ...
    inconsistentStateDetected := true;

    // TODO: write code to check for inconsistent state (dependent on the certain script)
    if (inconsistentStateDetected) then SapGuiRestart();

      // Now we have a clean state for the next transaction.
    else

      // In normal situations we just log out.
      SapGuiWindowAction(SAPGUI_WND_CLOSE, "SapGuiWindowAction\\SAPGUI_WND_CLOSE");
      ThinkTime(0.5);

      // Log Off
      SapGuiSetActiveWindow("wnd[1]", "Log Off", SAPGUI_MATCH_ExactNoCase);
		
      // Yes
      SapGuiPressButton("usr/btnSPOP-OPTION1", "SapGuiPressButton\\Yes");
    end;
  end TMain;