Working with Code Pages

Using Different Code Pages

Use the following procedure if you handle data that is encoded (or that you want to encode and send out) in a different coding from your operating systems default code page.

To Receive Data from HTTP, FTP, E-mail, or File

  • You can use the Services pub.client:http,pub.client:ftp, pub.client:smtp and pub.file:getFile to load a multi-byte document into the pipeline. Always use the option loadAs=bytes.
  • Convert the binary data using the Services pub.string:bytesToStringor a combination of pub.xml:xmlStringToXMLNode (also accepts bytes) and pub.xml:xmlNodeToDocument.
  • Set the input parameter encoding to the mime Encoding in which the bytes have been encoded, (one that is supported by the functions sun.io.ByteToChar XXX.class, where XXX stands for the encoding) for example: ASCII, ISO2022 or SJIS.

To Send Data Via HTTP, FTP, or E-mail or Save It to a File

  • Ensure that you do not pass any String objects into the Services pub.client:http, pub.client:ftp,pub.client:smtp or save a String into a file.
  • Call pub.string:stringToBytes with the correct encoding parameter.
  • Pass the bytes into ftp/http or into your Service which writes the file. (This service should use java.io.FileOutputStream to write the file, not FileWriter.) That way the message is sent out of Adapter for SAP with proper encoding.

To Encode Data from SAP Systems

About this task

To create the standard SAP XML you would use the service pub.sap.rfc:encode, which handles encoding automatically.

Note: If you wish to create other XML-documents from SAP data, you should be careful to avoid problems with code pages whenever you receive data from an SAP system (e.g. a response to an outbound Remote Function Call or via an inbound call).

You need to set the encoding attribute in the XML-document manually:

Use the following steps if you are using pub.xml:documentToXMLString

Procedure

  1. Extend your document by adding the attribute @encoding as a String as a child of the root element.
  2. Insert the proper default value (e.g. Shift-JIS, if your source data is Shift-JIS encoded).
  3. In the pub.xml:documentToXMLString Service, map your document to input field "document".