Convert XML string into an abap format date and time

Hi,
Does anyone know of a method or a function module in ABAP which converts XML string into an abap format date and time.
Here is a part of the xml that I want to convert.
<ns2:EventDateTime>2009-07-02T10:13:45+10:00</ns2:EventDateTime>
<ns2:EventMessageTransmissionDateTime>2009-07-02T10:13:45.987+10:00</ns2:EventMessageTransmissionDateTime>
Currently EventDateTime and EventMessageTransmissionDateTime are type XSDDATETIME_Z and these are converted to proper dates and times. We will be changing these fields to a STRING instead of XSDDATETIME_Z. The reason for this is to make the field more versatile. The customer would be receiving dates with Zulu (2009-09-23T12:00:00Z), with offsets (2009-09-23T12:00:00+10:00/-10:00) and just local timestamp (2009-09-23T12:00:00). With this, we need to make the date fields as string
to be able to accept the various date formats (esp. the local timestamp).
I am looking for a standard function module or method that will convert the xml string to a proper date and time abap format.
Would appreciate anyone's help!
Thanks.
Edited by: eunice ocson on Jul 13, 2009 1:49 AM
Edited by: eunice ocson on Jul 13, 2009 1:50 AM
Edited by: eunice ocson on Jul 13, 2009 1:51 AM
Edited by: eunice ocson on Jul 13, 2009 1:51 AM

Hi Eunice
Use the FM 'SMUM_XML_PARSE'
for more info
[Convert XML string to ABAP|XML String to ABAP or GUI]
hope it helps you.
Thanks!!

Similar Messages

  • Convert XML string into XML

    Hi All,
    Can you please let me know for any sample code in xslt/java mapping for converting XML string into XML. We use SAP Pi 7.0
    My XML string starts like this
    <?xml version="1.0" encoding="UTF-8" ?> 
    - <ns0:MT_ReceiverFileStructure <namespace>"><Output><?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<xsl>"?><Tarih_Date Tarih="11.09.2014" Date="09/11/2014>
       Thanks,
       Pavithra

    Thanks Praveen. It worked.
    However, the xml i have is an extract from a exchange rate URL and it has the reference to a xsl in it as below
    <?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<ABC.xsl>"?>.
    So there is an error in sxmb_moni. Is it possible to remove this.

  • Convert XML string into DOM

    Hi all,
    I have a question here regarding converting XML string into a DOM document.
    How can I do this in Java?
    The Document.Parse() methods do not have one that takes in String as its parameter.
    I'm not sure what is the best way to do this in Java.
    Any help is greatly appreciated.
    Thank you in advance.
    regards,
    Sean

    Convert XML String to Document with StringReader.
    String xmlString;
    DocumentBuilderFactory factory =
                DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
       Document         document = builder.parse(new InputSource(new StringReader(xmlString)));

  • XML: How to convert xml string into Node/Document

    I have a string in xml form.
    <name>
    <first/>
    <second/>
    </name>
    I want to convert this string into DOM Node or Document.
    How can I do this?
    Any help or pointer?
    TIA
    Sachin

    Try this :
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(new org.xml.sax.InputSource(new StringReader(strXml)));Hope this helps.

  • Formatting Date and Time in Smartforms.

    Hello,
    I'm a newbie and I'm working with smartforms.
    My requirement is to get the following format of date and time in a text within a template.
    'MMM DD HH:MM'
    Like : Jan 01 12:45
    I have tried SAPScript Commands like 'SET DATE MASK' but that doesn't appear to work.
    Do I have to use a Function Module?
    Please help out. A sample code will be appreciated!
    Regards & Thanks,
    Arun G Nair

    Hi,
    please see this code
    DATA: V_DATE1 TYPE STRING
    SELECT SINGLE LTX FROM T247
       INTO MONTH_NAME
       WHERE SPRAS = SY-LANGU
       AND MNR = SY-DATUM+4(2).
    CONCATENATE MONTH_NAME  SY-DATUM+6(2)  DATE1(4)
        INTO V_DATE1 SEPARATED BY SPACE.

  • How do i format date and time in SSRS 2008

    Okay, so i am working with SSRS 2008. I am formatting the date and time. Right now the current out put is 1/13/2014 8:02:11 AM. I want the output to
    be 1/13/14 8:02 AM. What is the expression for this? 
    Thanks in advance

    There are 2 functions that can be used, Format and FormatDateTime.
    http://www.jackdonnell.com/?p=122
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • Convert xml string into xml file?

    Hi,
    I got a method that returns an JDom Element object.
    Then I use the JDOM Element toString method() to change it into xml string.
    Now, I need to convert it into actual xml file.
    How to I do it?
    Thanks.

    Hi,
    If you got an xml string, just write it to an ordinary file. Look at FileWriter.
    /Kaj

  • How to convert xml file into internal table in ABAP Mapping.

    Hi All,
    I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
      <BookingCode>2KY34R</BookingCode>
    - <Passenger>
      <Name>SARVESH</Name>
      <Address>THANE</Address>
      </Passenger>
    - <Passenger>
      <Name>RAJESH</Name>
      <Address>POWAI</Address>
      </Passenger>
    - <Passenger>
      <Name>CARRON</Name>
      <Address>JUHU</Address>
      </Passenger>
    - <Flight>
      <Date>03/03/07</Date>
      <AirlineID>UA</AirlineID>
      <FlightNumber>125</FlightNumber>
      <From>LAS</From>
      <To>SFO</To>
      </Flight>
      </ns0:MTO_ABAP_MAPPING>
    AT the receiver side I wnat to concatenate the NAME & ADDRESS.
    I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
    but couldnt succeed to convert the xml file into internal table perfectly.
    Can anybody help on this. 
    Thanks in advance!!
    Sarvesh

    Hi Sarvesh,
    The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
    Just in case you have not seen this
    regards
    Vijaya

  • Convert XML file into ABAP Query

    Hi All,
    Can we capture a XML file generated from a Non-SAP system in SAP system and convert into ABAP Query to retreive Data from DB and post it back as a XML query to the same Non-SAP system using a Middleware. Can this process be done in cache memory level itself instead of saving in DB.
    If it is possible pls do tell the procedure and steps to be followed.
    Suggestion and Help will be much Appreciated
    Thanks & Regds.
    Ramesh

    Hi check these blogs....
    <a href="/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach:///people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
    <a href="/people/tobias.trapp/blog/2005/12/08/xml-processing-in-abap--part-6:///people/tobias.trapp/blog/2005/12/08/xml-processing-in-abap--part-6

  • Converting XML string to ABAP types

    Hello,
    I am having a requirement where i wanted to parse incoming XML string and i checked few of examples of CALL TRANSFORMATION id.
    but whatever examples i checked those were simple transformation with no hierarchy.
    My source structure
    <record>
    <firstname>XYZ</firstname>
    <position>Testposition</postion>
    </record>
    and i used
    CALL transformation id
    source xml lv_xml
    result firstname = lv_firstname position = lv_position.
    but lv_firstname and lv_position were blank. any idea whether it can be acheived through such method?
    thanks in advance.
    regards
    rajeev

    Hello Rajeev,
    Try using the following simple transformation
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="record"/>
      <tt:template name="record">
        <record>
          <firstname>
            <tt:value ref="record.firstname"/>
          </firstname>
          <position>
            <tt:value ref="record.position"/>
          </position>
        </record>
      </tt:template>
    </tt:transform>
    In your code you could define a structure like the following:
    TYPES: BEGIN OF record,
                  firstname TYPE char50,
                  position  TYPE char50,
                END OF record.
    And now you could use the CALL TRANSFORMATION in your code to convert the xml string into the structure and visa-versa.
    CALL TRANSFORMATION zcl_test_rec
          SOURCE XML lv_string
          RESULT record = ls_test.
    Where lv_string holds the xml as a string and ls_test is defined as a structure of type record (defined above).
    Hope this helps.
    Thank you,
    Ramneek

  • Convert a String Mar 7, 2008 to date in yyyy-dd-mm format

    Hi,
    Please help me to Convert a String Mar 7, 2008 to date in yyyy-dd-mm format..
    have to store that Date in SQL Server date field in yyyy-dd-mm.
    Regards,

    I done this and got the desired result 2008-03-07. Thanks... know checking it with my code :)
    String ss = "Mar 7, 2008";
              //System.out.println(ss);
              try{
              SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd, yyyy");
              Date date = dateFormat.parse(ss);
              System.out.println(date.toString());
              System.out.println(new java.sql.Date(date.getTime()));
              }catch(Exception ee)
                   ee.printStackTrace();
              } //endsEdited by: bunty_india on May 8, 2008 8:09 PM

  • A class to format an XML string into indented xml code

    I am looking for a class or a piece of code to format an XML string into indented xml code
    for example: an XML string as follows
    <servlet><servlet-name>Login</servlet-name>servlet-class>ucs.merch.client.system.LoginServlet</servlet-class></servlet><servlet-mapping><servlet-name>Login</servlet-name>
    to format into :
    <servlet>
    <servlet-name>Login</servlet-name>
    <servlet-class>ucs.merch.client.system.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Login</servlet-name>
    <url-pattern>/Login</url-pattern>
    </servlet-mapping>
    e-mail : [email protected]

    Xerces has a class called OutputFormat
    If you have your XML document in memory, you can format it using the method setIndenting(true) on the OutputFormat class. The following is an example:
    assuming xmlDoc is our document and fileName is the name of the file we wish to write to:
    OutputFormat format = new OutputFormat(xmlDoc);
    // setup output file name
    PrintWriter printwriter = new PrintWriter(new FileWriter(fileName, false));
    // construct an XMLSerializer for writing the document
    XMLSerializer serializer = new XMLSerializer( printwriter, format );
    // Ensure output is indented correctly...
    format.setIndenting(true);
    // set serializer as a DOM Serializer
    serializer.asDOMSerializer();
    // serialize the document
    serializer.serialize(xmlDoc);
    hope this helps!
    Rob.

  • Does anyone can help me to import XML string into a ORACLE database

    Hi guys!
    i have some problem that my friend wants me to convert XML string to Oracle relational database which means.
    let's say, there is a table that a row has XML string.
    so table has XML string with varchar type.
    what my friend want me to do is, the string needs to be solved as a relational database.
    like
    A table has 'ID', 'data', 'result' rows
    and Data column has XML string like <?xml version...............>
    then wants to convert that data column's XML data into TABLE B with structure normally XML has.
    i'm so confused and have no idea at all.. also i couldn't find any solution related to my stuff..
    if someone knows how to solve the problem, just let us know
    thx

    The database is 10.2.0
    What sort of example do u want me to give you..
    i thought i give all information on the post..
    i will explain it
    let's say there are 3 columns ID,Name,Code
    Id = normal integer
    Name= varchar
    Code= varchar
    and i need to conver that XML in the Code column into relational databases
    the code column has normal XML code which is starting from <?xml version.... and so on
    so does it explain?
    please help me!

  • REG: WRITE XML STRING INTO XML FILE

    Hi All, I have a XML FILE on PC. I get a xml string from my server.
    My Task: I want to append the xml string coming from the server into the existing xml file at a particular Node. Given below is my code :
    String xmlString = baos.toString();
                      DocumentBuilder db4XMLString = docBuilderFactory.newDocumentBuilder();
                      InputSource inStream = new InputSource();
                      inStream.setCharacterStream(new StringReader(xmlString));
                      Document doc4XMLString = db4XMLString.parse(inStream);
                      Node root4XMLString = doc4XMLString.getElementsByTagName("epg").item(0);
                      doc.appendChild(doc.importNode(root4XMLString, true));
                      File file = new File(Constant.XMLFILEPATH);
                      Result result = new StreamResult(file.toURI().getPath());
                      Source source = new DOMSource(doc);
                      Transformer xformer = TransformerFactory.newInstance().newTransformer();
                      xformer.transform(source, result);But, wen i run my application I get following exception:
    The markup in the document following the root element must be well-formed.
    org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    Is that my XML string is not well formed. Is it so then please let me how to convert my xml string into well formed XML data.
    Please help me out.
    Thanking You.

    There are many reasons why xmlString could be not well formed. There is no magic recipe for making it well formed: just look at it and see why it is not parseable.
    Note that this line:
    String xmlString = baos.toString();can be problematic if you have non ASCII-7 characters in your XML document. baos could then contain a byte representation of these characters in one particular encoding, but, since you use the .toString() method that relies on the default encoding of your system, you can end up with a mismatch and garbage in your XML.

  • Read an XML file into an ABAP program and manipulate it.

    I would like to know if it is possible to do the following in an ABAP program:
    1) Read an XML file into an ABAP internal table
    2) Call an XSLT transformation on the source file and store the results in an ABAP table.
    Is this possible to do? I have used ABAP XSLT in PI, but never in an ABAP program. I see you can use the CALL TRANSFORMATION command, but I have never used it in an ABAP program.
    Kind Regards,
    Tony.

    Check out these blogs.
    XML DOM Processing in ABAP part I -  Convert an ABAP table into XML file using SAP DOM Approach.
    XML DOM Processing in ABAP part II - Convert an XML file into an ABAP table using SAP DOM Approach.

Maybe you are looking for

  • Can't find/retrieve named image file

    When editing photos with CS6, I export afterwards to a file I've created for the purpose. For example, "Vacation." Unfortunately, I noticed I was not careful about where this file had been placed and the only way I can locate it is when I'm saving th

  • High cpu load average

    Hi Experts, I have a SOA deployed on AS 10.1.3.2 which is integerated with BI EE 10.1.3.2 on OHEL 4. With this setup, I have seeing very high load average on cpu side. When I stop the soa oc4j the load average comes to normal level of under 1. While

  • How can I get file name using JSTL ?

    Hi, I'm now using <c:out value="${pageContext.request.requestURI}"/> this return servlet path How can I get just file name or user path (in location bar) ? thanks in advance

  • I am going to go to hong kong and i 've got a ipod nano 1.generation

    like the title, i want attend ipod nano 1.generation changing program(something like this) i dont attend this program from my country because i'm living in Turkey, there isn't any Apple Store and on the website of apple, there isn't any information a

  • ' Landscape in XI '

    Hi All    Can any one explain me what is land scape of XI in real time projects?    What it contains ? Any information on this is most welcome ! Adv..thanks and regards ---  Rakesh