Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

XML Encoding Issue - Format UTF-16 to ISO-8859-1

Dear Groupmates,

I have data in my Internal table which i am converting to XML using custom Transformation.

Data is going to third party.The third party system requires data in ISO-8859-1 Format but SAP is generating the same in UTF-16 Format.I have been able to change the format of file from

utf-16 to ISO-8859-1 format but after conversion i am getting invalid tag information in form of characters

like &lt , &gt etc..in my file.

Here is the code i have used to set the encoding to ISO-8859-1 :-

DATA: xmlout TYPE xstring.

DATA: ixml TYPE REF TO if_ixml,

streamfactory TYPE REF TO if_ixml_stream_factory,

encoding TYPE REF TO if_ixml_encoding,

ixml_ostream TYPE REF TO if_ixml_ostream.

ixml = cl_ixml=>create( ).

streamfactory = ixml->create_stream_factory( ).

ixml_ostream = streamfactory->create_ostream_xstring( xmlout ).

encoding = ixml->create_encoding(

character_set = 'ISO-8859-1' byte_order = 0 ).

ixml_ostream->set_encoding( encoding = encoding ).

Sample Output :-

<?xml version="1.0" encoding="iso-8859-1"?>

<AMS_DOC_XML_EXPORT_FILE><AMS_DOCUMENT AUTO_DOC_NUM="FALSE" DOC_CAT="CA" DOC_CD="CA" DOC_DEPT_CD="045" DOC_ID="XR10281060830400001" DOC_IMPORT_MODE="OE" DOC_TYP="CH" DOC_UNIT_CD ="NULL" DOC_VERS_NO="01">

<CH_DOC_HDR AMSDataObject="Y">

<DOC_CAT Attribute="Y">&lt;![CDATA[CA]]&gt;</DOC_CAT>

<DOC_TYP Attribute="Y">&lt;![CDATA[CH]]&gt;</DOC_TYP>

Please let me know if anyone has idea how i can get rid of the invalid tag information.

Thanks !

With Regards,

Darshan Mulmule

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question