Conversion of XML file in Noepad

Hi Folks,
i have a requiremnt like sending .TXT file and output is .XML.
when i open the file in internet explorer i Got right output. when open the same file in notepad the file is look like below
<?xml version="1.0" encoding="UTF-8"?>
<EDS_PII_XML><Header><FILE_DATE></FILE_DATE></Header><Employee><EMPLID>010203</EMPLID><LAST_NAME>PUBLIC</LAST_NAME><FIRST_NAME>JOHN</FIRST_NAME><Deductions><DEDUCTION_CODE>HM</DEDUCTION_CODE><RECORD_TYPE>A</RECORD_TYPE><BEGIN_DT>2009-01-01</BEGIN_DT><END_DT></END_DT><PRE_TAX_COST>33.48</PRE_TAX_COST><AFTER_TAX_COST>0.00</AFTER_TAX_COST><OPTION>KAHI</OPTION><COVERAGE_LEVEL>EF</COVERAGE_LEVEL><IMPUTED_INCOME>0.00
but i need the file like below:
<?xml version="1.0" encoding="UTF-8"?>
<EDS_PII_XML>
<Header>
<FILE_DATE></FILE_DATE>
</Header>
     <Employee>
          <EMPLID>010203</EMPLID>
          <LAST_NAME>PUBLIC</LAST_NAME>
          <FIRST_NAME>JOHN</FIRST_NAME>
          <Deductions>
               <DEDUCTION_CODE>HM</DEDUCTION_CODE>
               <RECORD_TYPE>A</RECORD_TYPE>
               <BEGIN_DT>2009-01-01</BEGIN_DT>
               <END_DT/>
               <PRE_TAX_COST>33.48</PRE_TAX_COST>
               <AFTER_TAX_COST>0.00</AFTER_TAX_COST>
               <OPTION>KAHI</OPTION>
               <COVERAGE_LEVEL>EF</COVERAGE_LEVEL>
               <IMPUTED_INCOME>0.00</IMPUTED_INCOME>
               <GOAL_AMOUNT>0.00</GOAL_AMOUNT>
          </Deductions>
          <Deductions>
               <DEDUCTION_CODE>HS</DEDUCTION_CODE>
               <RECORD_TYPE>A</RECORD_TYPE>
               <BEGIN_DT>2009-01-01</BEGIN_DT>
               <END_DT/>
               <PRE_TAX_COST>15.25</PRE_TAX_COST>
               <AFTER_TAX_COST>0.00</AFTER_TAX_COST>
               <OPTION>01</OPTION>
               <COVERAGE_LEVEL>EF</COVERAGE_LEVEL>
               <IMPUTED_INCOME>0.00</IMPUTED_INCOME>
               <GOAL_AMOUNT>150.00</GOAL_AMOUNT>
Any conversion is there in XI?
please let me know ASAP.
points also rewarded.
Thanks
Anil M

Hi Anil,
You can do the conversion with XSLT. Here's the code:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output encoding="utf-8" indent="yes" method="xml" version="1.0"/>
  <xsl:strip-space elements="*"/>
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:transform>
(This copies the complete XML, and created a formatted output - indent="yes". All other content remains untouched.)
How to integrate in SAP, read here: http://www.heidoc.net/joomla/en/technology-science/sap-and-xslt/5-tutorial-data-exchange-between-abap-and-xml
Best wishes,
Jan
Edited by: Jan Krohn on Jul 15, 2011 10:57 AM

Similar Messages

  • Conversion of XML file from ANSI to UTF-8 encoding in SAP 4.6C

    Hi All,
      Im working on SAP 4.6C version.I have generated a XML file from my custom report.It is downloading in ANSI format.But i need to download this into UTF-8 format.So can anyone please let me know how to do this?
    Is this possible in 4.6C version?
    Thanks in Advance,
    Aruna A N

    Hello
    It is possible in 4.6.
    Try this code:
    REPORT Z_TEST_XML_DOWN .
    data:
      lp_ixml type ref to if_ixml,
      lp_xdoc type ref to if_ixml_document,
      lp_sfac type ref to if_ixml_stream_factory,
      lp_ostr type ref to if_ixml_ostream,
      lp_rend type ref to if_ixml_renderer,
      lp_enco type ref to if_ixml_encoding.
    data:
      lp_root type ref to if_ixml_element,
      lp_coll type ref to if_ixml_element,
      lp_elem type ref to if_ixml_element.
    class cl_ixml definition load.
    data:
    udat like lfa1,
    s type string.
    select single * from lfa1 into udat where lifnr = '0000000001'. " <- set here real number
    *** create xml
    lp_ixml = cl_ixml=>create( ).
    lp_xdoc = lp_ixml->create_document( ).
    lp_root = lp_xdoc->create_simple_element( name = 'Node'
                                              parent = lp_xdoc ).
    s = udat-land1.
    call method lp_root->set_attribute( name = 'country_name'
                                        value = s ).
    s = udat-name1.
    call method lp_root->set_attribute( name = 'vendor_name'
                                        value = s ).
    s = udat-ort01.
    call method lp_root->set_attribute( name = 'city_name'
                                        value = s ).
    *** render xml
    types: begin of xml_tab_line,
             line(256) type x,
           end of xml_tab_line.
    types: xtab type table of xml_tab_line.
    data: t_xml type xtab,
          size type i,
          rc type i.
    lp_sfac = lp_ixml->create_stream_factory( ).
    lp_ostr = lp_sfac->create_ostream_itable( table = t_xml ).
    lp_enco = lp_ixml->create_encoding( character_set = 'utf-8'
                                   byte_order = if_ixml_encoding=>co_none ).
    call method lp_ostr->set_encoding( encoding = lp_enco ).
    lp_rend = lp_ixml->create_renderer( ostream = lp_ostr
                                        document = lp_xdoc ).
    rc = lp_rend->render( ).
    *** export to file
    size = lp_ostr->get_num_written_raw( ).
    call function 'WS_DOWNLOAD'
      exporting
        bin_filesize = size
        filename = 'c:\sapxml_test.xml'
        filetype = 'BIN'
      tables
        data_tab = t_xml
      exceptions
        others = 1.
    It is just simple example.

  • Conversion of xml file to xsd

    Hi SapAll.
    i have got a requirement in an IDOC To xml File Interface where i need to create a structure for the target xml file .
    here i have sample xml file ,so i just want to know if there is any other way to generate xsd from the xml file instead of creating strucure in PI.i mean is there any website to do this ?.
    if i can get the xsd from the sample xml file then i can just import that xsd directly into External Definition for the target xml file structure

    Hi
    but when i imported the the updated xsd into External definition it raises the error as below
    Unable to convert imported document to WSDL
    You might have done any syntax error,make sure you insert the required field properly in the exported XSD.
    If you have visual studio 2005 , in your PC then you can open the XSD using that and edit in a proper format.
    Its good if you have XML SPY , you can check the syntax correctness and validate the XSD before importing.
    check the syntax required by referring tohttp://www.w3schools.com/Schema/schema_simple_attributes.asp
    And also make sure while importing  you choose "xsd" instead of  wsdl which is the default option for importing
    external definition.
    Regards,
    Srinivas

  • SAP PI 7.1. Splitting XMl file after 998 rows.

    I need to split the XML file for FI interface after 998 rows. How I can use File content conversion with XML file at sender adapter?
    Please suggest me a solution.

    Hi Nirman,
    If it is an XML file then you need to handle that in mapping. Below is the sample code.
    int count  = 0;
    int count1  = 0;
    for(int j = 0; j< a.length; j++)
         count  = count + 1;
         count1 = count1+ 1;
         result.addValue(a[j]);
         if (count == 998)
    //     if (count == var998)
              if (a.length - count1==0)
                        count = 0;
              else
                        result.addContextChange();
                        count = 0;

  • Problem in file content conversion from XML to CSV

    Hi Experts,
    I am finding problem in file content conversion. I need to convert the following XML file into CSV file:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_CROSS_REF xmlns:ns0="urn:dabur:idoc2file:pos">
          <Update_type>2</Update_type>
          <PLU>00000000</PLU>
          <Cross_ref_PLU>7777777</Cross_ref_PLU>
          <Capture_PLU />
          <Package_size />
          <Package_desc />
      </ns0:MT_CROSS_REF>
    The output file data has to be like:
    2,00000000,7777777,,,,
    The problem I am facing is while specifying the content conversion parameters in communication channel i dont know what recordset structure i should mention as all the records are directly under root. If I mention recordset structure as "ns0:MT_CROSS_REF" and parameters as
    ns0:MT_CROSS_REF.fieldSeparator   ,
    ns0:MT_CROSS_REF.endSeparator    'nl'
    i get error in communication channel monitoring and no file is posted.
    Please help me as to what correct parameter i should mention in my case.
    Thanks,
    Regards,
    Yash

    Hi Chirag,
    I cannot change the xml file as it comes after mapping idoc to a message type. How can I add ROOT in the xml? My message type is like MT_CROSS_REF and it has those 6 fields as in the XML (Update_type, PLU etc.). I do the mapping of these fields from a IDOC and get the XML.
    I hope you got my point.
    Thanks,
    Yash

  • "character conversion error" while parsing xml files

    Hello,
    I'm trying to parse MusicXML (Recordare) files, but I'm getting an exception.
    I'm using the SAX parser (javax.xml.parsers.SAXParser).
    Here is the code I use to instantiate it:
    final javax.xml.parsers.SAXParserFactory saxParserFactory = javax.xml.parsers.SAXParserFactory.newInstance();
    final javax.xml.parsers.SAXParser saxParser = saxParserFactory.newSAXParser();
    final org.xml.sax.XMLReader parser = saxParser.getXMLReader();
    I'm using my own handler, but I get the same exception even if I use org.xml.sax.helpers.DefaultHandler.
    The error I get is:
    Character conversion error: "Illegal ASCII character, 0xc2" (line number may be too low).
    The first few lines of my xml files look like this:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE score-partwise
    PUBLIC "-//Recordare//DTD MusicXML 0.6 Partwise//EN"
    "http://www.musicxml.org/dtds/partwise.dtd">
    <score-partwise>
    [...etc...]
    If I delete the <!DOCTYPE ...> line, then I don't get the exception anymore. But the MusicXML files I get (from some other program) always contain this line, and it would be quite some work to delete them from every file manually.
    So does anyone know if there is a way to avoid deleting that line in every file, while still being able to parse the xml files without exceptions?
    Or maybe does anyone know what the exact cause of the exception is? (because I don't know what exactly causes it)
    Thank you in advance.
    Greetz,
    Jipo

    So does anyone know if there is a way to avoid
    deleting that line in every file, while still being
    able to parse the xml files without exceptions?ok this is side-stepping the real problem but I've used this code to filterout DTD references for other reasons   public static InputStream filterOutDTDRef(InputStream in) throws IOException {
          BufferedReader iniReader = new BufferedReader(new InputStreamReader(in));
          StringBuffer newXML = new StringBuffer();
          for(String line = iniReader.readLine(); line!=null; line = iniReader.readLine())
             newXML.append(line+"\n");
          in.close();
          int s = newXML.indexOf("<!DOCTYPE ");
          if(s!=-1)
             newXML.replace(s,newXML.indexOf(">",s)+1,"");
          return new ByteArrayInputStream(newXML.toString().getBytes());
       }and it actually speeds up the parsing phase too (since the DTD ref.s were on the web and the XML standard mandates that there is a fetch for each xml file parsed..)
    you can feed the above into the InputSource constructor that takes an InputStream argument.
    Now for the real problem... 0xc2 is "LATIN CAPITAL LETTER A WITH CIRCUMFLEX" according to a unicode chart - which is not an ASCII character (as the error message correctly reports). I'm not sure why the file is being parsed as ASCII though? You could try parsing in a FileReader to the inputsource and hope it picks up the default character encoding of your system, and that that character encoding matches the file. Or you could try passing in a FileReader constructed with a explicit character encoding (eg "UTF8") and see if that does the trick?
    asjf

  • XML file conversion after sender file content conversion

    Hi,
    I have issue refarding file content conversion.
    My input structure is
    <MT_RCICrecords>
    <TRNH>
      <RCIC>
        <RECH>
        <RECL>
      <RCIC>
    <TRNH>
    Afetr sender File content conversion (csv to xml) it produces xml file as below (since file conversion does not support 3rd level of hierarchy)
    <TRNH>
    <RECH>
    </RECH>
    <RECL>
    </RECL>
    </TRNH>
    It does not recognize RCIC.
    Now i am trying to map this to IDOC and getting error as
    'MT_RCICRecords tag found instead of IDOC BEGIN ='.
    CAn anyone suggest me how to chaage this xml output after File content conversion to add RCIC tag in xml file?
    I am new to XI so please give me some sample code to.
    Thanks.
    Yashpal
    Its urgent!

    My problem is xml generated from content conversion is like below
    <MT_RCICrecords>
    <TRNH></TRNH>
    <RECH></RECH>
    <RECL></RECL>
    <TRLR></TRLR>
    </MT_RCICrecords>
    and i want it to be
    <MT_RCICrecords>
    <TRNH></TRNH>
    <RCIC>
    <RECH></RECH>
    <RECL></RECL>
    </RCIC>
    <TRLR></TRLR>
    </MT_RCICrecords>
    which is not happening
    My input message structure is
    MT_RCICrecords
    TRNH
    RCIC
    RECH
    RECL
    i hope it is clear now
    TRLR

  • Skipping the content conversion if the input file is an xml file.

    Hi,
    My source folder contains both text files and xml files.
    I want to skip the content conversion if the input file is an xml file and the same Content conversion as to work if the input file is a text file.
    Is there any way to achieve this?
    Regards
    Divia

    Hi,
    I think u hv to create 2 separate Communication Channels.............. 1 for XML (without Content Conversion), & other for TXT with Content Conversion.
    In 1st CC give file name as *.xml & in 2nd give file name as *.txt
    Thanks,
    Maheshwari

  • Error: Conversion of complete file content of 'filename here' to XML format

    "Error: Conversion of complete file content of 'filename here' to XML format failed"
    We process inbound files every hour, we now got this message we have never seen. But every hour, for three hours, one in many files that are processed get this error. But the file ends with success, and after spot checking the file looks like it made it into SAP.
    What is happening? Anybody know?
    Thank-You.

    hey
    did u see any adapter with red button?
    i m pretty sure there will some sender adapter with red button(meaning error)
    also whatever message failed,can u copy that payload from sxmb_moni and test the message mapping under test tab in IR
    thanx
    ahmad

  • XML File to Flat File scenario: Reciver file adaptor content conversion

    Hello Friends,
    Currently I am working on XML File to Flat File Scenario.
    I used receiver side File adaptor with content conversion.
    My receiver side adaptor is giving error. Error is given below.
    Conversion initialization failed: java.lang.Exception: java.lang.Exception: Error(s) in XML conversion parameters found: Parameter '.fieldFixedLengths' or '.fieldSeparator' is missing
    My content conversion parameters are as:
    row.fieldNames                           Customer_ID,Name,Address,Phone
    row.fieldSeparator                      ,
    row.processConfiguration          FromConfiguration
    row.endSeparator                       'nl'
    Can you please suggest me what kind of error is this?
    Regards,
    Narendra

    Still I am facing below given issue.
    2010-06-08 15:34:25     Error     File adapter receiver channel CC_Customer_FlatFile_Distination is not initialized. Unable to proceed: null
    2010-06-08 15:34:25     Error     Exception caught by adapter framework: Channel has not been correctly initialized and cannot process messages

  • Issue with Date Conversion when loading XML File into Oracle 10g Database

    Hello all,
    I have the interface shown in the screenshot below. In it, amongst other actions, I'm mapping an XML file element representing a date to an Oracle table column defined as DATE. The source and target columns are highlighted in the screenshot.
    !http://img223.imageshack.us/img223/1565/odiscr275.jpg!
    When I execute the interface, I get the following error message:
    java.lang.IllegalArgumentException at java.sql.Date.valueOf(Date.java:103)
    I'm assuming this refers to the date conversion!
    I've already tried replacing SRC_TRADES.DEAL_DATE with TO_DATE( SRC_TRADES.DEAL_DATE, 'DD/MM/YYYY' ) in the Implementation tab. This function was not recognised when I executed the interface, so it didn't work! The date value in the XML file is in DD/MM/YYYY format.
    I'm guessing that Oracle SQL Date functions don't work in the Implementation tab. Please could somebody let me know:
    1. Which Date Conversion function I could use instead?
    2. Where I can find a reference for the methods/functions I can use in the Implementation tab (if such a reference exists)?
    Cheers.
    James

    Hi.
    Try to change the execution area to staging area. After You change it, write in the mapping box just SRC_TRADERS.DEAL_DATE. When You use TO_DATE, the source field typu should be varchar2, not date (as it is in your source datastore)

  • File conversion of complex XML file

    Hi,
    we are trying to collect several IDOCs to a flat file. Therefore I create one message with the following structure:
    <i><File>
    <Message>
    <Segment1>
    <value1>a</value1>
    </Segment1>
    <Segment2>
    <value1>b</value1>
    </Segment2>
    </Message>
    <Message>
    [Same Message body]
    </Message>
    </File></i>
    Each segment should be converted to a new line.
    Unfortunately this structure is to complex to convert it using the Content Conversion of the file adapter.
    Is there any way to solve this problem without using the Append mode of the adapter ?
    Best regards,
    Linus

    Hi,
    thanks for your answers.
    The problem in our case is, that there could be "several messages in one", meaning:
    <i><XML Message>
    <SubMessage1>
      <Seg1>
      </Seg1>
      <Seg2>
      </Seg2>
      <Seg2>
      </Seg2>
      <Seg3>
      </Seg3>
    </SubMessage1>
    <SubMessage2>
      <Seg1>
      </Seg1>
      <Seg2>
      </Seg2>
      <Seg2>
      </Seg2>
      <Seg3>
      </Seg3>
    </SubMessage2>
    ...additional submessages...
    </XML Message></i>
    This structure should be converted to the following:
    <i>L1 [Seg1]: value;value;value...
    L2 [Seg2]: value;value...
    L3 [Seg2]: value;value...
    L4 [Seg2]: value;value...
    L5 [Seg3]: value;value...
    L6 [Seg1]: value;value...
    ....</i>
    The problem is, that I don't know how to map the n elements of m complex elements of an XML message to n*m simple elements (which could be converted by the file adapter).
    Could you see my problem?
    Best regards,
    Linus

  • Wlw-manifest.xml file missing con:conversation-state-table entries

    Hello,
    (cross-posted from weblogic.developer.interest.jndi)
    I am using WebLogic 8.1.4 (WLI 8.5). When our wlw-manifest.xml file is generated, it is MISSING all the <con:conversation-state-table> tags which typically contain the name of the database table that is required for each "top-level-component".
    Typically when you compile your WebLogic project into an EAR file a wlw-manifest.xml file is generated for your project, including any JMS Queues and database tables that are required to run in production mode.
    Previously we were using WebLogic 8.1.3 (WLI 8.3) and those entries were created correctly in the wlw-manifest.xml file, but after our upgrade they are not being created anymore. NOTE: The JMS queue entries are still being correctly created after the upgrade.
    Any idea what I need to do with WL 8.1.4 (WLI 8.5) to get the table names generated into the wlw-manifest.xml file again? A compiler argument or something like that perhaps?
    Thanks in advance,
    Chris

    Hi all!
    I am having the same problem with WebLogic Workshop 8.1 SP4.
    Any idea?
    Thanks in advance.

  • Conversion of xls file into xml file

    Hi,
    i want to convert xls file into xml
    pls let me know the procedure for it
    Thanks

    Hi Anu,
    U can use FM <b>SAP_CONVERT_TO_XML_FORMAT</b> to convert data to XML.
    Or u can use some threads related to this FM. So that u can get better idea about this.
    Check this link also
    conversion of xls file into xml file
    regards,
    raghu

  • Conversion of DOM object to XML file

    Hi
    Is there a direct method for conversion of a Document object to xml file? My code is like this
    Transformer aTransformer = tranFactory.newTransformer();
              System.out.println("Tansformers :"+aTransformer);
              aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
              DOMSource src = new DOMSource(resultDocument);
              System.out.println("src :"+src);
              Result dest = new StreamResult(new FileOutputStream(new File(filepath)));
              System.out.println("desc :"+dest);
              aTransformer.transform(src, dest);
    but the line DOMSource src = new DOMSource(resultDocument);
    is giving me an error like "undefined constrctor" . what must be the problem?
    Thanks

    DOMSource src = new DOMSource(resultDocument);
    resultDocument should be of type org.w3c.Node

Maybe you are looking for

  • Hashcode switch problem

    Hello. Can anyone tell me why this isn't working? I'm trying to use a switch off of a String, so I take the hashcode of it and compare it to the possible input strings. It looks like it should work, it's just comparing intergers, but my compiler alwa

  • I can no longer see the firefox box on the left of the screen above the tool bar

    Came home from work and the wife lost it. How do I restore the firebox logo onto the left corner above the toolbar

  • IWeb published to .mac- slideshow not working

    The slideshow and 'click to enlarge' features are not working. The button is there, but nothing happens when I (or anyone) click on them. How do I activate these functions? Also, I downloaded Moble Me, but I don't think I activated it because when I

  • PI 7.1 LDAP connectivity

    Hi , We configured our PI 7.1 system to connect to Active Directory(LDAP), we completed all the configuration in T Code-LDAP.But when i see Java stack user administration --> Configuration Data Source is still ABAP System. I am not able to change Jav

  • HT204053 iCloud document sync being strange

    I'm having an issue with icloud documents.  I have 10.8.2 mac software, the iphone 5, and an ipad 2 (both of which are on the latest ios).  They're all synced to the same @me.com account, so the documents should be showing up correctly in Pages.  Wha