title: SAP GUI Script & VBA: Get System Name / ID
body: <p>I have already created a gui scripting to automate some task. Now, there is a part where I needed to get the SAP system ID / Name. I need get the system ID / Name where the user is currently logged on.</p>
  
  <p>Currently I am using Q4N. So far below is my Code: </p>
  
  <pre><code>Dim app As Variant      
  Dim SAPGUIAuto As Object 
  Dim Connection As Variant 
  Dim session As Variant
  Dim MainPage as Worksheet
  set MainPage = Sheets("Main")
  
  If Not IsObject(app) Then
  Set SAPGUIAuto = GetObject("SAPGUI")
  Set app = SAPGUIAuto.GetScriptingEngine
  End If
  If Not IsObject(Connection) Then
  Set Connection = app.Children(0)
  End If
  If Not IsObject(session) Then
  Set session = Connection.Children(0)
  End If
  If IsObject(WScript) Then
  WScript.ConnectObject session, "on"
  WScript.ConnectObject app, "on"
  End If
  
  Set Info = session.Info()
  
  MainPage.Range("E22") = Val(Info.SystemName())
  </code></pre>
  
  <p>I tried to display this Info.SystemName() but it gives me zero number. </p>
  
  <p>I also tried recording a script in order to get this info: </p>
  
  <p><a href="https://i.stack.imgur.com/2e3VS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2e3VS.jpg" alt="enter image description here"></a></p>
  
  <p>Unfortunately, there is no recorded step for me to be able to get the system ID. </p>