huysentruitw / SapNwRfc

SAP NetWeaver RFC library for .NET 5, .NET Core and .NET Framework
MIT License
148 stars 43 forks source link

new SapConnection(connectionString) :SapNwRfc.Exceptions.SapException Conversion error between two character sets #46

Closed Kiakaa closed 3 years ago

Kiakaa commented 3 years ago

When creating a connection, if there are special symbols (for regular expressions) in the connection string, the following error will be reported. Exception info: SapNwRfc.Exceptions.SapException:“SAP RFC Error: RFC_ABAP_RUNTIME_FAILURE with message: Conversion error between two character sets.”

Source Code Location:/src/SapNwRfc/SapConnectionParameters.cs

SapNwRfc_connError

campersau commented 3 years ago

Can you please checkout these links?

(Copied from https://github.com/SAP/node-rfc/issues/211#issuecomment-828312568)


We might need to call RfcUTF8ToSAPUC (and RfcSAPUCToUTF8) for all SAP_UC types manually.

The official libraries for go, python and node are using it:

https://github.com/SAP/PyRFC/blob/a9fbe54f7d94251ec2cda49845ff1e858d16696d/src/pyrfc/_pyrfc.pyx#L1936-L1948 https://github.com/SAP/PyRFC/blob/a9fbe54f7d94251ec2cda49845ff1e858d16696d/src/pyrfc/_pyrfc.pyx#L147-L150

https://github.com/SAP/gorfc/blob/9625d2d861ea3d9ac08b42d0a867d495fe5e581a/gorfc/gorfc.go#L143-L157 https://github.com/SAP/gorfc/blob/9625d2d861ea3d9ac08b42d0a867d495fe5e581a/gorfc/gorfc.go#L1015-L1019

https://github.com/SAP/node-rfc/blob/de2061a32822f1e8fd477d34ce337d99e6da840e/src/nwrfcsdk.cc#L38-L56 https://github.com/SAP/node-rfc/blob/de2061a32822f1e8fd477d34ce337d99e6da840e/src/nwrfcsdk.cc#L919-L926

Kiakaa commented 3 years ago

thaks! It's my fault, I didn't set the [PartnerCharSize=2] in the connectionstring。

As the initial handshake is done with ISO-Latin-1, the characters in username/passwd would break, resulting in a refused logon. In that case set PCS=2 and the RFC library will use Unicode for the initial handshake.

Explained in:nwrfcsdk/demo/sapnwrfc.ini (at line 289) and field map in Readme:Click here to expand the list of supported connection parameters.

sapnwrfc.ini.txt