Hello community,
SAP offers different connectors to develop ABAP compatible components and applications. JCo for Java environments, NCo for dotNET languages and the NetWeaver RFC SDK for C++. But what's up if you work neither with Java or dotNET environments nor with C++?
Here is another alternative, CCo - the COM Connector for SAP. CCo is a COM library and offers wrappers around all functions of the SAP NetWeaver RFC library. So it is possible to use all functionalities of the SAP NetWeaver RFC library inside any language which support COM technic.
With CCo it is easily possible to use the SAP NetWeaver RFC functions inside VBScript, Visual Basic for Applications (VBA) or AutoIt script.
Here a VBScript example to connect an SAP system:
'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Variables-----------------------------------------------------------
Dim SAP, hRFC, rc
'-Main----------------------------------------------------------------
Set SAP = CreateObject("COMNWRFC")
If IsObject(SAP) Then
SAP.About
hRFC = SAP.RfcOpenConnection("ASHOST=ABAP, SYSNR=00, " & _
"CLIENT=001, USER=BCUSER")
If hRFC Then
MsgBox "Check connection with TAC SMGW in the SAP system"
rc = SAP.RfcCloseConnection(hRFC)
End If
Set SAP = Nothing
End If
'-End-------------------------------------------------------------------
Here a VBA example to ping an SAP system:
'-Begin-----------------------------------------------------------------
Option Explicit
'-Constants-----------------------------------------------------------
Const RFC_OK = 0
'-Sub Ping------------------------------------------------------------
Sub Ping()
'-Variables-------------------------------------------------------
Dim SAP As CCo.COMNWRFC
Dim hRFC As Long
Dim rc As Integer
Dim hFunc, hFuncDesc As Long
Set SAP = CreateObject("COMNWRFC")
If IsObject(SAP) Then
hRFC = SAP.RFCOPENCONNECTION("ASHOST=ABAP, SYSNR=00, " & _
"CLIENT=001, USER=BCUSER")
If hRFC Then
'-Variant1----------------------------------------------------
hFuncDesc = SAP.RFCGETFUNCTIONDESC(hRFC, "RFC_PING")
If hFuncDesc Then
hFunc = SAP.RFCCREATEFUNCTION(hFuncDesc)
If hFunc Then
If SAP.RFCINVOKE(hRFC, hFunc) = RFC_OK Then
Debug.Print "Ping successful"
Else
Debug.Print "Ping not successful"
End If
SAP.RFCDESTROYFUNCTION hFunc
End If
End If
'-Variant2----------------------------------------------------
If SAP.RFCPING(hRFC) = RFC_OK Then
Debug.Print "Ping successful"
Else
Debug.Print "Ping not successful"
End If
rc = SAP.RFCCLOSECONNECTION(hRFC)
End If
Set SAP = Nothing
End If
End Sub
'-End-------------------------------------------------------------------
To the duality of accesses via SAP GUI Scripting and RFC with scripting languages
![ScriptStructure1.jpg]()
CCo opens a powerful second channel to communicate with an SAP backend. You can code in your favorite COM-enabled scripting language and use two ways: on the one hand the SAP GUI Scripting to communicate via SAP GUI for Windows with an SAP system, and on the other hand the COM Connector (CCo) to communicate via SAP NetWeaver RFC library with an SAP application server.
CCo is an ideal complementation to SAP GUI Scripting in this application area. You can e.g. use the wide range of thousands of remote-enabled function modules from an SAP system. Use the transaction code BAPI to open the BAPI explorer and find a lot in the alphabetical hierarchy tree.
Enrich your SAP GUI Scripting operation processes. Get information easy and fast via CCo RFC interface in your scripting environment. Combine the best of both worlds.
Hint: CCo has at the moment experimental character. Don't use it in production environments.
Hint: CCo needs SAP RFC SDK, you find it here.
Download
You find CCo here: http://cco.stschnell.de
2013/08/02:
- New Version 0.8 is available.
- External functions to register and unregister the library without admin rights.
- All connection parameters are now in string format, for maximum flexibility.
- 89.5% of all methods doesn't need pointers.
- For all other methods I implement AllocateMemory, FreeMemory and Peek and Poke functions.
- With this version it is possible to use all functions of SAP RFC library.
Comments are welcome.
Cheers
Stefan