Char fields left filled with zeros problem

  • Nobody/Anonymous


    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

    Any ideas?


    • Nobody/Anonymous

      I think this is the code in which is doing the conversion  (over line 200), but i don't know the reason why is doing it?

      elif v.isdigit():
                          if v1<=sys.maxint: v=v1
                      except ValueError:
                          if isinstance(v,int):
                              self.int_value='%0*d' % (self._length_,v)

      Any help from the author?


    • Klavdij Voncina

      Klavdij Voncina - 2006-09-12

      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.


    • Nobody/Anonymous

      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?


      Manuel Segarra

    • Klavdij Voncina

      Klavdij Voncina - 2006-09-13

      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.


    • Nobody/Anonymous

      I have a similar problem using pysap. Example executed in idle:

      # get the interface
      >>> r_func=zhl_conn.get_interface('Y_4Q4_REQUEST_LICENCE_MESEQUI')
      >>> r_func.keys()
      # assigne values to the import keys
      >>> r_func['GRUPPENID']='1514100'
      >>> r_func['LIZSCHL']='PCDELUN70099103AVS'
      # call the function
      >>> rc=r_func()
      # print the return_tab
      >>> for i in r_func['RETURN_TAB']:
          print i
      tdformat = '1 E:'
      tdline = '00000000. GruppenID nicht vorhanden'
      # Expected:
      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
      >>> r_func['GRUPPENID']

      What happens ?

      Thanks in advance

      Winfried Diehm

    • Nobody/Anonymous

      got the last version (1.43) from CVS. this works but is rather slow



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks