Even Based XML Parsing in ABAP

Hi all ,
  Currently i am using DOM Based Parsing to parse XML in my ABAP program. i am planning to change the code by using Event based parsing which is recommended for perfomance when we parse large xml document
Any one have the Example program for event based parsing the xml .pls help me in this.
Thanks in Advance
Ram

Hello,
you can look at the coding example
data: event     type ref to if_ixml_event,
      event_sub type i
lp_dom type ref to if_ixml_document,
pstreamfac    TYPE REF TO if_ixml_stream_factory,
       pistream      TYPE REF TO if_ixml_istream,
create the factory for streams
pstreamfac = g_ixml->create_stream_factory( ).
create the input stream:
pistream = pstreamfac->create_istream_cstring( string = xml ).
lp_dom     = g_ixml->create_document( ).
create the iXML parser:
parser = g_ixml->create_parser(
stream_factory = pstreamfac
istream        = pistream
document       = lp_dom ).
let the parser know which events I am interested in
event_sub = if_ixml_event=>co_event_element_pre2 +
            if_ixml_event=>co_event_element_post.
parser->set_event_subscription( events = event_sub ).
do.
  event = parser->parse_event( ).
  if event is initial.
    exit. ' either end reached or error (check below)
  endif.
  data: str type string.
  case event->get_type( ).
    when if_ixml_event~co_event_element_pre2.
      str = event->get_name( ).  write: '<' str '>'.
    when if_ixml_event~co_event_text_post.
      str = event->get_value( ). write: str.
  endcase.
enddo.
always check for errors:
if parser->num_errors( ) ne 0.
endif.
Regards,
Marc

Similar Messages

  • File to IDoc : XML parsing in ABAP mapping

    Hi,
    In ABAP mapping I want to parse all of the incoming XML strings to internal table.Later I add few more fields to this table and transfer them to IDOC adapter in IDOC-XML format.In thsi case how do i get all of the input file data(converted from XML) into internal table using XML parsing in ABAP Mapping?
    Thansk in advance,
    RP

    Hi Amil,
    I insert into table but not immediately,I want all the parsed xml data into internal table and do something before I insert into DB /send it to IDOC.
    I knwo how to get single Xml parsing,but how to get multple records(looping xml parse) to internal table?
    Thanks,
    RP
    Edited by: RP@261 on Jun 3, 2009 2:14 PM

  • Looking for some basics/fundamentals of XML Parsing in ABAP

    Hello SAP gurus
    I have to start workign on a project that involves Variant Configuration stuff that will be sent as XML document. I have to parse the XML document and save the needed data in some custom tables. I heard that there are some standard functions that we can use to do this job. I tried searching SDN for string XML parsing and got tons of postings regarding this. I tried to go through them one by one but it was way beyond my understanding at this time. I am looking for the fundamentals or how to start from scratch.
    I would appreciate if anybody can guide me to find some kind tutorial or basic info on where and how to start.
    Thanks a lot in advance
    Ram

    XML parsing through CALL TRANSFORMATION is one of the easiest method. A transformation needs to be created as per your XML data in transaction XSLT_TOOL and the transformation needs to be called in ABAP program using "CALL TRANSFORMATION" statement.
    Kindly search in internet for XSLT/simple transformations.

  • Problems with namespace XML Parsing of ABAP PI 7.0 Integration Engine

    Hi,
    I discovered the following problem.
    The customer sends a SOAP message with is forwarded through a SOAP Adapter in the integration engine.
    The structure of the message is very simple:
    <Envelope>
    <Body>
    <ORDERS05>...</ORDERS05>
    </Body>
    </Envelope>
    The customer adds the namespace information a special way:
    <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope">
    <Body>
    <orders05 xmlns="">...</orders05>
    </Body>
    <Envelope>
    Here the namespaces is declared in the first element. It should be inherited into all child elements. The 'orders05' should not have the namespace ' xmlns="http://schemas.xmlsoap.org/soap/envelope" ', therefore the namespace is overwritten with ' xmlns="" '. However I don't know if this is a correct xml statement, the SAP system did not understand this.
    The integration throws an error which is stated in the message in the adapter engine:
    2008-11-06 17:31:44 Fehler SOAPFault empfangen vom Integration Server. ErrorCode/Category: XIProtocol/ITEM_MISSING; Params: /@mustUnderstand, ST: ST_XMS_MSGHDR30_RM; AdditionalText: Attribut 'mustUnderstand' erwartet; ApplicationFaultMessage: ; ErrorStack: Das XML-Element /@mustUnderstand fehlt im SOAP-Message Header (SAP XI Extension) Attribut 'mustUnderstand' erwartet
    2008-11-06 17:31:44 Fehler Fehler beim Übertragen der Message zum Endpunkt http://kas052.hauni.koerber.de:8036/sap/xi/engine?type=entry über die Verbindung SOAP_http://sap.com/xi/XI/System. Grund: com.sap.aii.af.ra.ms.api.RecoverableException: Received HTTP response code 500 : Error during parsing of SOAP header
    If I changed the SOAP message to the common format, it is accepted by the integration engine.
    <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope">
    <SOAP:Body>
    <orders05>...</orders05>
    </SOAP:Body>
    </SOAP:Envelope>
    Here the namespace ' xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope" ' is defined with a prefix and assigned to the elements 'envelope' and 'body'. The 'orders05' element has no namespace.
    However due to the xml syntax both messages are the same, so why the integration engine handle the messages different?
    Best regards,
    Nils Kloth

    The valid SOAP format supported by XI is as follows
    <SOAP:Envelope
      xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP:Body>
        <m:MessageTypeName xmlns:m="Some-URI">
          <Price>34.5</Price>
        </m:MessageTypeName>
      </SOAP:Body>
    </SOAP:Envelope>
    Ur sender system is not sending the data in correct Soap format and thats the cause of message rejection. The option you have to use the Soap adapter in "no soap" mode.
    Regards,
    Prateek

  • There is a xml parser written in pl/sql

    Hi everybody,
    We know xml parser for pl/sql is based on xml parser for java, that is, we need the Jsever running. However, Jserver needs 60-80 MB of memory and initially we don't need Jserver, except for xml parsing. Then:
    There is a xml parser written in pure pl/sql ?.
    Thanks for your help!
    Jairo.

    PL/SQL is not sufficient to write for XML Parsing. The implementation is either in C or in Java.
    If you use Oracle9i, you can take use of XMLType for the C-based XML Parser.

  • J2me xml parser

    I need a tree based xml parser for my j2me application called tinyxml_tree.jar
    can anyone suggest where i can get hold of this. pls help

    Hello,
    I think this is the library you are looking for:
    http://kxml.sourceforge.net/
    You may download its sources and add them to your j2me project.
    Good luck.

  • Options for XML parsing in WAS 6.20 ABAP and higher

    Hello Experts,
       What options are available to me for working with XML documents in SAP R/3 4.7? I am working on SAP WAS 6.20 ABAP and was wondering which tools/techniques I can use for parsing XML files?
       I am developing an ABAP program and primarily need to be able to parse XML documents. I need to be able to traverse up and down their data structures (trees/nodes/elements/etc.).
       In SAP R/3 4.6 I used to use the iXML library but it seems that there are many advanced and powerful features included in SAP WAS 6.20 ABAP and up.
       Could someone please give me a summary of and their opinions on some these "newer" options?
    Thanks,
    - Vik.

    Hi Vik,
       There are two ways you can parse/interpret XML documents in ABAP -
       1. iXML - Which you have already used in 46 release. It wasn't easy to use set of functions but still it was possible to parse documents using iXML library. In WAS 6.20 you can now use class CL_XML_DOCUMENT which is much more easier to use than iXML library. It is bilt on top of iXML using the same DOM model.
      2. XSLT - Useing XSLT_TOOLS or XSLT transaction you can create XSLT programs to transform XML to ABAP data objects and then work with ABAP data objects. In this case you have the option of using some other tool like XMLSPY to write the XSLT and then copy that to SAP.
    From your post it looks like you will probably have to traverse the tree in unpridictable way, probably DOM based parsing using CL_XML_DOCUMENT is more suitable for you.
    Cheers,
    Sanjeev

  • XSD Validation with ABAP XML Parser?

    Hello there,
    i'm loading xml files into a R/3 System. This all works fine with the standard XML Parser.
    The XML Files are based on a .xsd structure that is assigned to each file with a external link.
    To be sure that the xml document conforms to this .xsd structure i would like to check against it.
    For that i would like to hold a .xsd structure string in my abap programm.
    How can this be accomplished? Is this possible anyway?
    Greetings and many thanks.
    Kay

    check out the class
    CL_XML_SCHEMA
    Regards
    Raja

  • Parsing XML Files to ABAP

    Hello All,
    There is a requirement for parsing of XML files to ABAP.
    1.How do we pick an XML file from Application server and also from FTP server?
    2.After picking the XML file how to parse that XML file to process it to create material master?

    Hi,
    Ur scenario is File to R/3
    For creating material master ..i guess there is IDoc named MATMAS.
    U can make use of it and execute File to IDoc Scenario.
    link for File to IDoc--
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/fileToIDOC&
    U need to pick XML file from FTP server...No need to parse XML file...just create data type which represents ur xml file structure and map it to IDoc fields.
    regards,
    Manisha

  • How to parse xml in sap abap

    Hello,
    Can anyone help me to know how to parse xml in sap abap.
    I have a xml file which i want to parse and store it in internal table.
    <?xml version="1.0" encoding="UTF-8"?>##<data><name>menaka<name></data>
    Regards,
    Menaka.H.B

    Hello,
    For how to get the node name, you have to refer to this :
    [https://wiki.sdn.sap.com/wiki/display/ABAP/Upload%20XML%20file%20to%20internal%20table|https://wiki.sdn.sap.com/wiki/display/ABAP/Upload%20XML%20file%20to%20internal%20table]
    Check the code after:
    WHEN if_ixml_node=>co_node_element
    It tells you how to get the node name.
    BR,
    Suhas

  • Mapping Error - XML Parser Exception

    We have a scenario where an ABAP Client Proxy sends a message to PI. This message is transformed into the mail package format and an email sent via the mail adapter.
    The Interface Mapping has 2 steps. The 1st step uses an XSL transformation to format the <Content> as html. This step also sets the <Subject>, <To> and <Content_Type> fields. The 2nd step uses a graphical message mapping to dynamically set the <From> field based on the sender system.
    We are experiencing the following intermittent error with this scenario:
    <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>
      <SAP:P1>com/sap/xi/tf/_EUK_MM_MailFrom_</SAP:P1>
      <SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>
      <SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3>
    This relates to the 2nd mapping step (graphical message mapping) described above.
    The message trace provides the following detail
    <Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: XMLParser: Entity 'lt' undefined(:main:, row:3, col:227) at com.sap.aii.mappingtool.tf3.Transformer.checkParserException
    This suggests that the XML produced by the XSL transformation is invalid.
    The strange thing is that it is very difficult to replicate the error as it doesn't always occur even with the same payload! If the message is restarted it processes successfully. Testing the interface mapping in the IR, with the same payload, works successfully.
    I would welcome any ideas you may have on this.
    Thanks
    Mark

    Hi Mark,
    thing i know now why it works at "restart".
    When the message comes first you get the character '&lt;' in your xml for example: '&<(0'
    and you get the ParserException.
    Now the message is stored for queueing in the db. I assume the characters are now stored in the 'right way': '&amp;amp;&amp;lt;(0'
    When the message now will be restarted everything works fine.
    Regards,
    Olaf

  • XML Parse error while loading an XML file

    HI Folks,
    I was trying to load and XML file into BODS.. The XML file is well-formed and the same when tested in other tools  is getting loaded without any issues..
    I have created a XML-File format with the corresponding XSD..
    But here in BODS it is giving - Parse error
    1) when i try to view the data of the source XML in my dataflow ..it is giving "XML Parser Failed".. and not able to show data..
    2) When I run my job i get the same pares error - with details as under..
    ---> Error here is "Unable to recognize element 'TAB' " or some time is say " Element TAB should be qualified"
    Please guide with this if you have any info..thanks
    I'm pasting the XML source file format here for your reference:--
      <?xml version="1.0" encoding="iso-8859-1" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
    - <TAB>
    - <items>
    + <CUSTOMER_RECORD>
      <CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
      <NAME_1>ABC</NAME_1>
      <NAME_2>OFM/COMMERCIAL ACCOUNTS</NAME_2>
      <STREET_1>31 CENTER DRIVE MCS2045</STREET_1>
      <STREET_2 />
      <CITY>BETHESDA</CITY>
      <STATE_CODE>MD</STATE_CODE>
      <POSTAL_CODE>20892-2045</POSTAL_CODE>
      <COUNTRY_CODE>US</COUNTRY_CODE>
      <ORDER_BLOCK />
      <ERP_CREATE_DATE>20040610</ERP_CREATE_DATE>
      <ERP_CREATED_BY>DGUPTA</ERP_CREATED_BY>
      <ERP_MODIFY_DATE>20120201</ERP_MODIFY_DATE>
      <ERP_MODIFIED_BY>LWOHLFEI</ERP_MODIFIED_BY>
      <INDUSTRY_CODE>0103</INDUSTRY_CODE>
      <ACCOUNT_GROUP_ID>0001</ACCOUNT_GROUP_ID>
      <SALES_NOTE />
      <ADDRESS_NOTE />
      <CUSTOMER_CLASSIFICATION_CODE>02</CUSTOMER_CLASSIFICATION_CODE>
      <GLN_NUMBER />
      <PREVIOUS_ACCT_NO />
      <ACCOUNT_TYPE />
      <GAG />
      <SDI_ID />
      <HOSP_ID />
      <HIN />
      <DUNS />
      <PO_BOX />
      <POB_CITY />
      <POB_ZIP />
      <PHONE_NUMBER>77777</PHONE_NUMBER>
      <EMAIL_DOMAIN />
      <REQUESTER />
      <ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
      </CUSTOMER_RECORD>
    - <SALES_ORG_DATA>
    + <item>
      <CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
      <SALES_ORG>0130</SALES_ORG>
      <CUSTOMER_GROUP>03</CUSTOMER_GROUP>
      <ORDER_BLOCK_CODE />
      <ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
      </item>
    + <item>
      <CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
      <SALES_ORG>0120</SALES_ORG>
      <CUSTOMER_GROUP>11</CUSTOMER_GROUP>
      <ORDER_BLOCK_CODE />
      <ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
      </item>
      </SALES_ORG_DATA>
      </items>
      </TAB>
      </asx:values>
      </asx:abap>

    Pierre,
    Depending on the object "myLastFile", the method openDlg might not even exist (if the myLastFile object is not a File object, for instance). And I do not see any need for the myLastFile anyhow, as you are presenting a dialog to select a file to open. I recommend using the global ChooseFile( ) method instead. This will give you a filename as string in full path notation, or null when no file was selected in the dialog. I am not sure what your ExtendScript documentation states about the return value for ChooseFile, but if that differs from what I am telling you here, the documentation is wrong. So, if you replace the first lines of your code with the following it should work:
    function openXMLFile ( ) {
        var filename = ChooseFile ( "Choose XML file ...", "", "*.xml", Constants.FV_ChooseSelect );
    While writing this, I see that Russ has already given you the same advice. Use the symbolic constant value I indicated to use the ChooseFile dialog to select a single file (it can also be used to select a directory or open a file - but you want to control the opening process yourself). Note that this method allows you to set a start directory for the dialog (second parameter). The ESTK autocompletion also gives you a fifth parameter "helplink" which is undocumented and can safely be ignored.
    Good luck
    Jang

  • XMl parser version problem for running struts project in jdeveloper 10.1.3

    Dear All.
    I am trying to run a struts (v 1.2.9) based project in Jdeveloper 10.1.3.1.0.The struts version in Jdeveloper is 1.1.
    when i am trying to run the index.jsp i get an error:
    org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation/dynamic
    I think the XML parser version is a problem.Jdeveloper has OracleXMLParser v2 and i think the XML Parser apis used in building the project is different.I have placedcustiom xml parser apis and the xerces.jar in the jdevbin/jdev/lib folder and included these jar in the bootclasspath as follows:
    AddVMOption -Xbootclasspath/p:../lib/xml-apis.jar
    AddVMOption -Xbootclasspath/p:../lib/xerces-2.6.2.jar
    But even then the Exception persists.Is the syntax for Xbootclasspath wrong or i need to place these custom api's in some other location of jdev.
    I am not being able to figure out the XMl parser problem.
    Any help wud be great.
    Is it that i cant run the project in jdeveloper.Just to mention the application is deployed in OC4J on the server and runs fine..But its only that i kant run it locally through jdeveloper

    I am also facing the same issue on my laptop. I searched for forum but no luck.
    appreciate if anybody can throw some light on this.

  • Read XML content in ABAP

    Hi Experts,
    I have a requirement, where I need to Parse the XML file after reading it from application server. Based on the data, I need to add some Tags to XML data.
    Can we achieve the solution in ABAP.
    Request your expertise.
    Thank you,
    Amit

    Hi Amit,
    Yes, you can achieve this in SAP either by creating a DOM representation of the XML document, or by the parser firing events as logical elements are encountered in a run through an XML document.
    Refer the following documents for more details.
    DOM-based method - Parsing an XML document DOM-based - Application Development on AS ABAP - SAP Library 
    Event Based - Parsing an XML document event-based - Application Development on AS ABAP - SAP Library 
    Refer this document for sample code - Parse an xml file and insert values in ABAP - ABAP Development - SCN Wiki
    Regards
    Anoop

  • XDK10g supports XML parsing for PL/SQL?

    Hi,
    I have a couple of questions here:
    1) Does XDK10g support XML parsing for PL/SQL? (More specifically, I need to use xmlDom and xmlParser)
    2) Does Oracle 10g come installed with XDK 10g? If not, does it even need to install XDK 10g to use xmlDom and xmlParser?
    Thank you all and have a nice day.
    Kelvin
    Edited by: user9518458 on Oct 30, 2008 1:31 AM

    Well, if you are talking 10.2, then
    "The (Java-based) Oracle XDK PL/SQL packages XMLDOM, XMLPARSER, and XSL_PROCESSOR have been deprecated in favor of the (C-based) Oracle XML DB packages DBMS_XMLDOM, DBMS_XMLPARSER, and DBMX_XSLPROCESSOR. Synonyms have been provided to smooth the migration of legacy applications" (http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/whatsnew.htm#CHDCAICE)
    Whether that is a default install option or one that requires selecting I can't say, but it is available without needing to additionally use the XDK. So odds are you can do whatever you need in PL/SQL using those DBMS_ packages (or XMLTYPE based variables if the need arises).

Maybe you are looking for

  • SRM 5.0 - Non-replication of Blocked Vendors from R/3 to EBP

    Hi Team, We are using SAP SRM 5.0 for e-procurement. Issue: The R/3 vendor is transferred to SRM for creation of bidder ID for e-procurement. Presently there is no check/warning message in the system while transferring blocked vendor from R/3 to SRM

  • Applecare ordered with computer....didn't receive it in delivery

    I just received my powerbook 15". I ordered a wireless mouse with it along with applecare. The powerbook arrived last friday. The wireless mouse and applecare product was shown in my emails to be shipped from a different location and shipped fed ex g

  • Are deleted files still in Time Machine?

    I use Time Machine with Time Capsule. If I delete a file on my Macbook, will all traces of it be removed from the TC or are they still archived? If they remain archived, is there a way (through Time Machine) to remove the file completely?

  • Getting the JScrollpane to be the correct size?

    I am having a problem with my scroll bars in the scroll pane. They are allowing me to scroll way more than I would like them to. I have added a screenshot of my problem here: http://www.minds.may.ie/~colly/problem.JPG I know that I could make the Scr

  • Can i request supporting my currency?

    Hi, i leave and work in Kazakhstan (KZ). Existing Creative Cloud member. I love BC's workflow and features. The only concern, i can't setup a proper currency (KZT) for my ecommerce website. Can someone please help? Thanks in advance. Alex.