Skip to Content
Former Member
May 10, 2014 at 05:19 PM

Logon Property: RFCWithDialog Problem


Hi all,

I'm trying to make a connection with SAP through the SAP.Functions object, the connection's property RfcWithDialog is set to True, so it is possible to use the SAP screens during an RFC call, however when running the method call SAP's screen is not shown as it should, noting that the code used worked perfectly until a few days ago. Can anyone help me solve this problem?

Sub RecordBDC()

Dim SAPConn As Object
Dim rfcFunc As Object
Dim authCheck As Object
Dim tCode As Object
Dim dynTab As Object
Dim mesTab As Object
Dim idx1 As Long
Dim idx2 As Long

'Create the SAP Functions object
Set SAPConn = CreateObject("SAP.Functions")

'Set up Connections parameters

SAPConn.Connection.System = "d4. PD4 - Produção TIM ONE CLIENT"
SAPConn.Connection.client = "203"
SAPConn.Connection.user = "MyUser"
SAPConn.Connection.Password = "MyPassWord"
SAPConn.Connection.Language = "PT"

SAPConn.Connection.RfcWithDialog = True

'Performing the connection
If SAPConn.Connection.IsConnected = 1 Then

If SAPConn.Connection.Logon(0, True) <> True Then
MgSapLogOn = vbCancel
Exit Sub
End If


If SAPConn.Connection.Logon(0, True) <> True Then
MgSapLogOn = vbCancel
Exit Sub
End If
End If

End With

'Set up RFC parameters
Set tCode = rfcFunc.exports("TCODE")
Set authCheck = rfcFunc.exports("AUTHORITY_CHECK")
Set dynTab = rfcFunc.tables("DYNPROTAB")
Set mesTab = rfcFunc.tables("MESSTAB")
tCode.Value = "Z_SD_FAT_DET"

'Call the RFC
If rfcFunc.Call = True Then 'SAP should show the screen of the transaction defined in parameter tCode

idx2 = 0
conRepl = MsgBox("Do you need BDC_CURSOR/BDC_SUBSCR?", vbYesNo + vbDefaultButton2)
For idx1 = 1 To dynTab.RowCount
If conRepl = vbNo And dynTab.Value(idx1, "FNAM") = "BDC_SUBSCR" Or dynTab.Value(idx1, "FNAM") = "BDC_CURSOR" Then
idx2 = idx2 + 1
ActiveSheet.Cells(idx2 + 1, 1) = idx2
ActiveSheet.Cells(idx2 + 1, 2) = dynTab.Value(idx1, "PROGRAM")
ActiveSheet.Cells(idx2 + 1, 3) = dynTab.Value(idx1, "DYNPRO")
ActiveSheet.Cells(idx2 + 1, 4) = dynTab.Value(idx1, "DYNBEGIN")
ActiveSheet.Cells(idx2 + 1, 5) = dynTab.Value(idx1, "FNAM")
ActiveSheet.Cells(idx2 + 1, 6) = "'" & dynTab.Value(idx1, "FVAL")
End If
MsgBox "Completed"
MsgBox "Transaction cannot be called. " & Chr(13) & "Please check auth. or etc.."
End If

End Sub