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

XML data encoding iso-8859-1 . Currently utf-16 is default encoding

Former Member
0 Likes
1,214

Hello ABAP Gurus ,

Need a help from you .

Scenario : We have SAP4.7 enterprise version which we have now converted to Unicode system . There is a BSP application which talks to an external web application (Non Unicode) thru HTTP protocol and sends data thru XML.

Problem : Problem is at the time when BSP application prepares the XML While preparing XML data , before converting to Unicode environment the encoding was "iso-8859-1" . But now after Unicode conversion , the encoding is "UTF-16".

The XML data looks like

<?xml version="1.0" encoding="utf-16"?><DATA><ACTION>CREATE_TICKET</ACTION><CRI

I have tried replacing "utf-16" by "iso-8859-1 " . The interface works . But at the recieving end , ie external web application , the German umlauts appear as some garbage values .

I know we need to enforce encoding . I have tried with the following code but could not suceed . The encoding appears as "utf-16".

Following is the section of code which I have written in BSP application.

  • Daten in DOM-Baum wandeln

CALL FUNCTION 'SDIXML_DATA_TO_DOM'

EXPORTING

name = 'DATA'

dataobject = ls_cr_xml

IMPORTING

data_as_dom = if_dom

CHANGING

document = if_document

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

error_out text-f47 text-f48 space space.

ENDIF.

  • DOM-Baum in Character-Stream wandeln

if_pixml = cl_ixml=>create( ).

IF if_pixml IS INITIAL.

error_out text-f50 text-f53 space space.

ENDIF.

if_pstreamfact = if_pixml->create_stream_factory( ).

IF if_pstreamfact IS INITIAL.

error_out text-f51 text-f53 space space.

ENDIF.

if_postream = if_pstreamfact->create_ostream_cstring( string = xml_doc ).

IF if_pstreamfact IS INITIAL.

error_out text-f52 text-f53 space space.

ENDIF.

--


Encoding--

data: gv_str type string.

data: gv_l_xml_encoding type ref to if_ixml_encoding.

data gv_l_resultb type boolean.

gv_str = 'ISO-8859-1' .

clear gv_l_xml_encoding.

call method if_pixml->create_encoding

EXPORTING

byte_order = 0

character_set = gv_str

RECEIVING

rval = gv_l_xml_encoding.

clear gv_l_resultb.

call method gv_l_xml_encoding->set_character_set

EXPORTING

charset = gv_str

RECEIVING

rval = gv_l_resultb.

call method if_document->set_encoding

EXPORTING

encoding = gv_l_xml_encoding.

----


Append child -

CALL METHOD if_document->append_child

EXPORTING

new_child = if_dom

RECEIVING

rval = lv_return.

IF lv_return NE 0.

error_out text-f47 text-f49 space space.

ENDIF.

--


Render the XML data to output stream--

CALL METHOD if_document->render

EXPORTING

ostream = if_postream.

After this section of code is executed , the variable xml_doc gets filled up with XML data .

<?xml version="1.0" encoding="utf-16"?><DATA><ACTION>CREATE_TICKET</ACTION><CRI

Can anybody help how to enforce encoding ?

Regards,

Laxman Nayak.

2 REPLIES 2
Read only

Former Member
0 Likes
560

Dear Laxman;

Any Luck Dear?

I am in a same situation... please pass to me your solution.

Best Regards,

Aslam Riaz

Read only

0 Likes
560

Hi Aslam Riaz,

Did you find any solution..?

Kindly help me on this issue.

Thanks and Regards,

Shailaja Chityala