Developing OTDs for Application Adapters

SAP BAPI Encoding

SAP BAPI/RFC OTDs are encoding independent of the SAP system. This means that OTDs created on a Unicode SAP instance can seamlessly interact with non-Unicode SAP instances, and vice versa. In addition, the marshal and unmarshal encoding methods on the IDOC_INBOUND_ASYNCHRONOUS OTD only apply to the data, and not to the SAP instance. The default for all processed byte data is UTF-8, regardless of connection type (Unicode or non-Unicode).

When attempting to unmarshal data flows using an encoding other than UTF-8, such as UTF-16, then you must also call the setUnmarshalEncoding method to specify this encoding. This enables the Adapter to properly unmarshal the byte array.

You also need to set the correct Character Set in the Environment parameters for an inbound Adapter when receiving data from SAP. This way, the Adapter knows whether it is receiving Unicode or non-Unicode data from the SAP instance. The setMarshalEncoding method is only for marshaling the OTD data into a byte array and is not related to the SAP system character set.

Like the outbound data flows mentioned above, attempting to marshal data flows using an encoding other than UTF-8, such as UTF-16, requires setting the setMarshalEncoding method to match this encoding. This enables the data received from SAP to be correctly converted to a byte array of the desired encoding.