Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem while replacing iso-8859-1 to UTF-8

Former Member
0 Likes
1,529

Hi All,

I am trying to modify XMl file where encoding tag should have value as "UTF-8" instead of iso-8859-1.

For this, I have implemented BADI "DMEE_BADI_01" into custom BADI.

However, file gets modified by using below code.

REPLACE ALL OCCURRENCES OF REGEX '\b(iso-8859-1)\b'
       IN TABLE c_output_tab WITH 'UTF-8'.

But while opening generated file with internet explorer or and mozilla, I am getting the following error:

"Invalid at the top level of document. Error processing resource <Filename with Path>"

Can anybody please help me to resolve this issue?

Thanks & Regards,

Pratima.


Hi All,

I am trying to modify XMl file where encoding tag should have value as "UTF-8" instead of iso-8859-1.

For this, I have implemented BADI "DMEE_BADI_01" into custom BADI.

However, file gets modified by using below code.

REPLACE ALL OCCURRENCES OF REGEX '\b(iso-8859-1)\b'
       IN TABLE c_output_tab WITH 'UTF-8'.

But while opening generated file with internet explorer or and mozilla, I am getting the following error:

"Invalid at the top level of document. Error processing resource <Filename with Path>"

Can anybody please help me to resolve this issue?

Thanks & Regards,

Pratima.


3 REPLIES 3
Read only

Former Member
0 Likes
1,099

Hi Pratima,

There are reason why they are used ... They are encoding and depending on that the XML praser reads your document.

So if your document is build as UTF-8 and you change the Encoding to ISO it will not open as the characters are of ISO and the document is of UTF

For more details

http://www.java-forums.org/xml/6066-xml-parse-throws-saxparseexception-encoding-utf-8-insteadof-iso-...

Regards

Read only

Former Member
0 Likes
1,099

Perhaps classes CL_ABAP_CONV_IN_CE and CL_ABAP_CONV_OUT_CE can be used to change encoding. That, in addition to your replace statement may work.

Do read the class documentation.

Read only

arindam_m
Active Contributor
0 Likes
1,099

Hi,

Check the SAP Note 1017101. Might help to get more idea on the encodings involved. I think just changing the encoding type at header won't help. You may have to transform the data completely for proper interpretation of the XML data.

You might take help of PI XML Anonymizer if its there.

http://wiki.sdn.sap.com/wiki/display/XI/Changing+Namespaces+and+the+encoding+format+of+XML

Cheers,

Arindam