Errors when trying to use an open SAP-connection

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?

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
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
bump...

I hope someone can spot the error I'm making in this piece of code...
Is it how the variable is used? Is it a missing reference? I'm lost :cry:
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,148
Members
452,382
Latest member
RonChand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top