on 01-10-2008 5:03 PM
Hi all,
I have planning layout (SAP SEM-BPS 3.5, SAP GUI Excel In Place). I have to call remote function (functional module from BW server side). Mentioned function reads some data from table and returns ones to Excel.
To do one I use object "SAP.Functions"
Dim funct, conn, LogonControl
Set funct = CreateObject("SAP.Functions")
This object requires connection to BW
Set LogonControl = CreateObject("SAP.LogonControl.1")
Set conn = LogonControl.NewConnection
If conn.Logon(0, True) Then ...
funct.Connection = conn
So, I create new connection and new session.
Is there any way to use existing connection/session to use one within "SAP.Functions" object?
Thanks in advance,
Dmitry
Hello,
I think you should use:
Set SapGuiAuto = GetObject("SAPGUI")
So for example:
Function Attach
Dim GuiAuto
On Error Resume Next
Set GuiAuto = GetObject("SAPGUI")
On Error Goto 0
If GuiAuto Is Nothing THEN
Msgbox "Please start SAPlogon"
Set Attach = Nothing
Exit Function
Else
...you code...
End If
End Function
It works for me.
Regards,
EK
Edited by: Erkan Kopuz on Feb 7, 2008 10:03 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I get connection by proposed way. But, when I try to use this connection
E.G.
Set SapGuiAuto = GetObject("SAPGUI")
Set appl = SapGuiAuto.GetScriptingEngine
Set conn1 = appl.Children(0)
and use this connection within CreateObject("SAP.Functions")
E.G.
+ Set funcControl = CreateObject("SAP.Functions")+
+ funcControl.Connection = conn1+
VB script returns error.
What a reason of error? Perhaps, additional type convertion for object Connection is needed?
Hello,
you can check if you are connected with <MyConnObject>.isconnected and if it returns 1 then you are, if not you can try <MyConnObject>.reconnect.
Regards,
Andi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.