Application Development 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: 

Is it possible to create a uncode compliant (UTF-8) XML in 4.6C ?

Former Member
0 Kudos
218

Hello,

Is is possible to create a unicode compliant (UTF-8) XML document in SAP 4.6c ?.

Regards,

Jay

1 ACCEPTED SOLUTION

Former Member
0 Kudos
151

Thanks a lot Thomas.. It worked fine.

I have another question - please let me know.

I have to download the encoded XML file to app server. But after converting it to a table all entries are in hex format also are there any other ways to download the internal table other then dataset transfer.

Thanks again...

Jay

5 REPLIES 5

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
151

Yes - quite possible. Use the iXML libraries just like normal.

However before you render the XML into the output stream (IF_IXML_OSTREAM), tell the OSTREAM that you want to use UTF-8 encoding.

*  Encoding is type ref to IF_IXML_ENCODING.
*  ENCODING_TYPE is a constant set to value 'UTF-8'.
  data: s_encoding_type type string.
  clear streamfactory.
  streamfactory = ixml->create_stream_factory( ).
  s_encoding_type = encoding_type.
  encoding = ixml->create_encoding( character_set = s_encoding_type
                                    byte_order = 0 ).
* b_xml is type XSTRING
  ostream =
    streamfactory->create_ostream_xstring( b_xml ).

  call method ostream->set_encoding
          exporting  encoding = encoding.
  call method document->render
       exporting ostream = ostream
                 recursive = 'X'.

Former Member
0 Kudos
152

Thanks a lot Thomas.. It worked fine.

I have another question - please let me know.

I have to download the encoded XML file to app server. But after converting it to a table all entries are in hex format also are there any other ways to download the internal table other then dataset transfer.

Thanks again...

Jay

0 Kudos
151

I always use the Transfer to DATASET to write out the files to the APP Server. It doesn't matter if you send it to the app server (via dataset) or frontend (via GUI_DOWNLOAD); just be sure to use binary transfer.

I send the XML output directly in to a binary string (no internal table). I then send that to the app server as the binary string.

  clear ressize.
  ressize = ostream->get_num_written_raw( ).
open dataset filename1 for output in
                                     binary mode message message_text.
transfer b_xml to filename1 length ressize.
close dataset filename1.

I'm not sure if there is something eles here you are looking for.

0 Kudos
151

Hi Thomas,Thanks a lot for all your help. Could you please direct where can find help files for those classes ?.

Thanks again.

Jay