<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic nwrfc python unicode input encoding? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/nwrfc-python-unicode-input-encoding/m-p/6125553#M1364451</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to feed a unicode sap r/3 system with data from a MS Access db on MS windows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both access and windows are in greek locale (cp1253). Python, nwrfc, and sap r/3 are unicode (utf8). My program encoding is utf8. I use python ado module (e.g. win32com.client.Dispatch(r'ADODB.Connection')).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the values I get from the database are tested as python type unicode. If I feed them directly to sapnwrfc I get "invalid input" type of errors. If I encode them as 'utf8' (e.g. &amp;lt;value&amp;gt;.encode('utf8')), I get "RFC FUNCTION CALL ERROR: RfcSetChar string too long" errors. The respective fields in SAP are say CHAR10 type and they should be able to contain the test data. Some further tests revealed that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Greek:
g = u'u03B1u03B2u03B3' &amp;lt;type 'unicode'&amp;gt;
repr(g) 
"u'\\u03b1\\u03b2\\u03b3'" (3 characters)
repr(g.encode('utf8')) 
"'\\xce\\xb1\\xce\\xb2\\xce\\xb3'" (6 characters)
 
Latin:
l = u'abc' &amp;lt;type 'unicode'&amp;gt;
repr(l) 
"u'abc'" (3 chars)
repr(l.encode('utf8'))
"'abc'" (3 chars)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not understand unicode programming that well, but if I send g.encode('utf8') to sapnwrfc, data is written to db successfully as long as their length, (that of repr(g) ), does not exceed that of the SAP field. The rest are truncated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What should the input be? Can you help me out here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Menelaos Maglis&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Menelaos Maglis on Sep 2, 2009 9:12 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Sep 2009 07:10:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-09-02T07:10:25Z</dc:date>
    <item>
      <title>nwrfc python unicode input encoding?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nwrfc-python-unicode-input-encoding/m-p/6125553#M1364451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to feed a unicode sap r/3 system with data from a MS Access db on MS windows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both access and windows are in greek locale (cp1253). Python, nwrfc, and sap r/3 are unicode (utf8). My program encoding is utf8. I use python ado module (e.g. win32com.client.Dispatch(r'ADODB.Connection')).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the values I get from the database are tested as python type unicode. If I feed them directly to sapnwrfc I get "invalid input" type of errors. If I encode them as 'utf8' (e.g. &amp;lt;value&amp;gt;.encode('utf8')), I get "RFC FUNCTION CALL ERROR: RfcSetChar string too long" errors. The respective fields in SAP are say CHAR10 type and they should be able to contain the test data. Some further tests revealed that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Greek:
g = u'u03B1u03B2u03B3' &amp;lt;type 'unicode'&amp;gt;
repr(g) 
"u'\\u03b1\\u03b2\\u03b3'" (3 characters)
repr(g.encode('utf8')) 
"'\\xce\\xb1\\xce\\xb2\\xce\\xb3'" (6 characters)
 
Latin:
l = u'abc' &amp;lt;type 'unicode'&amp;gt;
repr(l) 
"u'abc'" (3 chars)
repr(l.encode('utf8'))
"'abc'" (3 chars)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not understand unicode programming that well, but if I send g.encode('utf8') to sapnwrfc, data is written to db successfully as long as their length, (that of repr(g) ), does not exceed that of the SAP field. The rest are truncated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What should the input be? Can you help me out here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Menelaos Maglis&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Menelaos Maglis on Sep 2, 2009 9:12 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Sep 2009 07:10:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nwrfc-python-unicode-input-encoding/m-p/6125553#M1364451</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-02T07:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: nwrfc python unicode input encoding?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nwrfc-python-unicode-input-encoding/m-p/6125554#M1364452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Menelaos,&lt;/P&gt;&lt;P&gt;did you already check SAP note  1021459 regarding this issue ?&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Nils Buerckel&lt;/P&gt;&lt;P&gt;SAP AG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2009 09:56:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nwrfc-python-unicode-input-encoding/m-p/6125554#M1364452</guid>
      <dc:creator>nils_buerckel</dc:creator>
      <dc:date>2009-09-11T09:56:55Z</dc:date>
    </item>
  </channel>
</rss>

