Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP VBA Scripting with multiple SAP Production Clients

former_member546423
Discoverer
0 Kudos

I'm trying to write a script that in one script will look for one client (SID) and in another it will look for the other client (SID)

When I use this one, I get a "compile error"

Function Getorders()

Dim SapGuiAuto As Object
Dim Application As SAPFEWSELib.GuiApplication
Dim Connection As SAPFEWSELib.GuiConnection
Dim i As Integer
Dim Conn As String
Dim Flag As Boolean

Flag = False
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
If Application.Connections.Count() > 0 Then
For i = 0 To Application.Connections.Count() - 1
Set Connection = Application.Children(i)
Conn = Connection.Description()
If Conn = "Cessna1. SAP ECC Production" Then
Flag = True
Exit For
End If
Next
If Flag = False Then
Set Connection = Application.OpenConnection("Cessna1. SAP ECC Production")
End If
'Insert your code here

Set Connection = Nothing

Else

Set Connection = Application.OpenConnection("Cessna1. SAP ECC Production")

'Insert your code here


Set Connection = Nothing

End If

End Function

0 REPLIES 0