How to convert xml utf 16 to utf 8

Is it possible to convert xml file with UTF16 to UTF8 using ABAP? I am using ECC 6.0
Appreciated your inputs.

Hhmm, interesting. I thought it should be straightforward, but it the two solutions I could think of seem a bit convoluted. First way is probably to use the iXML libray, where the starting point is the class CL_IXML. You can find the SAP documentation [here|http://help.sap.com/saphelp_nw04/helpdata/en/86/8280d212d511d5991b00508b6b8b11/frameset.htm].
Then there's a "manual approach": Use OPEN DATASET to read the UTF-16 file, then modify the XML encoding attribute and save it as UTF-8 file. Not straightforward, because the tempting command option [OPEN DATASET .. LEGACY TEXT MODE CODE PAGE|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_MODE.htm] doesn't work. Per ABAP help:
For the specification of the code page cp, a character-type data object is expected that must contain - at the time of execution of the statement - the label of a non-Unicode page from the column CPCODEPAGE in the database table TCP00. A Unicode page must not be specified.
Darn, looks like they expect most Unicode files to be UTF-8. But that might be the reason you want to convert it...
So use the following steps:
<ol><li>Open the file as a binary file (only option for UTF-16, seev[here|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_ENCODING.htm]) via [OPEN DATASET file FOR INPUT IN BINARY MODE|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET.htm] and read content into XSTRING using [READ DATASET|http://help.sap.com/abapdocu_70/en/ABAPREAD_DATASET.htm].</li>
<li>Convert it to a string using utility class [CL_ABAP_CONV_IN_CE|http://help.sap.com/saphelp_nw04/helpdata/en/79/c554afb3dc11d5993800508b6b8b11/frameset.htm], see example [here|http://wiki.sdn.sap.com/wiki/display/Snippets/ABAPCodePage+Conversions].</li>
<li>Replace the encoding markup for UTF-16 in the XML with a reference to UTF-8.</li>
<li>Write the XML content back to a file using [OPEN DATASET file|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET.htm] FOR [OUTPUT|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_ACCESS.htm] IN [TEXT MODE|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_MODE.htm] [ENCODING UTF-8|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_ENCODING.htm] and [TRANSFER|http://help.sap.com/abapdocu_70/en/ABAPTRANSFER.htm]</li></ol>
Maybe somebody has a shorter way...
Cheers, harald

Similar Messages

  • How to convert XML file to an internal table ?

    Hi All,
    I want to do a batch input program. The source data would be given as an excel file . I would like to know how to convert XML file to internal table properly. Please help me out..
    Thanking you in advance ..
    Shankara Narayanan T.V

    Hi Shankar,
    use 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
             EXPORTING
                  filename                = p_file1
                  i_begin_col             = '1'
                  i_begin_row             = '5'
                  i_end_col               = '40'
                  i_end_row               = '16'
             TABLES
                  intern                  = it_intern
             EXCEPTIONS
                  inconsistent_parameters = 1
                  upload_ole              = 2
                  OTHERS                  = 3.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    LOOP AT it_intern.
          AT NEW row.
            CLEAR it_intern.
          ENDAT.
            CASE lv_flag.
        Production Version
              WHEN  1.
                it_master-matnr      =   it_intern-value.     
              WHEN  2.
                it_master-werks      = it_intern-value.
              WHEN  3.
                it_master-verid      = it_intern-value.
              WHEN  4.
                it_master-text1      = it_intern-value.
              WHEN  5.
                it_master-fdate     = it_intern-value.
          AT END OF row.
            APPEND it_master.
          ENDAT.
        ENDLOOP.
    -Anu
    Message was edited by:
            Anupama Reddy

  • How to convert XMl file to XSD file

    how to convert XMl file to XSD file ?
    i have a xml file format  it has to be converted to xsd file through ABAP .
    Regards
    Anbu B

    i got the answer....
    Regards
    Anbu B

  • How to convert XML into word doc or pdf

    hi all ,
    i ve to create a xml with specified alignment,but while taking print out alignments changing according to IE's alignment.
    So, Plz some one tel me whether any solution is there in xml itself or it have to be convert into word doc or PDF.If so, tell me an idea for how to convert xml file into Word doc or PDF.

    thanx ,i saw about FOP in xml.apache.org site and i learned something abt tat . But i dont know how to download FOP package from apache..
    Actually they gave links to download
    like http://ftp.wayne.edu/apache/xml/fop
    inside tat link they mentioned as parent,Directory,binaries,sources and tar files.From this i dont know how to download?
    Plz can someone tell a solution..

  • How to convert XML into XSD Using Altova XML Spy

    Hi,
    How to convert XML file into XSD Using Altova XML Spy.
    I want to use that XSD as an External Def in my IR
    Regards
    Suman

    hi
    Following is the path where you could get the PDF's and zip file.
    https://www.sdn.sap.com/irj/sdn/howtoguides?rid=/webcontent/uuid/5024a59a-4276-2910-7580-f52eb789194b [original link is broken]
    please check out the following Heading, and at the bottom corner you will find the download option where you will get the zip file:
    How to Generate XSD Schemas from Existing MDM 5.5 Repositories
    You can download xomlite45.jar from sdn
    copy the jar file to your java installation location like c:>java in
    Java –jar xomLite45.jar MyFile.xml
    then you get correspondig MyFile.xsd
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/bf0e8a97-0d01-0010-f0a2-af3b18b7f4eb

  • How to convert XML data into binary data (opaque data)

    Hi,
    I am trying to develop a process that delivers files after reading data from a database.
    However, it is required not to deliver the data immediately. We want to perform some checks before the files get written.
    So the way we want to design this is,
    1. Read data from database (or any other input). The data is in XML format (this is a requirement, as in general, we have xml data)
    2. This data is written, opaquely, to a JMS queue that can store binary data, along with what is the filename of the file that would be written (filename is passed using JMS Headers)
    3. When required, another process reads the JMS queue's binary data, and dumps into a file
    The reason I want to use opaque data while inserting in the JMS queue is, that enables me to develop a single process in Step 3 that can write any file, irrespective of the format.
    My questions are
    1. How to convert the xml data to opaque data. In BPEL I may use a embedded java, but how about ESB. Any other way....?
    2. how to pass filename to the jms queue, when payload is opaque. Can I use a header attribute...custom attributes?
    3. Which jms message type is better for this kind of requirement - SYS.AQ$_JMS_BYTES_MESSAGE or SYS.AQ$_JMS_STREAM_MESSAGE

    Ana,
    We are doing the same thing--using one variable with the schema as the source of the .xsl and assigning the resulting html to another variable--the content body of the email, in our case. I just posted how we did it here: Re: Using XSLT to generate the email HTML body
    Let me know if this helps.

  • How to convert XML file to PDF

    Hi there,
    Does anyone know by any chance, how to covert XML file to PDF? Thanks

    Hello,
    You can convert most of the files in PDF by using the Print menu.
    Open the file you want to save in PDF and choose in the menu bar File > Print....
    You will see a will the Print window and at the left, click on the PDF button.
    Choose in the menu “Save as PDF...”
    Insert the name and you can also set security settings (like a password) and click on the “Save” button.
    Hope this will help.
    EDIT : (oups, dsimagry posted as the same time of me)

  • How to convert XML message in text format by using HTTPS-Receiver adapter

    Is it possible to convert XML message in text format when we use HTTPS as the receiver adapter?
    If yes, how?
    Thanks!
    Mrudula

    Hi Mrudula,
    As far as i know there are no content conversion methodology for HTTPS as the recevier adapter.
    Also you can read through these links to confirm the same:
    http://help.sap.com/saphelp_nw04/helpdata/en/0d/5ab43b274a960de10000000a114084/content.htm
    http://publib.boulder.ibm.com/infocenter/wbihelp/v6rxmx/index.jsp?topic=/com.ibm.wbia_adapters.doc/doc/sap_xi/sapximst30.htm
    SAP NetWeaver - XML Communication Interface (CA-XML) [original link is broken]
    Regards,
    abhy
    note: reward the helpful.

  • Jdev11g: How to convert  Xml resultset   to a ADF DataControl

    How to convert a Xml Resulset from a webservice response (biee webservice) to a ADF Data Control?

    Please post JDeveloper 11 questions on the JDeveloper 11 forum:
    JDeveloper and OC4J 11g Technology Preview
    How about using the Web Service Data control for this?

  • How to convert XML document to xml variable?

    Hi,
    I have taken an xml variable in my process and reading a xml document file. Can anyone tell me how can i convert this xml document to xml variable so that i can parse the xml variable.
    I am able to convert xml variable to xml document variable by using set value activity. But how do I perform reverse process.
    I want to perform this conversion because i want to keep xml data in document format on storage drive and then parse this xml data so that i can read the nodes.
    Any help will be appreciated..
    Regards
    Sunil

    we can use set value activity to reach these xml docs and assign it to xml variable.
    Then parsing of this xml can be browsed to find the nodes.
    Regards
    Sunil

  • How to convert xml file to xsl using java

    Hi all,
    I have an XML file with which i need to convert(transform) it to an xsl file using java.
    I am new to converting xml file to xslt.Please send me if u have code .
    Thanks in advance
    regards
    Ram

    You seem to be asking the wrong question. An XSL file can be used to transform an XML file, but transforming an XML into an XSL does not make sense. The API for running XSL transforms on the Java platform is described here:
    http://java.sun.com/javase/6/docs/api/javax/xml/transform/package-summary.html

  • How to convert  XML file to excel file

    To convert XML file to excel file. what are the jar files required. also tutorial to convert XML File to excel file

    Gotta use your own imagination.
    I'd have a root tag <excel-spreadsheet>. Under that I'd have a <worksheet> tag for each worksheet. Under that I'd have a <row> tag for each row. Each <row> tag would have <column> tags, with "name" attribute, and the spreadsheet entry as the value.
    The problem is that you can't really map everything that will go into a spreadsheet into this stream (e.g., graphs, stray cells, etc.) It maps well to tables, but that's it.

  • How to convert xml to non xml in business service

    I have created a business service which routes the data to the respective given email addresses.But the body of the body is in the form of xml tags but need the body to be in normal document type format.
    I have tried converting xml to mlf format(with delimiter '\n') before routing but still its the same xml tag which i get it from the body ,the only change being this time its a very simple xml file with just elements in it and no namespace declaration ,namespace definition etc.Please help me solve this problem?

    I am not sure exactly in which format you want to translate the XML but you may use either MFL transformation/Java callout in OSB to convert XML into non-XML or vice-versa -
    http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15866/part_fb.htm#BABEAIAF
    Regards,
    Anuj

  • How to convert XML to Binary in OSB Message flow

    Dear All,
    Can you please help me in converting XML to Binary in OSB Message flow.
    Please help.
    Thanks,

    ah ok, then you have to apply a transformation from XML to some fixed length format, EDI style
    probably you have 2 options: the traditional MFL
    http://docs.oracle.com/cd/E13159_01/osb/docs10gr3/consolehelp/mfls.html
    or the (probably) more supported nXSD with a JCA adapter
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/nfb.htm
    I will let you digest this info and then we can continue.
    There are a number of threads in this forum on whether one technology is better than the other (as usual, google can assist you)

  • How to convert xml data into html format in bpel

    Hi ,
    Can any one tel me how to conevrt xml into html in oracle bpel.
    Does bpel support this functionality or not.
    Regards,
    Ana
    Edited by: user10181991 on Apr 5, 2009 11:16 PM

    Ana,
    We are doing the same thing--using one variable with the schema as the source of the .xsl and assigning the resulting html to another variable--the content body of the email, in our case. I just posted how we did it here: Re: Using XSLT to generate the email HTML body
    Let me know if this helps.

Maybe you are looking for

  • Unable to change PR fields

    Hi Experts, I have one strange problem, we are runing classic scenario and PR is created in R/3 system for each shopping cart. I am unable to change item short text, UOM, price etc of these PR using ME52N in R/3 system . But if i create manually PR i

  • Creation of Purchase requisition in Maintainance order

    Hi I have a external operation in maintenance order , i have set the indicator in control key I assign service order in the maintainance order When i save the order system creates a purchase requisition Please let me know where is the setting which c

  • Display adapter randomly resetting

    I'm having two issues which may or may not be related. My display adapter keeps resetting itself. Sometimes it works and I can continue working.other times I get a screen full of vertical lines and have to reboot. The computer will also not bout or r

  • Oracle financial user guide

    Hi, could you provide the oracle financial application user guide. since we are new to this technology. we need the guide to explore the application. Thanks in advance. Jaya

  • Tears in my eyes...

    So I finally ventured into Illustrator CS4 and I find that...: When creating a box with snap to grid on, it truly "snaps" to the grid. When changing the stroke position on the box, the control points do not change position to match the outside of the