简体   繁体   English

在 VBA 中调用 RFC_READ_TABLE 期间出现错误 61704

[英]Error 61704 during calling RFC_READ_TABLE in VBA

I am trying to connect to SAP via RFC objects:我正在尝试通过 RFC 对象连接到 SAP:

Dim sap As Object
Set sap = CreateObject("SAP.Functions.unicode")
sap.connection.system = "xxxxxxxx"
sap.connection.Client = "700"
sap.connection.User = "USER"
sap.connection.Password = "PASS"
sap.connection.Language = "EN"

If sap.connection.Logon(1, False) <> True Then 'Try Logon
   MsgBox "Cannot Log on to SAP"
End If

'*************************************************************
'Define the table specifics
'************************************************************

Dim objRfcFunc As Object
Set objRfcFunc = sap.Add("RFC_READ_TABLE") 'IN THIS LINE MY ERROR OCCURS

Internal application error - runtime error:61704内部应用程序错误 - 运行时错误:61704

Any solutions?有什么解决办法吗?

连接参数 It seems like my connection is OK.看来我的连接没问题。 Could you check my connection variables?你能检查我的连接变量吗?

The following code I took from here and adjusted it worked for me.我从这里获取并调整了以下代码对我有用。 Of course you have to change the connection parameters (username etc.) as well.当然,您还必须更改连接参数(用户名等)。 I guess your issue is you do not have a connection in the first place.我想你的问题是你一开始就没有联系。

Sub Test_RFC()
    ' Connect to SAP
    Dim oSAP As Object
    Set oSAP = CreateObject("SAP.Functions.unicode")
    ' Connection parameters - to be adjusted
    oSAP.Connection.ApplicationServer = "1.1.1.1" ' IP des Appl-Servers (SM51->Details)
    oSAP.Connection.SystemNumber = "01"           ' Systemnummer, meißt im Namen des Appl-Servers enthalten
    oSAP.Connection.System = "XD1"                ' Entwicklungs-, Test-, Produktivsystem
    oSAP.Connection.Client = "100"                ' Mandant
    oSAP.Connection.Language = "DE"               ' Sprache "EN", "DE" ...



    ' RFC-Login: Show logon popup
    If oSAP.Connection.Logon(0, False) = True Then
        'You can only add a function module in case you have a connection
        Dim oFuBa As Object            
        Set oFuBa = oSAP.Add("RFC_READ_TABLE")

    End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM