XI java mapping using SAX

Hi,
im using java mapping for complex IDOC structure. If I run program localy, it works great, but when XI runs mapping, I have problems with xml file, some elements are not there ?! I don't know why it happens.....i said that i'm using complex logic, and therefore I'm using complex IF statments to produce segment in IDOC. I have noticed that there is a problem, because when I switch off IF, everything is fine???? any idea??
thx mario

Hi,
Do you have nested 'if' statements?  Is it possible you could be experiencing a "dangling else" problem?
http://www.dai-arc.polito.it/dai-arc/manual/tools/jcat/main/node101.html

Similar Messages

  • JAVA mapping using SAX parser adds extra tags

    Hi,
      We are using  java mapping using a SAX parser.It works well in standalone application ie it parses correctly and gets our desired xml structure and the xml is well formed too but when we import it in XI as a jar file it does not throw any errors but adds extra start tags, as a result the output xml is not well formed.XI is adding extra start tags.
    If any one else has faced a similar situation please help.
    Regards,
    Anirban.

    Hi Roberto,
    Thank you for the response.
    As I said, it doesnt throw any error. It is working perfectly in standalone application. But when we deploy it to XI Server, it is not forming the well formed XML. We too are puzzled by this situation.
    Okay, i will explain my scenario here.
    The following is my input XML to the java pgm..
    <Header>
    </Header>
    <Body>
    </Body>
    <SubBody1>
    </SubBody1>
    <SubBody2>
    </SubBody2>
    <SubBody3>
    </SubBody3>
    <SubBody4>
    </SubBody4>
    <Trail>
    </Trail>
    The desired output is
    <Header>
      <Body>
         <NameChanged1>
            <NameChanged2>
    <SubBody3>
    <SubBody4>
    </SubBody4>
    </SubBody3>
    </NameChanged2>
    </NameChanged1>
    <Trail>
    </Trail>
    Just look at the SubBody2 and SubBody1 node, its tag name has been changed in the output XML. Thats y i have decided to use java mapping instead of message mapping.
    I have developed the code for everything, i.e for changing the tag name and for forming the nested xml and it is working fine as a standalone application. But while deploying it to XI, the output is not well formed. I dont know the reason for it. Even I have checked the cardinality of the output Data types, that I have created. Its perfectly okay with all.
    Any Ideas???
    Regards,
    Anirban

  • JAVA Mapping with SAX: Illegal character exception &

    Hi everybody,
    I use a SAX JAVA Mapping. It throws an error cause the xml that is parsed has a
    &amp;
    like in
    <D_3036>Company &amp; Co. KG</D_3036>
    Does anybody know how to solve the problem?
    I do not want to replace the
    &amp;
    Are there special settings/properties for the handler/parser?
    Thanks
    Regards
    Mario

    Hi all,
    thanks for your comments and suggestions. The error was not cause by the problem I describes.
    FYI:
    If there is an ampersand in the middle of a string, than the standard method
    characters
    in the handler is called three times!
    This let me asume the ampersand was the error.
    Regards Mario
    Edited by: Mario Müller on Dec 19, 2008 1:23 AM

  • Java Mapping using DOM

    Hi All,
    I need Java mapping help. I will get incomming payload as following
    <orders>
    <matnr>123</matnr>
    <qty>10</qty>
    </orders>
    i need to change the above payload as follows
    <ns0:orders>
    <ns0:matnr>123</ns0:matnr>
    <ns0:qty>10</ns0:qty>
    </ns0:orders>
    Please help me how to achieve this using Java mapping.
    Regards
    Vijay

    Hi,
    Dom will be quite expensive for this type of requirement since you will have to go to each element and then append the namespace.
    I suggest you use SAX parser which is more  efficient for such requirement.
    The code is given below you can modify it according to your requirement.
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    public class SAXDemo extends DefaultHandler{
         public StringBuffer sb = new StringBuffer();
         public String PREFIX = "ns0:";
         int count = 1;
         public static void main(String[] args)
              SAXDemo demo= new SAXDemo();
              demo.saxdemo();
              System.out.println();
         public void saxdemo()
              InputStream in;
              try
                   in = new FileInputStream(new File("Input.xml"));
                   SAXParserFactory factory = SAXParserFactory.newInstance();
                   factory.setNamespaceAware(true);
                   factory.setValidating(false);
                   SAXParser saxParser = factory.newSAXParser();
                   * Parse the content of the given {@link java.io.InputStream}
                   * instance as XML using the specified
                   * {@link org.xml.sax.helpers.DefaultHandler}.
                   * @param inputstream InputStream containing the content to be parsed.
                   * @param cobject The SAX DefaultHandler to use.
                   * @exception IOException If any IO errors occur.
                   * @exception IllegalArgumentException If the given InputStream is null.
                   * @exception SAXException If the underlying parser throws a
                   * SAXException while parsing.               
                   saxParser.parse(in, this);
                   System.out.println(sb.toString());
              catch (FactoryConfigurationError e)
                   e.printStackTrace();
              catch (ParserConfigurationException e)
                   e.printStackTrace();
              catch (SAXException e)
                   e.printStackTrace();
              catch (IOException e)
                   e.printStackTrace();
         public void startDocument()throws SAXException
         public void endDocument()throws SAXException
         public void startElement(String namespaceURI, String name, String qName, Attributes attrs)
         throws SAXException
              if(count == 1)
                   sb.append("<"+PREFIX+qName+" "+PREFIX+"xmlns="+namespaceURI+">");
              else
                   sb.append("<"+name+">");
              count ++;
         public void endElement(String uri, String name, String qName) throws SAXException
              sb.append("</"+qName+">");
         public void characters(char buf[], int offset, int len)
         throws SAXException
              String s = new String(buf, offset, len);
              buf  = null;
              sb.append(s.trim());
                   s = null;
    Regards
    Fariha

  • Java Mapping Using DOM Parser.

    Hi Experts,
    I am new to Java mapping and i have followed the link
    http://scn.sap.com/thread/3173071 and it is working fine. It is for only one item. I have tried to modify the code and i placed a for loop to go create the Output Node based on the No of Input Nodes and it is giving the error as below. But my requirement is
    Input.xml : -
    <?xml version="1.0" encoding="UTF-8" ?>  
    <ns0:DT_Source xmlns:ns0="urn:java_mapping2"> 
    <Person1> 
          <Name>Alex</Name>  
          <Surname>Stewart</Surname>  
    </Person1>
    <Person1> 
          <Name>Sam</Name>  
          <Surname>Abdreson</Surname>  
    </Person1>  
    </ns0:DT_Source>
    Output.xml:-
    <?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    <ns0:DT_Target xmlns:ns0="urn:java_mapping2"> 
    <Person2> 
         <EmpName> 
              <Emp>Alex Stewart</Emp> 
    </EmpName> 
    </Person2>
    <Person2> 
         <EmpName> 
              <Emp>Sam Abdreson</Emp> 
    </EmpName> 
    </Person2>  
    </ns0:DT_Target> 
    I am unable to get the output. I am getting the following error.
    org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
    at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.insertBefore()
    at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild()
    Please suggest me how i can resolvoe this error.
    Regards,
    GIRIDHAR

    Complete code
    package test;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import java.io.IOException;
    import org.xml.sax.SAXException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    public class RemoveTag extends AbstractTransformation {
        public void execute(InputStream in,OutputStream out) throws StreamTransformationException, SAXException, IOException {  
            try
                 DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
                 DocumentBuilder builderel=factory.newDocumentBuilder();
                 /*input document in form of XML*/
                 Document docIn=builderel.parse(in);
                 /*document after parsing*/
                 Document docOut=builderel.newDocument();
                 TransformerFactory tf=TransformerFactory.newInstance();
                 Transformer transform=tf.newTransformer();
                 Element root,child,child1,child2;
                 Node textChild;
                 Node name,surname;
                 String fullname="";
                 root=docOut.createElement("ns0:DT_Target");
                 root.setAttribute("xmlns:ns0","urn:java_mapping2");
                 NodeList nList = docIn.getElementsByTagName("Person1");
                 for (int temp = 0; temp < nList.getLength(); temp++)
                child1=docOut.createElement("Person2");
                 child=docOut.createElement("EmpName");
                 child2=docOut.createElement("Emp");
                 child.appendChild(child2);
                 child1.appendChild(child);
                 root.appendChild(child1);
                 name=docIn.getElementsByTagName("Name").item(temp);
                 surname=docIn.getElementsByTagName("Surname").item(temp);
                 fullname=name.getFirstChild().getNodeValue()+" ";
                 fullname+=surname.getFirstChild().getNodeValue();
                 textChild=docOut.createTextNode(fullname);
                 child2.appendChild(textChild);
                 docOut.appendChild(root);  
                 transform.transform(new DOMSource(docOut), new StreamResult(out));
            catch(Exception e)
                 e.printStackTrace();
        public static void main(String[] args) {
            try{
                RemoveTag genFormat=new RemoveTag();
                 FileInputStream in=new FileInputStream("C:\\Users\\Desktop\\aa.xml");
                 FileOutputStream out=new FileOutputStream("C:\\Users\\Desktop\\output1.xml");
                 genFormat.execute(in,out);
            catch(Exception e)
                 e.printStackTrace();
    @Override
    public void transform(TransformationInput arg0, TransformationOutput arg1)
    throws StreamTransformationException {
    // TODO Auto-generated method stub
    try {
        this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

  • Java Mapping Using JAXB [Java Arch for XML Binding]

    Hi All,
    Anyone tried using JAXB  [Java Architecture for XML Binding API available with Java WebServices Pack] technique for XML processing in Java Mapping??
    I am facing the following problems..
    1. I am not able to generate namespace while marshalling target XML [In standalone mode and not tried in XI].
    2. What are the jar files we need to import?
       I tried importing the following jar files in XI.
    jaxb-api.jar,jaxb-impl.jar,jaxb-libs.jar,jax-qname.jar,namespace.jar,relaxngDatatype.jar
      and getting some errors while importing these files in XI.
    3. It throws error at runtime [Interface Mapping-Test Tab]
       like Resource not found:javax/xml/bind/Messages_en.properties,javax/xml/bind/Messages_en_US.properties
    4. Even after creating a copy of available file Messages.Properties with name: Messages_en.properties and Messages_en_US.properties.. it is not generating any messages in Target message tab
    Thanks in Advance,
    Ananth Chinnaraj

    Sravya ,
    I have searched wide and far for this, but no success.
    A lot on JAXB XI and Webdynpro, but nothing on JAXB, XI and mappings.
    Could you please post the url here ?
    Thanks and kind regards,
    Jan

  • Java Mapping - using Eclipse as IDE.

    Hello,
    We need to write a complex java mapping. We are currently planning to use Eclipse IDE for developing the mapping class. (we dont have the NW studio unfortunaltey). The user defined function option in the IR will not suffice.
    My question is - where do we get the com.sap.** libraries from - so that we can import those packages in our mapping code?
    Thanks.

    Hi,
      The necessary Jar files are downloaded & available in your PC when you use Integration Builder tools.
    Normally Java webstart caches these files in your local directory.
    You can find Java mapping related Jars in the following directory :
    C:Documents and Settings%USER%Application DataSunJavaDeploymentjavawscachehttp%HOST%P50000DMrepDMrepository
    Goto the directory, search for files like *aii_map_api.jar
    It will give you list of Jar files like RMaii_map_api.jar , just rename it as aii_map_api.jar and use it in Eclipse or NWDS.
    Note: While searching for Jar files take only Jar files with ~30KB size from the search results.
    regards,
    Ananth

  • Help Required in java mapping using XI

    Does any body worked on java Mapping in XI
    where do u find the com.sap.aii.*;
    thank's in advance
    swamy

    Hi,
    To access the mapping API, you must include the Jar file aii_map_api.jar in your class path. The Jar file is located in the following directory:
    <SAP_install_dir>/<system_name>/<instance_name>/j2ee/cluster/server<number>/apps/sap.com/com.sap.xi.services/
    To include the three J2EE standard libraries in the class path of the NetWeaver Developer Workplace, call the Set Additional Libraries... function in your Eclipse project by calling the context menu and selecting the libraries
    com.sap.tc.Logging,
    com.sap.mw.jco
    sapxmltoolkit.
    Hope this solves your problem.
    Regards,
    Siva Maranani.
    Message was edited by: siva  maranani

  • Reg XML generation from java objects using SAX 2.0

    i'm using java 1.6 and i've imported following class to generate XML from java objects
    import com.sun.org.apache.xml.internal.serialize.OutputFormat;
    import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
    the following class has been imple her to create a Xml file and tag elements ,
    OutputFormat of = new OutputFormat("XML", "iso-8859-1", true);
    XMLSerializer serializer = new XMLSerializer(fos, of);
    ContentHandler hd = serializer.asContentHandler();
    hd.startDocument();
    everything works fine but i'm getting warrnin reg the serializer and outputformat
    warring is:
    com.sun.org.apache.xml.internal.serialize.OutputFormat is Sun proprietary API and may be removed in a future release
    com.sun.org.apache.xml.internal.serialize.OutputFormat is Sun proprietary API and may be removed in a future release
    HOW CAN I AVOID DS WARRING PLZ HELP REG DS
    thanks ,
    with regards,
    Rajesh.S

    I've been having the same problem. Here is what i found:
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6476630]
    Hope that helps (or at least helps you feel better).

  • Functions used in Java mapping

    hi
    If anybody has worked on Java mapping, Can anybody tell me the common functions that are used in Java mapping along with some examples
    Also how java mapping is more useful as compared to XSLT and ABAP mapping, when to use java mapping and some demo example on java mapping if available
    Thanks & regards,
    Loveena.

    Hi Loveena
    refer these Blogs for Step-via step for java mapping
    /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    <b>Java Mapping (Part I)</b>
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/javaMappingusingDOMParser&
    /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/binary%2bconversion%2bin%2bxi%2b-%2bjava%2bmapping
    JAVA Mapping :If you have complex mapping in your scenarios and also some times if you have more than 100 field to map then better to choose the JAVA MApping
    Java Mapping uses 2 types of parsers. DOM and SAX. DOM is easier to use with lots of classes to help you create nodes and elements, but, DOM is very processor intensive.
    SAX parser is something that parses your XML one after the other, and so is not processor intensive. But, it is not exactly easy to develop either.
    DOM and SAX are APIs
    In NWDS we have to develop the mapping and create jar and archieve and import it under Iported archieved in IR. this can be used in Interface mapping.
    See the below links so that you can have screen shots,...
    Java Mapping
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    Re: java ,abap and XSLT mapping
    Re: java ,abap and XSLT mapping
    Re: When to Use XSLT,Java or Graphical Mapping
    mapping
    Testing and Debugging Java Mapping -/people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    Thanks !!
    Regards
    Abhishek Agrahari

  • File to JDBC using JAVA Mapping

    Hello,
      Can u explain me about the above scenario of File to JDBC using JAVA Mapping.
       Iam new to XI explain above in detail.
    *Points will be Rewarded*
    Thanks&Regards,
    RavichandKone.

    HI,
    If your mapping is one to one then dont go for java mapping use graphical mapping.
    /people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30 --> for jdbc receiver: file -JDBC
    Here are the link which will help you in writing the stored procedure:
    Receiver JDBC scenario MS access - /people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn
    Stored Procedures-
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    http://www.ics.com/support/docs/dx/1.5/tut6.html
    /people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
    http://www.ics.com/support/docs/dx/1.5/tut6.html
    http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html
    http://www.sqlteam.com/article/stored-procedures-an-overview
    thnx
    Chirag Gohil

  • Graphical Mapping Vs XSLT mapping Vs Java Mapping Vs ABAP Mapping

    Hi Experts,
              I have a question regarding different message mapping options available in XI namely
    Graphical Mapping
    XSLT mapping
    Java Mapping
    ABAP Mapping
    Q1: Which amoung the above mappings is the best and why?
    Q2: On what cases Graphical, XSLT, Java and ABAP Mapping should be used?
    Q3: Is it true that graphical and XSLT mappings are converted into Java class internally?
    Kindly help!
    Thanks
    Gopal
    Message was edited by:
            gopalkrishna baliga

    Hi,
    There is no hard and fast rule for using the mapping techniques.
    Graphical Mapping is used for simple mapping cases. When, the logic for your mapping is simple and straight forward and it does not involve mult hiearchical mapping requirement. and context handling.
    Java and XSLT mapping are used when graphical mapping cannot help you.
    When the choice is between Java And XSLT, XSLT is simpler than java mapping and easier. But, it has its drawbacks.  XSLT can lead to a bad perfrormance if the Source XML is huge.
    Java Mapping uses 2 types of parsers. DOM and SAX. DOM is easier to use with lots of classes to help you create nodes and elements, but , DOM is very processor intensive.
    SAX parser is something that parses your XML one after the other, and so is not processor intensive. But, it is not exaclty easy to develop either.
    For further info on each of the mapping, refer to these links,
    Graphical Mapping,
    http://help.sap.com/saphelp_nw04/helpdata/en/6d/aadd3e6ecb1f39e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    XSLT Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm
    http://www.w3.org/TR/xslt20/
    Java Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
    DOM parser API
    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html
    Also, check this thread for more info,
    Different types of Mapping in XI
    Am not sure about XSLT , but , yes graphical mapping is converted into java classes internally and these classes use SAX parsing as well.
    Regards,
    Bhavesh

  • Java Mapping, XSLT Mapping, ABAP Mapping

    Hi Experts,
                     Could any one explain what is the main features of the following Mapping. How to pick the mapping?
    Java Mapping - When to use and what is the advantage.
    ABAP Mapping - When to use and what is the advantage.
    XSLT Mapping - When to use and what is the advantage.
    Graphical Mapping - When to use and what is the advantage.
    cheers,
    Sunee

    There are 4 types of mapping in XI
    1. Graphical Mapping
    2. XSLT Mapping
    3. JAVA Mapping
    4. ABAP Mapping
    When to use Message mapping
    1 When the logic for your mapping is simple and straight forward, you can use
    Advantages of message mapping
    1)Easy to use.
    2) has GUI drag and drop.
    3) used for simple mapping cases
    4) it does not involve any complex logic
    Disadvantages of message mapping
    1)has limitation in terms of complex hierarchy
    When to use Java mapping
    1) Java mapping are used when graphical mapping cannot help you.
    Advantages of Java Mapping
    1)you can use Java APIs and Classes in it.
    2) file look up or a DB lookup is possible
    3) DOM is easier to use with lots of classes to help you create nodes and elements.
    Disadvantages of Java mapping
    1)SAX parser is not easy to develop
    2)DOM parser is intensive
    3) Java knowledge is required
    4) bit complexer
    XSLT Mapping - When to use
    1)When the required output is other than XML like Text, Html or XHTML (html displayed as XML )
    2)When default namespace coming from graphical mapping is not required or is to be changed as per requirements.
    3)When data is to be filtered based on certain fields (considering File as source)
    4)When data is to be sorted based on certain field (considering File as source)
    5)When data is to be grouped based on certain field (considering File as source)
    Advantages of using XSLT mapping
    1)XSLT program itself defines its own target structure.
    2)XSLT programs can be imported into SAP XI. Message mapping step can be avoided. One can directly go for interface mapping once message interfaces are created and mapping is imported.
    3)XSLT provides use of number of standard XPath functions that can replaces graphical mapping involving user defined java functions easily.
    4)File content conversion at receiver side can be avoided in case of text or html output.
    5)Multiple occurrences of node within tree (source XML) can be handled easily.
    6)XSLT can be used in combination with graphical mapping.
    7)Multi-mapping is also possible using xslt.
    8)XSLT can be used with ABAP and JAVA Extensions
    Disadvantages of using XSLT mapping
    1)Resultant XML payload can not be viewed in SXMB_MONI if not in XML format (for service packs < SP14).
    2)Interface mapping testing does not show proper error description. So errors in XSLT programs are difficult to trace in XI but can be easily identified outside XI using browser.
    3)XSLT mapping requires more memory than mapping classes generated in Java.
    4)XSLT program become lengthier as source structure fields grows in numbers.
    5)XSLT program sometimes become complex to meet desired functionality.
    6)Some XSL functions are dependent on version of browser.
    Advantages of Abap Mapping
    1) A person comfortable with OOABAP can go for ABAP mapping instead.
    Disadvantages of Abap Mapping
    1) Abap knowledge is required
    2) bit compexer
    For further info on each of the mapping, refer to these links,
    Graphical Mapping,
    http://help.sap.com/saphelp_nw04/helpdata/en/6d/aadd3e6ecb1f39e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    XSLT Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm
    http://www.w3.org/TR/xslt20/
    Java Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
    DOM parser API
    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html
    Check this blog on Mapping:
    /people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
    Also, check this thread for more info,
    Different types of Mapping in XI

  • XI AF API call failed. Module exception: Java Mapping

    Hi Experts,
    I have faced a typical error for one of my interface. The Scenario is SOAP to SOAP and we are performing SOAP Lookup  before sending the data to Target web service. We are using one Java Mapping  'FileIns_lookupLoad.java --- com/fi/' and performing the SOAP Lookup from within the code. In the Lookup Communication channel we are using 'Axis' as message protocol and passing couple of values through Module Key parameters. We have same ESR and ID objects in Development, Quality and Production (as per Version ID and History).
    Now the problem is Lookup is failing only in Development but Quality and Production is working fine. I have replaced Quality CC URL with the development WSDL URL, but that worked fine. That means Development Web Service is good. We are getting the below error in Dev:
    <SAP:Stack>StreamTransformationException triggered by application mapping program com/fi/FileIns_lookupLoad; Look Up Failed</SAP:Stack>
    Trace : *
    <Trace level="1"
    type="T"> Some Thing Wrong in LookUpError when calling an adapter by using the communication channel CC_IN_SOAP_GEInsuranceLoadLookup1 (Party: , Service: BusService_GE, Object ID: 4214805c52893ef9b0b3f0ef0902fe9e) XI AF API call failed. Module exception: 'while trying to invoke the method org.apache.axis.types.URI.toString() of an object returned from com.sap.xi.XI.Message._30.QualifiedName.getNamespace()'. Cause Exception: 'while trying to invoke the method org.apache.axis.types.URI.toString() of an object returned from com.sap.xi.XI.Message._30.QualifiedName.getNamespace()'. </Trace>
      <Trace level="1" type="T">*** END APPLICATION TRACE ***</Trace>
      <Trace level="1" type="T">Java mapping com/fi/FileIns_lookupLoad has thrown a StreamTransformationException. Thrown: com.sap.aii.mapping.api.StreamTransformationException: Look Up Failed at com.fi.FileIns_lookupLoad.execute(FileIns_lookupLoad.java:282) at com.fi.FileIns_lookupLoad.transform(FileIns_lookupLoad.java:74) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:92) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep.................................................
    ................................................................................<Trace level="1" type="T">Application mapping program com/fi/FileIns_lookupLoad throws a stream transformation exception: Look Up Failed Thrown: com.sap.aii.ib.core.mapping.execution.ApplicationException: Application mapping program com/fi/FileIns_lookupLoad throws a stream transformation exception: Look Up Failed at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:95) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep(SequenceMapping.java:40) at com.sap.aii.ib.server.mapping.execution.Mapping.execute
    I have already checked with Basis and as per them JDK and Java versions are identical in Dev, QAS and Prod. It seems something is wrong with 'XI AF API' which we are calling from the channel. If we totally ignore Lookup process and send direct data, it is working fine. Target CC is also using Axis.
    Sequence in CC: afreq ->xireq ->wssec2 ->xires ->afres
    For any more information please let me know.
    Thanks,
    Nabendu.

    Hi Anupam,
    The Java Mapping code is same in Dev , QAS and Prod. Also the versions of the JAR is same.
    Please find the code below.
    package com.fi;
    import java.util.HashMap;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.MappingTrace;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.DynamicConfigurationKey;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.*;
    import org.w3c.dom.views.AbstractView;
    import org.xml.sax.SAXException;
    import java.io.ByteArrayInputStream;
    import com.sap.aii.mapping.lookup.*;
    /*import com.sap.aii.utilxi.hmis.server.HmisEnvironment.Accessor;
    //import com.sap.aii.utilxi.lock.api.LockServiceException;
    //import com.pmintl.pppimes.RFCLookup.javamapping.*;
    //import java.io.FileInputStream;
    //import java.io.FileOutputStream;*/
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    //import java.text.ParseException;
    import java.util.Date;
    import java.io.*;
    public class FileIns_lookupLoad extends AbstractTransformation{
            private Map param = null;
            private AbstractTrace trace = getTrace();
            String senderService = null;
           String inParamChannel = null;
           String inParamBusService = null;
              //3. Each JAVA Mapping using program 7.1 API must implement the method
              // transform(TransformationInput in, TransformationOutput out)
              // as oppose to execute Method in earlier version.
               public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {
              // TODO Auto-generated method stub
              //4. An info message is added to trace. An instance of trace of object is obtained by calling
              // the getTrace method of class AbstractTransformation
                    inParamChannel = arg0.getInputParameters().getString("COMM_CHANNEL");
                    inParamBusService = arg0.getInputParameters().getString("BUS_SERVICE");
                    getTrace().addInfo("Input Parameter: " + inParamChannel);
                    getTrace().addInfo("Input Parameter: " + inParamBusService);
                    this.execute(arg0.getInputPayload().getInputStream(),
                          arg1.getOutputPayload().getOutputStream());
              //5. Input payload is obtained by using arg0.getInputPayload().getInputStream()
          * @param args
         public static void main(String[] args) {
                // TODO Auto-generated method stub
         public void execute(InputStream in, OutputStream out)
                   throws StreamTransformationException {
              // TODO Auto-generated method stub
              try
                   //Get The Trace
    //               trace = (AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE );
                   trace = getTrace();
                  getTrace().addInfo("Java Mapping Started");
                   DocumentBuilderFactory ifactory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder ibuilder = ifactory.newDocumentBuilder();
                   Document IDoc  = ibuilder.parse(in);
                   Document TDoc = ibuilder.newDocument();
                   String mrnVal = "";
                   trace.addInfo("Preparing Target Doc");
                   Element message = TDoc.createElementNS("urn:Medtronic.com:CATS_Patient_Transactions","n1:Mt_Insurance");
                   Node tRoot = TDoc.appendChild(message);
                   //trace.addInfo(tRoot.getNodeName());
                   Element sRoot = (Element)IDoc.getFirstChild();
                   //trace.addInfo(sRoot.getNodeName());
                   NodeList nl = sRoot.getChildNodes();
               // trace.addInfo("Len"+nl.getLength());
    ////               for(int i=0;i<nl.getLength();i++)
    //                    Node n1 = TDoc.importNode(nl.item(i), true);
    //                    trace.addInfo("Adding Child Nodes");
    //                    trace.addInfo(nl.item(i).getNodeName());
    //                    tRoot.appendChild(n1);
                   NodeList lmrn = sRoot.getElementsByTagName("Mrn");
                   if(lmrn != null)
                        Node n1 = TDoc.importNode(lmrn.item(0), true);
                        Element e1 = (Element)lmrn.item(0);
                        //trace.addInfo(e1.getNodeName());
                        mrnVal = e1.getTextContent();
                        tRoot.appendChild(n1);
                   NodeList lfsc = sRoot.getElementsByTagName("Fsc");
                   if(lfsc != null)
                        for(int i=0;i<lfsc.getLength();i++){
                             Element n1=TDoc.createElement(lfsc.item(i).getNodeName());
                             tRoot.appendChild(n1);
                             Node fieldch = TDoc.createElement("Fields");
                             n1.appendChild(fieldch);
                             NodeList chl = lfsc.item(i).getChildNodes();
                             trace.addInfo("len11"+chl.getLength());
                             for(int j=0;j<chl.getLength();j++){
                                  if(!chl.item(j).getNodeName().equals("FscNumber")&&!chl.item(j).getNodeName().equals("Priority")){
                                       if(chl.item(j).hasChildNodes()){
                                            trace.addInfo(chl.item(j).getNodeName());
                                       Element fscfield = TDoc.createElement("FSCField");
                                       fieldch.appendChild(fscfield);
                                       NodeList FUQl = chl.item(j).getChildNodes();
                                       for(int p =0;p<FUQl.getLength();p++){
                                            //trace.addInfo(" i: "+i+" J: "+j+" P: "+p);
                                            if(FUQl.item(p).getNodeName().equals("FUQNumber")){
                                                 //Node tFUQ = TDoc.createElement("FUQNumber");
                                                 //tFUQ.setTextContent(FUQl.item(p).getTextContent());
                                                 fscfield.setAttribute("FUQNumber", FUQl.item(p).getTextContent());
                                            if(FUQl.item(p).getNodeName().equals("Value")){
                                                 Node tVal = TDoc.createElement("Value");
                                                 tVal.setTextContent(FUQl.item(p).getTextContent());
                                                 fscfield.appendChild(tVal);
                                                 //Node tName = TDoc.createElement("Field");
                                                 //tName.setTextContent(chl.item(j).getNodeName());
                                                 fscfield.setAttribute("Field", chl.item(j).getNodeName());
    //                                   Node fuqch = chl.item(j).getFirstChild();
    //                                   Node valch = fuqch.getNextSibling();
    //                                   if(fuqch!=null){
    //                                        Node tFUQ = TDoc.createElement("FUQNumber");
    //                                        tFUQ.setTextContent(fuqch.getTextContent());
    //                                        fscfield.appendChild(tFUQ);
    //                                   if(valch!=null){
    //                                        Node tVal = TDoc.createElement("Value");
    //                                        tVal.setTextContent(valch.getTextContent());
    //                                        fscfield.appendChild(tVal);
    //                                        Node tName = TDoc.createElement("Filed");
    //                                        tName.setTextContent(chl.item(j).getNodeName());
    //                                        fscfield.appendChild(tName);
                                  else{
                                       //Node numch =TDoc.importNode(chl.item(j), true);
                                       //Element e1 =(Element)n1;
                                       if(chl.item(j).getNodeName().equals("FscNumber")){
                                            n1.setAttribute("Number", chl.item(j).getTextContent());
                                       if(chl.item(j).getNodeName().equals("Priority")){
                                            n1.setAttribute("Priority", chl.item(j).getTextContent());
                             //tRoot.appendChild(lfsc.item(0));
    //                         Element e1 = (Element)lfsc.item(0);
    //                         trace.addInfo(e1.getNodeName());
    //                         mrnVal = e1.getNodeValue();
    /////Start of Look Up Code////
                   //Preparing Input String
                   String lookUpRequest = "<LoadPatientFullInsuranceDetail><Mrn>"+mrnVal+"</Mrn></LoadPatientFullInsuranceDetail>";
                   trace.addInfo("Request");
                   trace.addInfo(lookUpRequest);
                        SystemAccessor acc;
                        Channel channel;
                        Payload lookupResult;     
                        try
                             channel = LookupService.getChannel(inParamBusService, inParamChannel);
                             trace.addInfo("Got the channel");
                             acc = LookupService.getSystemAccessor(channel);
                             trace.addInfo("Got The Channel and Accessor");
                             InputStream ist = new ByteArrayInputStream(lookUpRequest.getBytes());
                             XmlPayload payload = LookupService.getXmlPayload(ist);
                             if(acc != null){
                                  trace.addInfo("Got The Channel and Accessor");
                                  trace.addInfo("Executing The Webservice");
                                  lookupResult = acc.call(payload);
                                  trace.addInfo("End of Executing The Webservice");
                                  trace.addInfo(lookupResult.toString());
                             if(lookUpRequest!=null){
                                  trace.addInfo("Responce is not null");
                                  InputStream rist = lookupResult.getContent();
                                  Document lresDoc = ibuilder.parse(rist);
                                  Node n1 = lresDoc.getFirstChild();
                                  trace.addInfo(n1.getNodeName());
                                  if(n1.getNodeName().endsWith("LoadPatientFullInsuranceDetailResponse"))
                                       Node ch1 = n1.getFirstChild();
                                       trace.addInfo(ch1.getNodeName());
                                       NodeList lookupnl = ch1.getChildNodes();
                                       //trace.add
                                       for(int i=0;i<lookupnl.getLength();i++)
                                            Node n2 = TDoc.importNode(lookupnl.item(i), true);
                                            trace.addInfo("Adding Child Nodes");
                                            trace.addInfo(lookupnl.item(i).getNodeName());
                                            tRoot.appendChild(n2);
                                  else{
                                  throw new StreamTransformationException("Error in Look Up"+n1.getTextContent());
                                   //while(ch1.hasChildNodes() && !ch1.getNodeName().equals("FSCS")){
                             else{
                                  trace.addWarning("Responce is null");
                                 throw new LookupException();
                        catch(LookupException le)
                             trace.addWarning("Some Thing Wrong in LookUp"+le.getMessage());
                             throw new StreamTransformationException("Look Up Failed");                         
                           Transformer transformer = TransformerFactory.newInstance().newTransformer();
    //                       StreamResult reqResult = new StreamResult(new StringWriter());
                           DOMSource source = new DOMSource(TDoc);
                           Result result = new StreamResult(out);
                           transformer.transform(source,result);
              catch(StreamTransformationException ste)
               throw new StreamTransformationException(ste.getMessage());
              catch(Exception e){
                   trace.addInfo(e.getMessage());
              finally{

  • New to JAVA mapping

    Hi All,
    I have been working in PI for sometime now. But i have never done JAVA mapping or writing modules in PI. Now i am in need of working on either of these. I have no idea on the topics mentioned above. I tried searching for docs and links on these and was successful in finding only example scenarios, which was not very clear.
    Can anyone give me details on these for a beginner please? I mean how to start with JAVA mapping and basics in it.
    Regards,
    Lavanya R

    Hi Lavanya,
    There are multiple blogs for Java Mapping,you can start following those links:
    Easy way to learn - Java Mapping using DOM - SAP PI 7.1+
    Beginners guide to Java mapping using DOM parser in SAP XI - Process Integration - SCN Wiki
    **************** - Understanding Java Mapping concepts
    You must be aware of the XML parsing techniques such as DOM and SAX parser.You may at first start parsing through JAVA program (if you are not that fluent in parsing)and then gradually try to implement into PI.You may find multiple documents for developing parsing program in JAVA tutorial sites like :
    Reading XML Data into a DOM (The Java&amp;trade; Tutorials &amp;gt; Java API for XML Processing (JAXP…
    Parsing an XML File Using SAX (The Java&amp;trade; Tutorials &amp;gt; Java API for XML Processing (JA…
    Regards,
    Suman

Maybe you are looking for

  • Numbers (Mac OS and iOS)

    I am a long time Windows/Office user who has moved to the Apple environment (Mac/iPhoneiPad) over the past couple of years.  I've also moved all of my family and have seen a lot of work colleagues make a similar moves, largely on the back of adoption

  • No Rate. Foreign currency invoice does not have an exchange rate assigned to it.

    Hi, working in oracle applications 11i. We have encountered the above issue in an invoice. I have run autorate request and I can see that the invoice and all its distribution lines has the exchange  rate. but when we submit it for validation it shows

  • Suffering an complie error when trying to compile java class in EBS11i

    Hi, When I trying to compile java classes with which imported the HttpServletResponse class, will get the follow error message: package javax.servlet does not exist cannot resolve symbol symbol : class HttpServletResponse It seems the javax.servlet p

  • Lightroom 1.3 creates CameraRaw Cache

    I import raw files to an external hard drive on a Win XP system. After installing 1.3, I have a new folder C:\Documents and Settings\my name\Local Settings\Application Data\Adobe\CameraRaw\Cache. A Cache ###.dat file about the same size as the origin

  • Error writing input to command  11GR2

    Hi My daily backup job is stuck in a running state on the step; Backup with the error mentioned in the title. No matter what I do in terms of trying to stop, suspend or delete the run of this job nothing seems to clear the step so I can resechedule t