cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with Python saprfc

Former Member
0 Kudos

I'm having a few issues with the python saprfc library. I'm using python saprfc 0.09.

Firstly, unspecified dates don't seem to be passed as 00000000 as I believe they should be; I think this bug has been fixed in some of the other connectors, but it still seems to be an issue in the python one.

Also, there seems to be an issue dealing with numerical values. A lot of numbers are wrong by some number of factors of 10. For example, the following code:

b = conn.discover('BAPI_EXCHRATE_GETCURRENTRATES')

b.DATE.setValue('20061010')

b.DATE_TYPE.setValue('V')

b.RATE_TYPE.setValue('M')

conn.callrfc(b)

print b.EXCH_RATE_LIST.hashRows().next()['EXCH_RATE']

returns 03.11870, whereas the equivalent Ruby prints 0031.18700, which agrees with the SAP GUI.

I was also wondering whether it would it be possible to specify the encoding used by the SAP system, and have saprfc return all strings as unicode? At the moment I have to call str.decode('ISO-8859-1') on every string value I recieve from saprfc, so it would be really useful if the library performed this decoding before returning strings.

Finally, I was also wondering why it's possible to convert a table to an iterator over a list of dicts with bapi.TABLE.hashRows(), but to convert a structure to a hash one has to do bapi.STRUCTURE.structure.toHash(bapi.STRUCTURE.value)? Couldn't this be done with bapi.STRUCTURE.toHash()?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Does anyone else use the Python saprfc? Have you encountered any of these problems?

It seems a shame that saprfc isn't quite up to production use, but I don't think my knowledge of the protocol is up to fixing the problems I'm encountering (if they are problem with saprfc).

Has anyone tried the ctypes-based pysaprfc library? I gave it a quick try, but came across a problem which I'm afraid I can't remember now.

Any advice on using Python with SAP would be gratefully received!

gregorw
Active Contributor
0 Kudos

Hello Neil,

have you noticed that version 0.10 is avaliable at http://www.piersharding.com/download/python/?

Regards

Gregor

Former Member
0 Kudos

Hi Neil -

Firstly - this forum isn't the primary place to go to for support for saprfc (either Python, Perl, or Ruby) - you should contact the project owner, for which there are contact details available in all the distributions. The only reason why I've seen this now, is because Gregor pinged me.

There is a bug in the BCD value handling, which is causing you the problems mentioned above - I've patched this, and there is a new version up at http://www.piersharding.com/download/python/saprfc-0.11.tar.gz.

As for usability issues - if you have a problem with it - you could always send me a patch - that is what opensource is about.

saprfc for Python is the least advanced of the 3 connectors (although I know of atleast one production implementation, doing remote sensing work with run times measured in months, so it can't be that unstable) - mainly because very few people seem to be interested in using Python in an SAP context. There is plenty of scope for expansion if there is a community will.

Regards,

Piers Harding.

Former Member
0 Kudos

Wow, that was a fast fix!

I will have a play around with the usability aspect, and send you a patch if I feel I've made an improvement.

Thanks for all your support,

Neil.

former_member583013
Active Contributor
0 Kudos

Hi Piers:

I'm really interesting in using Python and SAP...So you got a new customer -:P I just to finished my Rails learning (Which I must continue....) and then move to Python -;)

Greetings,

Blag.

Answers (0)