Tip: How to Check SAP Network Speed During the Runtime of a Workflow

Sometimes the network settings of the SAP connection causes problems, if they are set to low.

image

SAP note 587202 tells us the reasons for this behaviour: “If the low speed connection indicator is set for a connection, less information is transferred to SAP GUI. As a result, the scripting component is missing the field names that are required for the names and IDs of the objects in the scripting model. Errors then occur (for example, with FindById).”

In the context of process automation with any RPA platform means this low speed connection setting a disadvantaged condition. More information are available in this post about Automation of an SAP Session with Low Speed Connection. As @LevKushnir wrote: " LowSpeedConnection is not suitable for SAP automation and activating this mode will have an impact on the functionality of SAP GUI for Windows. Therefore in our documentation HighSpeedConnection is a must for the successful automation."

Here a solution to check the speed connection of a session in a workflow. Create a VBScript file, e.g. with the name CheckSAPConnectionSpeed.vbs, in your process directory. Here the VBScript code:

'-Begin-----------------------------------------------------------------

'-Directives------------------------------------------------------------
Option Explicit

'-Function getSessionFromId---------------------------------------------
Function getSessionFromId(Id)

  Dim SapGuiAuto, app
  Dim connections, connection
  Dim sessions, session, sessionID
  Dim i, j

  Set SapGuiAuto = GetObject("SAPGUI")
  If Not IsObject(SapGuiAuto) Then
    Exit Function
  End If

  Set app = SapGuiAuto.GetScriptingEngine
  If Not IsObject(app) Then
    Exit Function
  End If

  Set connections = app.Connections()
  If Not IsObject(connections) Then
    Exit Function
  End If

  '-Loop over connections-----------------------------------------------
  For i = 0 To connections.Count() - 1

    Set connection = app.Children(CLng(i))
    If IsObject(connection) And connection.DisabledByServer = False Then

      Set sessions = connection.Sessions()
      If IsObject(sessions) Then

        '-Loop over sessions--------------------------------------------
        For j = 0 To sessions.Count() - 1

          Set session = connection.Children(CLng(j))
          If IsObject(session) And session.Busy() = False Then

            If session.Info.SystemSessionId = Id Then
              Set getSessionFromId = session
            End If

          End If 

        Next

      End If
      
    End If  

  Next

End Function

'-Main------------------------------------------------------------------
Dim session

On Error Resume Next
Set session = getSessionFromId(WScript.Arguments.Item(0))
On Error GoTo 0
If Not IsObject(session) Then
  WScript.Echo "No session found"
  WScript.Quit
End If

If session.Info.IsLowSpeedConnection = True Then
  WScript.Echo "LowSpeedConnection"
  WScript.Quit
Else
  WScript.Echo "HighSpeedConnection"
End If

'-End-------------------------------------------------------------------

This code contains a Main section and a getSessionFromId function. In the Main section the function it is called and the return value is LowSpeedConnection or HighSpeedConnection. The function itself is very easy to understand. It loops over all connections with their sessions and when it has found the session with the passed ID it returns the session object.

image

To get the ID we use a tiny trick which published @andrzej.kniola here. In the SAP window scope we add an output variable.

image

We assign this output variable to another variable of the type UiElement.

image

With this step we have access to all variables of the window, e.g. sapSysSessionId.

image

And this sapSysSessionId is the input for the VBScript code. Here it loops over all sessions to find the correct one. If the right one has been found, the IsLowSpeedConnection property is queried via the GuiSessionInfo class. The result is returned to the calling workflow.

This approach offers the possibility to check at the runtime of a workflow if the operating requirements are met. Depending on the answer, an appropriate procedure can be initiated.

A further perspective of this approach is to detect all information which offers SAP GUI Scripting classes. We discuss a few possibilities here. On the same way it is possible to uncouple SAP GUI Scripting from the automation workflow, with all the advantages and disadvantages.

6 Likes