[Pysaprfc-users] Need some help for writing a simple SAP interface using pysap
Brought to you by:
klvon
From: vivek k. g. <gup...@re...> - 2006-08-05 12:23:40
|
Dear All, Recently I am given a task to try interfacing with SAP R/3 using RFC. The task is as following..I have to write an app which should be able to call a simple function in SAP and show the output on screen. Also the SAP should be able to call a simple function in this app.As I have no previous experience of SAP I was very nervous. I googled for the options available for interfacing and found pySAP, .net connector and JCo while searching for interfaces. In my organization as most of the work is on windows platform so noboy here uses any open source languages. I have some prior experience of Python and I thought it will be a good chance to push it in my organization. I somehow managed to convince my pm that this job can be done in python. Now let me tell you what softwares I have available at my hand..OS : Windows XPPython : version 2.4.3ctypes : version 1.0.0pysaprfc : version 1.0.0mxdatetime : version 2.0.3We don\'t have a license for SAP but I somehow managed to get librfc32.dll from the client (possibly, if this test app is through :) ) the version for librfc32.dll is 4640.5.378.3114. I created two simple scripts after reading the documentation. Here is the code for the simple server function..------------------------------------------import pysapimport sysclass SAP_RFC_SRV(pysap.RFC_SERV_FUNC): _name_=\'ZTEST_ABC\' _importing_=[(\'Strdata\',\'C\',10)] _exporting_=[(\'Msg_reached\',\'C\',1)] def run(self,handle): print \'Message From Sap : \',self[\'Strdata\'] self[\'Msg_reached\']=\'1\'srv=pysap.RfcServerEx()try: srv.register_func(SAP_RFC_SRV) srv.main_loop(sys.argv)except pysap.SapRfcError,E: print \'Error returned while trying to register sap rfc server...\',E raw_input(\'Press any key to exit...\') sys.exit(1)-----------------------------I even created an exe from the script using the py2exe after reading a previous post on mailing list dated 2005-08-31. But still when I run this exe I still get this \'connection failed\' message.Is it neccessary to have a running SAP server to run this server app or is there something I am missing? Also, do I have to create some ini file for this server to work? Please help me as this is my only chance to get some work in Python after more then 2 years :( and I definitely don\'t want to miss it.THX and Regards,Vivek Kumar |