'-Begin-----------------------------------------------------------------
'-
'- Look also in TAC SBGRFCCONF and SBGRFCMON
'- Hint: You need SAP 7.0 EHP 1 for SAP NetWeaver 7.0 Support Package 4
'- and higher
'-
'-----------------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Constants-----------------------------------------------------------
Const RFC_OK = 0
'-Sub Main------------------------------------------------------------
Sub Main()
'-Variables-------------------------------------------------------
Dim SAP, CCo, hRFC, rc, UID, hUnit, hFuncDesc, hFunc
Dim unitAttrID, unitAttr, unitIdentID, unitIdent
Set SAP = CreateObject("COMNWRFC")
If Not IsObject(SAP) Then
Exit Sub
End If
Set CCo = CreateObject("COMNWRFCHELP")
If Not IsObject(CCo) Then
Exit Sub
End If
hRFC = SAP.RfcOpenConnection("ASHOST=ABAP, SYSNR=00, " & _
"CLIENT=001, USER=BCUSER")
If hRFC = 0 Then
Set SAP = Nothing
Set CCo = Nothing
Exit Sub
End If
hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "RFC_PING")
If hFuncDesc = 0 Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Set CCo = Nothing
Exit Sub
End If
hFunc = SAP.RfcCreateFunction(hFuncDesc)
If hFunc = 0 Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Set CCo = Nothing
Exit Sub
End If
If SAP.RfcGetUnitID(hRFC, UID) <> RFC_OK Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Set CCo = Nothing
Exit Sub
End If
'-Create structures RFC_UNIT_ATTRIBUTES and RFC_UNIT_IDENTIFIER---
If CCo.AllocateMemory(273, unitAttrID, unitAttr) = vbFalse Or _
CCo.AllocateMemory(70, unitIdentID, unitIdent) = vbFalse Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Set CCo = Nothing
Exit Sub
End If
'-qRFC------------------------------------------------------------
' hUnit = SAP.RfcCreateUnit(hRFC, UID, "STEFANSQUEUE", unitAttr, _
' unitIdent)
'-tRFC------------------------------------------------------------
hUnit = SAP.RfcCreateUnit(hRFC, UID, "", unitAttr, unitIdent)
If hUnit = 0 Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
rc = CCo.FreeMemory(unitIdentID)
rc = CCo.FreeMemory(unitAttrID)
Set CCo = Nothing
Exit Sub
End If
If SAP.RfcInvokeInUnit(hUnit, hFunc) = RFC_OK Then
If SAP.RfcSubmitUnit(hUnit) = RFC_OK Then
MsgBox "Look in table BGRFC_SRV_STATE for UID " & UID
SAP.ErrorMsgTarget = 2
If SAP.RfcConfirmUnit(hRFC, unitIdent) = RFC_OK Then
MsgBox "Look in table BGRFC_SRV_CFM for UID " & UID
Else
MsgBox SAP.ErrorMessage
End If
End If
End If
rc = SAP.RfcDestroyUnit(hUnit)
rc = SAP.RfcDestroyFunction(hFunc)
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
rc = CCo.FreeMemory(unitIdentID)
rc = CCo.FreeMemory(unitAttrID)
Set CCo = Nothing
End Sub
'-Main----------------------------------------------------------------
Main()
'-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |