I have this problem: when calling a RFC using tables and putting numeric chars only in char fields, they get left filled with zeros till de width of the field, i.e if in python a do 1, i get in sap 001 in 3 char length fields,
I'im using pysaprfc and SAP 4.6B
I think this is the code in pysap.py which is doing the conversion (over line 200), but i don't know the reason why is doing it?
if v1<=sys.maxint: v=v1
self.int_value='%0*d' % (self._length_,v)
Any help from the author?
The purpose of this code was to automatically format string containing numbers to ABAP format for numerical strings (numc) - right aligned with leading zeroes. SAP uses this quite offten to format fields like customer or material numbers which can be both alphanumerical (left aligned) and digits-only (leading zeroes) and I wanted the string to be easly compatible with values as store in database.
Latter I changed my mind - this kind of under-the-hood formating may lead to errors - and current CVS version doesn't use it anymore.
Thank you Klavdij for your quick anwser, so I think I can comment previous lines without hurt (I will test)because they are at the part of the code which treat with the STRING data type.
A question thought, Is it safe to use the code from CVS right now?
Code in CVS is in "pre-release" state and should be fairly safe. I'm using it in couple of my projects and it seems rather stable.
I have a similar problem using pysap. Example executed in idle:
# get the interface
['RETURN_TAB', 'GRUPPENID', 'LIZSCHL']
# assigne values to the import keys
# call the function
# print the return_tab
>>> for i in r_func['RETURN_TAB']:
tdformat = '1 E:'
tdline = '00000000. GruppenID nicht vorhanden'
tdformat = '0 M:'
tdline = 'PCDELUN70099103AVS' Lizenz OK
Reason is that the lenght of r_func['GRUPPENID'] is doubled (type of GRUPPENID in SAP is CHAR length 8)AND the value then is filled with leading zeros. The left part of the value is then sent to SAP
What happens ?
Thanks in advance
got the last version (1.43) from CVS. this works but is rather slow