As was promised earlier – work has been done on creating the next generation Connector for Python using the new SAP NW RFCSDK that Ulrich SAP NetWeaver RFC SDK.
The Python sapnwrfc Connector is designed very much in the same style as the NetWeaver RFC gives the Next generation Ruby and Perl Connectors ones, so the syntax should hopefully be familiar (from the test suite distributed with the source code):
import unittest # define the test class class sapnwrfctest(unittest.TestCase): # code that is executed once at the start of the test def setUp(self): sapnwrfc.base.config_location = 'examples/sap.yml' sapnwrfc.base.load_config() # Test iteration of handling a deep structure def testDeep1(self): # connect to SAP conn = sapnwrfc.base.rfc_connect() self.assertNotEquals(conn, None) # look up the RFC interface definition fds = conn.discover("STFC_DEEP_STRUCTURE") self.assertEquals(fds.name, "STFC_DEEP_STRUCTURE") for i in range(100): # allocte a call container fs = fds.create_function_call() self.assertEquals(fs.name, "STFC_DEEP_STRUCTURE") # populate the parameters for the call fs.IMPORTSTRUCT( { 'I': 123, 'C': 'AbCdEf', 'STR': 'The quick brown fox ...', 'XSTR': "deadbeef".decode("hex") } ) # do the call fs.invoke() # check the results s = fs.ECHOSTRUCT() self.failUnless(s['I'] == 123) self.failUnless(s['C'].rstrip() == 'AbCdEf') self.failUnless(s['STR'] == 'The quick brown fox ...') self.failUnless(s['XSTR'].encode("hex") == 'deadbeef') self.assertEquals(conn.close(), 1) # now run it if __name__ == "__main__": import sapnwrfc unittest.main()
Downloading
This is a complete rewrite to take advantage of the new SAP NW RFCSDK, with unicode support, and support for deep structures. This version provides Client side RFC support only. The download is available here
Great! I was thinking of start Python learning…And now I’m sure I want to learn it!
Greetings,
Blag.
I actually use pysaprfc for SAP connector, did you heard about this? it is able to run under windows and is inspired in your work but the nice think I see in that piece of software is the use of ‘ctypes’ for connection to the SAP librfc32.dll.
That project seems to be abandoned so I am interested to try your sap python connector using the new sapnwrfc however, I have no a Windows Version of this.
DO you have a Windows version to share or do you know of anybody that has this?
Thanks for your attention and time, Piers.
Eduardo.
no, I don’t know of any precompiled versions of sapnwrfc for Python, but if you build it, I’m happy to put it up on my site for download.
Cheers.