cancel
Showing results for 
Search instead for 
Did you mean: 

VB Excel CreateObject SAP.LogonControl.1 RCF error in Saplogon how do you work it with a sap router

Former Member
0 Kudos
2,345

Hi,


I have seen a lot of VB codes through excel - how do you work it when you are using a SAP Router -

I am getting this error

RFC_ERROR_COMMUNICATION

Message


LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner 'xx.xx.xx.xx:3300' not reached
TIME Tue Aug 20 09:45:42 2019
RELEASE 749
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE D:/depot/bas/749_REL/src/base/ni/nixxi.cpp
LINE 3428
DETAIL NiPConnect2: xx.xx.xx.xx:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 18

can someone help?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

i have a video - but i can not send it here -I am using Sapgui 7.5 on a virtual machine in SKYTAP

if i use sapgui - i can login without a problem

only when i run the code from the excel I get this problem -

Former Member
0 Kudos

The same problem

Error Group

RFC_ERROR_COMMUNICATION

Message


LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '10.65.160.244:3300' not reached
TIME Wed Aug 21 22:16:27 2019
RELEASE 749
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE D:/depot/bas/749_REL/src/base/ni/nixxi.cpp
LINE 3428
DETAIL NiPConnect2: 10.65.160.244:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 6

this is what I am using -

Option Explicit
Public Functions As SAPFunctionsOCX.SAPFunctions
Private LogonControl As SAPLogonCtrl.SAPLogonControl
Private objConnection As SAPLogonCtrl.Connection
Dim Func As SAPFunctionsOCX.Function
Public eNUMBER_OF_ENTRIES As SAPFunctionsOCX.Parameter
Public tENTRIES As SAPTableFactoryCtrl.Table
Public TableFactory As SAPTableFactory
Private LogCount As Integer
Public shScript, shLog As Worksheet



Sub TableEntriesRFC()
Dim i As Integer
Dim retcd As Boolean
Dim SilentLogon As Boolean

Set shScript = Worksheets("Script")
ResetLog

Set LogonControl = CreateObject("SAP.LogonControl.1")
'Set Functions = CreateObject("SAP.Functions")
Set LogonControl = CreateObject("SAP.LogonControl.1")
Set TableFactory = CreateObject("SAP.TableFactory.1")
'Set objConnection = Functions.Connection()
Set objConnection = LogonControl.NewConnection
'SilentLogon = False


'Set objConnection = Functions.Connection()
SilentLogon = False

'Set the hourglass pointer
'Application.Cursor = xlWait

AddLog "Logon", "Logging into SAP...", vbBlack
' Logging into SAP
If objConnection.Logon(0, SilentLogon) Then


'Logon was successful
AddLog "Logon", "Successfully logged into SAP", vbBlack
'Create an object to call the RFC FM
Functions.Connection = objConnection

AddLog "RFC", "Preparing the interface", vbBlack
'Actual FM is added here
Set Func = Functions.Add("RFC_GET_TABLE_ENTRIES")
'Populate the importing parameters
Func.Exports("TABLE_NAME").Value = Range("TableName").Value
'Declare the exporting parameters and tables
Set eNUMBER_OF_ENTRIES = Func.Imports("NUMBER_OF_ENTRIES")
Set tENTRIES = Func.Tables("ENTRIES")

'Executing the FM
AddLog "RFC", "Executing call", vbBlack
Func.Call

AddLog "RFC", "Number of entries: " + CStr(eNUMBER_OF_ENTRIES), vbBlack
'Extract the results to Excels to D10 and down
For i = 1 To tENTRIES.RowCount
Cells(9 + i, 4).Value = tENTRIES(i, 1)
Next

Else
'Execute this block if logon fails
Dim msg As String
msg = "Failed to login to SAP. Verify credentials or access."
AddLog "Logon", msg, vbRed
Application.Cursor = xlDefault
MsgBox msg
GoTo Cleanup
End If


Cleanup:
'Update the timestamp
Range("Timestamp").Value = Now()
'Close the connection to SAP
objConnection.Logoff
AddLog "Logout", "Logged out of SAP", vbBlack
'Set the pointer back to default cursor
Application.Cursor = xlDefault
MsgBox "Script completed"
End Sub

Stefan-Schnell
Active Contributor
0 Kudos

Hello Maria,

I assume the error pops up in your case at this point:

If objConnection.Logon(0, SilentLogon) Then

Your SilentLogon is set to False, you choose the system and the error occurs.

Which version of SAP GUI for Windows do you use?

Try this approach

Set Functions = CreateObject("SAP.Functions.Unicode")
Set objConnection = Functions.Connection()
SilentLogon = False

'Set the hourglass pointer
'Application.Cursor = xlWait

AddLog "Logon", "Logging into SAP...", vbBlack
' Logging into SAP
If objConnection.Logon(0, SilentLogon) Then

and let us know your results. I tried this approach in my environment with SAP GUI for Windows 7.60 and it works with an entry with SAP Router without any problems.

Best regards
Stefan