Skip to Content
0

NetWeaver RFC SDK returns strange data on RfcGetString when receiving IDocs

May 02, 2017 at 11:57 AM

159

avatar image
Former Member

Hallo everyone,

I am currently writing a small C++ application for Windows in Visual Studio 2010. The application is now able to connect to SAP and retrieve the function description for IDOC_INBOUND_ASYNCHRONOUS. Afterwards it is also able to register the function on another connection and call RfcListenAndDispatch.

Whenever my colleagues send an IDoc for the registered connection, my dispatch function is triggered and tries to process the received data. The following commands are still successful:

RfcGetTable(rfcFuncHandle, cU("IDOC_CONTROL_REC_40"), &rfcControlTable, rfcErrorInfo)

RfcGetTable(rfcFuncHandle, cU("IDOC_DATA_REC_40"), &rfcRecordTable, rfcErrorInfo)

RfcMoveToFirstRow(rfcRecordTable, rfcErrorInfo)

RfcMoveToFirstRow(rfcControlTable, rfcErrorInfo)

Then I try to get data from the tables above:

RfcGetString(rfcControlTable, cU("IDOCTYP"), rfcCharBuffer, uiCharCount, &uiStringLength, pRfcErrorInfo)

This last call returns RFC_OK, but the data in rfcCharBuffer looks like Unicode in the wrong endian arrangment (server runs on AIX, client on Windows Server 2012) and there is almost nothing written inside the returned buffer... The text WMTORD can be identified at (ca.) offset 10 in the returned rfcCharBuffer, but that is not what I would have expected (WMTOID01 was expected by me).

The next call

RfcGetString(rfcControlTable, cU("DOCNUM"), rfcCharBuffer, uiCharCount, &uiStringLength, pRfcErrorInfo)

returns an incredibly high number...

Is there something that needs to be configured to ensure the correct Unicode handling between the two systems? Is this related to Unicode configuration at all?

Thanks for your help!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Isaias Freitas
May 03, 2017 at 05:54 PM
0

Hello Stefan,

Is the SAP system UNICODE?

And can you provide the source code of a sample C++ program that you can use to simulate the issue?

Regards,

Isaías

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

It is a non-unicode SAP. By now we fixed the issue. The RFC destination has to be configured as unicode to correctly work with the RFC SDK. My impression from the RFC SDK documentation was that the SDK always uses unicode, regardless of the SAP server's true encoding and data is converted automatically. That was obviously wrong...

Thanks for your answer anyway!

0

Hello Stefan,

You are welcome!

Indeed, the SDK would always use UNICODE.

This is exactly why the destination had to be adjusted (the non-UNICODE SAP system is sending data to an external system that is UNICODE - your C++ application).

Anyway, I'm glad that the issue is solved :-).

Can you please close this question, then?

Regards,

Isaías

0