Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan_schnell
Active Contributor
0 Kudos
I introduced COM Connector (CCo) here. Here now an example how to use transactional RFC calls with VBScript via CCo. The queued RFC calls are commented. You can find more information about the different RFC variants here.
'-Begin-----------------------------------------------------------------

'-Directives----------------------------------------------------------
Option Explicit

'-Constants-----------------------------------------------------------
Const RFC_OK = 0

'-Sub Main------------------------------------------------------------
Sub Main()

'-Variables-------------------------------------------------------
Dim SAP, hRFC, rc, TID, hTrans, hFuncDesc, hFunc

Set SAP = CreateObject("COMNWRFC")
If Not IsObject(SAP) Then
Exit Sub
End If

hRFC = SAP.RfcOpenConnection("ASHOST=ABAP, SYSNR=00, " & _
"CLIENT=001, USER=BCUSER")
If hRFC = 0 Then
Set SAP = Nothing
Exit Sub
End If

hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "RFC_PING")
If hFuncDesc = 0 Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Exit Sub
End If

hFunc = SAP.RfcCreateFunction(hFuncDesc)
If hFunc = 0 Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Exit Sub
End If

If SAP.RfcGetTransactionID(hRFC, TID) <> RFC_OK Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Exit Sub
End If

'qRFC
'hTrans = SAP.RfcCreateTransaction(hRFC, TID, "StefansQueue")

hTrans = SAP.RfcCreateTransaction(hRFC, TID, "")
If hTrans = 0 Then
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing
Exit Sub
End If

If SAP.RfcInvokeInTransaction(hTrans, hFunc) = RFC_OK Then

If SAP.RfcSubmitTransaction(hTrans) = RFC_OK Then

'qRFC
'MsgBox "Look in TAC SMQ2 (Inbound Queue)"

MsgBox "Look in table ARFCRSTATE for TID " & TID

rc = SAP.RfcConfirmTransaction(hTrans)

End If

End If

rc = SAP.RfcDestroyTransaction(hTrans)
rc = SAP.RfcDestroyFunction(hFunc)
rc = SAP.RfcCloseConnection(hRFC)
Set SAP = Nothing

End Sub

'-Main----------------------------------------------------------------
Main()

'-End-------------------------------------------------------------------

Enjoy it.