Hermanito
Well-known Member
- Joined
- Apr 4, 2007
- Messages
- 1,238
Hi all,
I'm still trying to get a SAP-connection working... so far I have this code (found somewhere else, slightly adapted to our situation). The logon-part works, so the first call in Main() is okay (I have changed connection details in the code pasted here). Then it halts on the next line (funcControl.Connection = Conn) with this error:
Run-time error '61704': Internal application error.
When I choose debug and immediately try to continue I get
Run-time error '-2147352568 (80020008)': Bad variant type
I've got no clue as to why this line gives these errors, I hope it's something silly I'm overlooking...
Does anyone have an idea what is going wrong here?
I'm still trying to get a SAP-connection working... so far I have this code (found somewhere else, slightly adapted to our situation). The logon-part works, so the first call in Main() is okay (I have changed connection details in the code pasted here). Then it halts on the next line (funcControl.Connection = Conn) with this error:
Run-time error '61704': Internal application error.
When I choose debug and immediately try to continue I get
Run-time error '-2147352568 (80020008)': Bad variant type
I've got no clue as to why this line gives these errors, I hope it's something silly I'm overlooking...
Does anyone have an idea what is going wrong here?
Code:
Dim LogonControl As SAPLogonCtrl.SAPLogonControl
Dim Conn As SAPLogonCtrl.Connection
Dim FuncControl As SAPFunctionsOCX.SAPFunctions
Dim TableFactoryCtrl As SAPTableFactoryCtrl.SAPTableFactory
Dim ZPP_BOM_DOWNL
Dim eQUERY_TAB
Dim TOPTIONS
Dim TDATA
Dim TFIELDS
Sub Main()
Set LogonControl = CreateObject("SAP.LogonControl.1")
Set FuncControl = CreateObject("SAP.Functions")
Set TableFactoryCtrl = CreateObject("SAP.TableFactory.1")
Call R3Logon
FuncControl.Connection = Conn
Call R3ZPP_BOM_DOWNL("T000")
Conn.Logoff
End Sub
Sub R3Logon()
Set Conn = LogonControl.NewConnection
Conn.ApplicationServer = "10.0.1.1"
Conn.System = "ZZZ"
Conn.Client = "123"
Conn.Language = "EN"
Conn.User = "UserName"
Conn.Password = "Password"
Conn.RfcWithDialog = 0
retcd = Conn.Logon(0, True)
If retcd <> True Then
MsgBox "Cannot log on! - " & retcd
Stop
Else
MsgBox "Logon OK"
End If
End Sub