Re: [Pysaprfc-users] Need some help for writing a simple SAP interface using pysap
Brought to you by:
klvon
From: Klavdij V. <von...@si...> - 2006-08-06 14:57:05
|
You definitely need access to a SAP system to test your application. The librfc32.dll alone is not enough. In order to call a function defined in SAP you need at least connection settings (IP or name of the host, and system number) plus username, password and client number. In the simplest and most often case the connection string is something like 'ASHOST = <ip or hostname of SAP system> SYSNR=<system number> CLIENT=<client> USER=<username> PASSWD=<password>'. In case of a server function (as in your example) the connection should be defined from SAP system using transaction sm59 as described in SAP documentation. If I understand your situation correctly your client gave you librfc32.dll but you don't have access to their system. In that case you should negociate access to their test or dev system in order to be able to test your app. The example you sent should work if SAP system is accessible and configured properly (sm59). Best regards, Klavdij > 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 |