Regarding java mapping failure

Hai all
  Iam Ajay , here i would like to create XML Tree using DOM Parser. In the java Program i need to import
"com.sap.aii.mapping.*" library. Unfortunately i don't have that. could you suggest me where do i import the jar file which includes the above java library .
Thank you

HI,
The jar files required for java mapping is aii_map_api.jar
You can find this in your your XI server in the following path:
<b>j2ee\cluster\server0\apps\sap.com\com.sap.xi.services</b>
/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions (Mappings->Question No 5)
Regards,
Moorthy

Similar Messages

  • Regarding java mapping in SAP XI

    Hi Friends,
                    I need help on java mapping.In java mapping in design side in the receivermessage interface by right clicking on and selecting java proxy generation. here i have a doubt ,we have to select both sender and receiver interfaces are not.please send me any info regarding This issue.

    Hi Vuday,
    Java Proxy
    /people/prasad.ulagappan2/blog/2005/06/27/asynchronous-inbound-java-proxy
    /people/siva.maranani/blog/2005/04/03/abap-server-proxies
    http://sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a068cf2f-0401-0010-2aa9-f5ae4b2096f9
    https://sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d
    Thanks,
    Satya Kumar

  • Regarding Java Mapping

    Hi,
    I am new to java mapping. I just want to know what files I have to upload in IMPORTED ARCHIVES in Integration Repository to run the mapping properly.
    Thanks In Advance.
    Yaseen.

    Yaseen,
    If you are calling some class that is no a part of the standard jdk, then you need to have those classes / packages available under imported archives.
    <i>I dont think so when I upload only class file, it says class not found.</i>
    Compile your JAVA Mapping code , create the class file and then import that clas file under Imported Archives and use the same for  mapping program in interface mapping.
    Like i mentioned, if you are using some class in the Java Mapping that is not a part of stanadrad jdk, then you need import those Packages also.
    Regards,
    Bhavesh

  • Regarding Java mapping and ABAP Mapping

    Hello,
         If I suppose to do Java mapping or ABAP mapping, Is there any pre requisite to perform these two mappings?
    If exist what they are?
    How to perform them?
    Thank you

    Hello jyotsna,
    Java mapping can be used when you have complex mapping structures.
    We can do most of the times for our requirements through Graphical mapping.
    When the structures are very complex to build you can go for SAX (Simple API for XML) or DOM (Document Object Model) parsers.
    Message mapping internally generates DOM parser.
    Java Mapping in XI
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=java+mapping&adv=false&sortby=cm_rnd_rankvalue#
    SAP Network Blog: Implementing a Java Mapping in SAP PI
    /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
    Java Mapping (SAP Library - Partner Connectivity Kit)
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    SAP Network Blog: XI Java Mapping Helper (DOM)
    /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    SAP Network Blog: Testing and Debugging Java Mapping
    /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    Binary Conversion in XI - Java Mapping - Code Gallery - Wiki
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/binary%2bconversion%2bin%2bxi%2b-%2bjava%2bmapping
    SAP Network Blog: "JAVA MAPPING", an alternate way of reading a CSV file
    /people/rahul.nawale2/blog/2006/07/18/java-mapping-an-alternate-way-of-reading-a-csv-file
    ABAP mappings run on ABAP Stack and are developed in the ABAP workbench of the Integration Server.
    You normally do not need to use the ABAP mappings and is preferable for someone with ABAP programming background. I should say JAVA functions would suffice any complex scenarios.
    refer step by step guides for ABAP Mapping
    ABAP Mapping
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=abap+mapping&adv=false&sortby=cm_rnd_rankvalue#
    How to Use ABAP Mapping in Exchange Infrastructure 3.0 (NW2004)
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5c46ab90-0201-0010-42bd-9d0302591383
    SAP Network Blog: Testing ABAP Mapping
    /people/sameer.shadab/blog/2005/09/29/testing-abap-mapping
    SAP Network Blog: How to call XI ABAP Mapping via RFC
    /people/ricardoandres.maienza/blog/2007/04/06/how-to-call-xi-abap-mapping-via-rfc
    SAP Network Blog: XI: ABAP mapping logs - more standard = better visibility
    /people/michal.krawczyk2/blog/2006/09/20/xi-abap-mapping-logs--more-standard-better-visibility
    SAP Network Blog: Dynamically sending a mail to the PO creator using XSLT- ABAP Mapping
    /people/rahul.nawale2/blog/2006/11/01/dynamically-sending-a-mail-to-the-po-creator-using-xslt-abap-mapping
    You need to provide the name of your mapping program maually , you see it is an input box.
    just provide the name of abap mapping program it will work.
    and one more thing you cannot test abap mapping program in integration builer you need to test in abap only.
    use tcode: SXI_MAPPING_TEST for testing abap mapping
    Thanks,
    Satya
    Reward points if it is useful..

  • Regarding Java mapping Interface

    Hello,
    while implementing the java mapping, we need to develop the interface called
    com.sap.aii.mapping.api.streamTransformation
    So here what is " aii "
    how can we develop this interface.
    Thank you

    Hi Ravi,
    com.sap.aii.mapping.api.StreamTransformation is a class contained in the archive aii_map_api.jar so in your java project you need aii_map_api.jar to be able to use class StreamTransformation.
    There is no specific meaning for "aii"
    For more details about StreamTransformation, you have this:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/bd/c91241c738f423e10000000a155106/frameset.htm
    The package com.sap.aii.mapping.api.StreamTransformation can be obtained from SAP service Market place.
    Thanks
    Swarup

  • Configuration in Java Mapping.

    Hi Folks, Here I am in real Need of Some inputs regarding JAVA Mapping. Actually I am working on the Change of a scenario. I just Added some fields to the interface. I added these fields on the Sender structure and the receiver structure.
            I did mapping also for the added fields. Till XI part its working fine. The problem is When I see the Interface mapping they are using the Java Class Mapping as well with the message mapping.
            I am very new to JAVA. I dont know even A..B..C..D of JAVA. That is the reason I am waiting for some to help from our Community.
            Here are some inputs regarding the JAVA mapping. I did some research and find out that they are using the JAVA Mapping for XML Validation. So I came to know that we dont need to change the JAVA files. Java file just reads the Incoming structure and writes to the receiver. Inside the JAVA mapping it  is using the XSD file to capture the incoming structure. 
            Here is the problem, when I double clik on the java mapping,  it is heading to the Imported archives in which we are having .java, .class, .XSD files already imported with some path information. when I just check the code by double clicking the XSD structure it is showing the old XSD. it is not updated with the added fields. So when ever I am testing the Interface its throughing an exception.
            Can any body please help me out in this matter.
             As i am not going to change the JAVA files, Do I need to install the J2SDK in my local Machine.
            What ever the path is showing in the imported archives, will that be in the XI server or again in our local machine. Do we need to create the folders to save any files on our local machines.
            I am in need to change the XSD file in the path. where I need to change the XSD.
            can any body please gimme the clear process regarding java part which I need to follow to complete my development. even though i completed 80% of my development I am struggling with this config from past 4 days. Please help me out. Looking for the positive responses.
         Thanks,
    Ramana Avula.

    Hi do one thing
    Export the whole imported archive for e.g let the name be ABC.
    When you click on ABC you find .java .class & XSD file.
    export the archive with a .jar extension
    for e.g ABC.jar
    Now open this jar file with winzip.
    you will see the three files i.e. .class .java & XSD
    Now using winzip just replace the old  XSD  with new
    The name should be same.
    Take care if the XSD file is not present inside any folder
    if so then replace it inside that directory only and not outside any folder
    for e.g. /com/company/ folder have your .java & class file
    but /com/company/xsd/abc.xsd is your xsd file
    so replace it in appropriate folder only
    And then reimport it back in the same archive
    Edited by: Progirl Progirl on Dec 4, 2008 4:39 PM
    Edited by: Progirl Progirl on Dec 4, 2008 4:42 PM

  • Re-use message mapping from within java mapping?

    Hi there,                                                                               
    I have a question regarding java mapping. What I would like to do is to re-use an existing message mapping from within java mapping.
    Technicaly, message mapping is perfomed by com.sap.aii.mappingtool.tf3.AMappingProgram.execute, right? I would like to call that mapping program for a specifc message mapping from within my java mapping.
    Pseudo java code would look like this:
    public void execute(InputStream in, OutputStream out)
      throws StreamTransformationException {
    com.sap.aii.mappingtool.tf3.AMappingProgram.execute(in,out,'SomeMessageMapping');
    SomeMessageMapping is a message mapping that is defined in the integration repository.
    Is it possible? If so, could you provide me with some details?
    Thank you and best regards,
    Wolfgang

    Hi Wolfgang,
    very interesting idea?
    I would activa a dummy message mapping. than I would have a look in the file directory of the java-stack and try to find out the name of the *.class or *.jar file.
    On the other hand you could generate a tpz-transport-file an unpack this file, to explore the name of the *.class or *.jar
    Unfortunately I do not have access to the file system. So I can't explore the name.
    Regards Mario

  • Error while doing java mapping

    Hi,
    I have written a java mapping code .But i have a small doubt when i compile it it is showing errors that package com.sap.aii.mapping.api does not exist.How can i solve the problem.Please help me in this issue.
    Thanks,
    Bhargav

    Hi ,
    check this thread, it may help you.
    https://forums.sdn.sap.com/click.jspa?searchID=3558715&messageID=3229273
    Regards,
    Ramesh.

  • Word couldn't send mail because of MAPI failure, Unspecified error.

    This issue is crossposted in Microsoft Answers Word and OUTLOOK.  I am posting here in hopes that someone at Mircrosoft may have a solution or at least elevate the issue to someone who does.
    http://answers.microsoft.com/en-us/office/forum/officeversion_other-word/word-could-not-send-mail-because-of-mapi-failure/f62678fe-ef1d-42b5-8cfe-1e43d6a1d609
    http://answers.microsoft.com/en-us/office/forum/office_2013_release-outlook/word-couldnt-send-mail-due-to-mapi-failure/1f03cf74-9258-411b-9e2b-e41cb5006d71
    I dabble with VBA and write and maintain several amateur Word Add-Ins.  Accordingly, I have Word 2003, 2007, 2010 and 2013 installed on my PC.  They get along fine.  However, I am unable to "Share" or "Send" an open Word
    document as an E-mail attachment in any version!  In each case Word returns an error mesage "Word couldn't send mail because of a MAPI failure, Unspecified error (the same issue occurs with Excel and Powerpoint except the error dialog is a bit different.)
    Using Word 2003, I (CAN) "Send to (Mail recipient for review)" in which case OUTLOOK is opened with the document as an attachment.  I can also "Send to Mail Recipient" from Windows Explorer, in which case the Word file is attached to
    an OUTLOOK message, and I can create an instance of OUTLOOK and send mail from Word using VBA.
    I have repaired all Office versions.  I have removed the registry keys for all office versions and repaired all versions again.  I have run "fixmapi" until I am blue in the face. I have renamed the MAPI32.DLL files and ran sfc \scannow
    to ensure that the MAPI32.DLL file is not corrupt.  In view of these actions and in view of what I can do, something tells me that the MAPI files are fine.
    So what is this "Unspecified error?"  This problem is rife on the internet and most of the "canned" solutions have been marked "Answered" by some MS support engineer.  These "canned" solutions might have
    fixed the issue at one point, but they don't work now.  At least not for me.
    Thanks.
    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Hello Greg,
    I noted that there are 2 knowledge articles that describe scenarios where you may encounter this error.
    KB 291152 You receive a "Word couldn't send mail because of MAPI failure" error message when you try to send a Word document as an e-mail attachment in Word 2002
    http://support.microsoft.com/kb/291152/EN-US
    KB 929362 You cannot send a file by clicking Send in a different program when Outlook 2007 is running as administrator
    http://support.microsoft.com/kb/929362/EN-US
    Please let me know the following:
    1. What version of Outlook are you using?
    2. Do you have Outlook open when you attempt the File > Share > Email as attachment from Word? If not, does the error occur if you open Outlook, open Word and then try to send the email?
    3. If you close/reopen Word and then try the send again, do you get the same error?
    4. Are you running either Outlook or Word in an elevated mode?
    5. What happens if you start both Outlook and Word as "Run As Administrator". You may have to right-click each applications' .exe file to be able to choose the "Run As Administrator" option.
    6. Do you get the same error when using File > Share > Email as attachment using Excel?
    7. In Internet Explorer, open the Internet Options. On the General tab within the browsing history, delete your temporary Internet files and website files
    8. Does the issue occur in selective startup mode?
    Steps to setup selective startup mode:
    Click on the Windows Start button, in the Search box type msconfig and then hit enter. This should open up the System Configuration Utility. Make the following adjustments within each tab.
    Services Tab:
      - Check the option 'Hide All Microsoft Services'
     - Click on button 'Disable All'
    Startup Tab:
     - Click the button 'Disable All'
     - Go back through the list and enable any Microsoft items
    Click Ok. It will say “You must restart your computer for some of the changes
    made by System Configuration to take effect”. Hit the ‘Restart’ button.
    When the PC reboots try to run your test again.
    To return back to a normal boot launch msconfig again and choose 'normal startup' on the general tab, click Ok and then reboot the PC.
    Regards,
    Dennis

  • Java Mapping in pi 7.1 using pi 7.1 nwds

    I am writing a program to remove the special chars in NWDS Java mapping. this is for replacing the "&" with "&amp;".. I am able to compile it and import the jar in PI.. but it does not do anything.. please check..
    And also let me know where to check for Java mapping executed with trace detail.. to check if any error
              try {
              int read_data;
              while ((read_data = arg0.getInputPayload().getInputStream().read()) != -1) {
                   if (read_data != '&') {
                        arg1.getOutputPayload().getOutputStream().write(read_data);
                        } else {
                             arg1.getOutputPayload().getOutputStream().write("&amp;".getBytes());
              arg1.getOutputPayload().getOutputStream().flush();
              }catch (Exception e) { }

    Dear Gopal,
    If i not wrong you need to replace all the charecters "&" with blank ...
    if so you can this code for doing that..
    String outData = inData.replaceAll("&","");
    or
    you need to replace any special charecter to blank please clarify..
    so that i can help you out to solve this issue using java mapping..
    Regards
    Vijay

  • JAVA mapping error

    Hi All,
    I am getting the below error while executing a JAVA mapping.
    <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">LINKAGE_ERROR</SAP:Code>
      <SAP:P1>XMLNSTagCreate1/XMLNSTagCreate1</SAP:P1>
      <SAP:P2>java.lang.NoClassDefFoundError: XMLNSTagCreate1/XM</SAP:P2>
      <SAP:P3>LNSTagCreate1 (wrong name: XMLNSTagCreate1)</SAP:P3>
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:Stack>Linkage error while loading class XMLNSTagCreate1/XMLNSTagCreate1; java.lang.NoClassDefFoundError: XMLNSTagCreate1/XMLNSTagCreate1 (wrong name: XMLNSTagCreate1)</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
    I have tried compiling the code in the same JRE as the one in PI. Still it is not working.
    Please suggest.
    Regards,
    Yashwanth
    Edited by: YashwanthSVK on Aug 17, 2011 8:38 PM

    Hi all... thank you for the replies.. I have compiled the code in the same version of JRE as the PI version...
    Hi Vijay,
    I also felt the same but as I do not have much knowledge in JAVA, i could not track it further. 
    below is the code for the mapping... would you mind if I ask you to have a look at it and let me know where the error is..
    thank you so much ...
    import java.io.*;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.TransformerFactory;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    import com.sap.aii.mapping.api.MappingTrace;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactoryConfigurationError;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import java.io.FileWriter;
    This mapping creates xmlns attribute to send to Tradeplace
    public class XMLNSTagCreate1 extends DefaultHandler  implements StreamTransformation {
         private Map param;
         private MappingTrace trace;
         private OutputStream out;
         public void execute(InputStream in, OutputStream out)
              throws StreamTransformationException {
                   DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
                        try {
                             //trace.addWarning("Execute function starts here");
                             DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
                             try {
                                  org.w3c.dom.Document doc = docBuilder.parse(in);
                                  //Node TradeplaceMessage = doc.getFirstChild();
                                  Element trade=(Element) doc.getFirstChild();
                                  if(trade.hasAttribute("tag1"))
                                  NamedNodeMap TradeplaceMessageAttributes = trade.getAttributes();
                                  String xmlnsValue=trade.getAttribute("tag1");
                                  String modeValue=trade.getAttribute("productionMode");
                                      trace.addInfo("XMLNS  Value:"+xmlnsValue);
                                                                     trade.removeAttribute("tag1");
                                       trade.removeAttribute("productionMode");
                                       trade.setAttribute("xmlns",xmlnsValue);
                                       trade.setAttribute("productionMode",modeValue);
                                                      javax.xml.transform.Transformer transformer = TransformerFactory.newInstance().newTransformer();
                                                      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                                                      StreamResult result = new StreamResult(new StringWriter());
                                                      DOMSource source = new DOMSource(doc);
                                                      transformer.transform(source, result);
                                                      String xmlString = result.getWriter().toString();
                                                      //System.out.println(xmlString);
                                                      out.write(xmlString.getBytes());
                             } catch (SAXException e1) {
                                  // TODO Auto-generated catch block
                                  e1.printStackTrace();
                             } catch (IOException e1) {
                                  // TODO Auto-generated catch block
                                  e1.printStackTrace();
                             } catch (TransformerConfigurationException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                             } catch (TransformerFactoryConfigurationError e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                             } catch (TransformerException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                        } catch (ParserConfigurationException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
         public static void main2(String[] args) throws Exception {
              String xmlFile = "U:
    Untitled.xml";
              InputStream in = new BufferedInputStream(new FileInputStream(xmlFile));
              XMLNSTagCreate1 test = new XMLNSTagCreate1();
              //test.countOccurences(in);
         public static void main(String[] args) throws Exception {
              String xmlFile = "//NA.AD.WHIRLPOOL.COM//myApps//home//NA//qqjos1d//My Documents//TP2.xml";
              InputStream in = new BufferedInputStream(new FileInputStream(xmlFile));
              FileOutputStream out = new FileOutputStream("//NA.AD.WHIRLPOOL.COM//myApps//home//NA//qqjos1d//My Documents//DhanishTP2.xml");
              XMLNSTagCreate1 test = new XMLNSTagCreate1();
              test.execute(in, out);
              OutputStreamWriter out1 = new OutputStreamWriter(out,"UTF-8");
         /* (non-Javadoc)
    @see com.sap.aii.mapping.api.StreamTransformation#setParameter(java.util.Map)
         public void setParameter(Map param) {
              // TODO Auto-generated method stub

  • Issue in conversion ABAP to java mapping during PI upgrade

    Hi All,
    We are upgrading one interface from ABAP mapping to Graphical/Java mapping in PI upgrade.(7.1 dual stack to 7.4 version)
    In ABAP mapping there is character conversion like below.
      encoding    = '1164'
          replacement = '?'
    We want to implement the same functionality either through Java or graphical mapping . But we are not sure what are the range  of characters that need to be converted to '?' and also what is the most optimized way to achieve this functionality.
    Below are few sample of characters coming in the file:
    б,л,к,У,М,л,и,о,ф..etc

    hi all,
    the issue got resolved with a JAVA replace function
    String r = str.replaceAll("\\P{InBasic_Latin}", "?");
    Thanks all for your inputs.
    Regards,
    Anamika

  • Creation of additional attachment in Java Mapping

    Hello all,
    I want to use a Java Mapping with the functionality to create a second /attachment which I can send over email out?
    I don’t want to pick this file somewhere from the server, instead I want to fill the content of the additional attachment directly in the java mapping.
    I hope somebody knows the answer of my question.
    If its possible is there any kind of example??
    Many thanks for your help
    ilka

    hi Stefan,
    http://scn.sap.com/thread/1874962
    Regarding the comment in this thread, can you please tell me if you have faced any issue with creating output attachments. Right now, i have a message mapping in which i have written a udf to create attachments
    this message mapping is a multi mapping and the source is 0-unb. I have used a return as xml on the root message and pointed it to the udf after split by value.
    There are three root nodes in one of my cases, and when this goes through this mapping, there is 1 attachemnt each created with three main documents and submain documents. However, all the attachments contain details of the first root node itself where in actually it should be each main and submain document having a different attachment. Please find my udf below. Please let me know if you think it is wrong somewhere.
    udf :-
    GlobalContainer globalContainer = container.getGlobalContainer();
    OutputAttachments outputAttachments = globalContainer.getOutputAttachments() ;
    int flag =0;
    AbstractTrace trace = container.getTrace();
    String attachmentName = "";
    //for(int i=0;i<var1.length;i++){
    try
    var1=var1.replaceAll("><",">\n<");
    attachmentName = "attachment"+cnt;
    Attachment newopAttachment = outputAttachments.create((attachmentName), var1.getBytes("UTF-8"));
    outputAttachments.setAttachment(newopAttachment);
    trace.addInfo("newopAttachment"+newopAttachment);
    cnt=cnt+1;
    attachmentName ="";
    newopAttachment = null;
    var1="";
    catch (Exception e)
    trace.addInfo("ever reaching trace");
          e.printStackTrace(); 
    //result.addValue("1");  
    //result.addValue("1");  
    return "1";
    Input :-
    Messages
    Message1
    SBDH
    SBDH
    SBDH
    Each of the above SBDH, i have returned as xml and pointed to the udf after split by value
    Your help is highly appreciated.
    Regards,
    Ninu

  • Need help on guide of java mapping

    HI,
    I want to learn java mapping. I searched in blogs but I am not comfortable to understand. Can anyone explain me the step by step process.
    Thanks,
    Enivass

    Hi enivas,
    Having basic understanding about J2SE will be great help for you. Please check these links about Java Mapping step by step
    Implementing a Java Mapping in SAP PI /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
    XI Java Mapping Helper (DOM) /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    Debugging Java Mappings using SAP Netweaver Developer Studio /people/christian.drumm/blog/2008/09/30/debugging-java-mappings-using-sap-netweaver-developer-studio
    Handling and Tracing Runtime Exceptions in Java Mapping /people/prasannakrishna.mynam/blog/2009/07/21/handling-and-tracing-runtime-exceptions-in-java-mapping
    SAP PI Java API has changed a lot from PI7.0 to PI7.1. http://wiki.sdn.sap.com/wiki/display/XI/UsingPI7.1APIforJavamapping
    Check them out in this link Javadocs Index http://www.sdn.sap.com/irj/sdn/javadocs. Blogs mentioned use old API, but once you get idea about Java mapping switching to new API will be easy. Java help is easily available on net, use Google more. Happy learning.
    Regards,
    Raghu_Vamsee

  • Problem in Java Mapping

    Hi,
          I was trying out a simple Java mapping example.
    Example of source structure is -
    <?xml version="1.0"?>
    <ns0:MT_SRC xmlns:ns0="http://www.sap-press.com/xi/training/00">
    <organization>
    <employee>
    <firstname>Jack</firstname>
    <lastname>Rose</lastname>
    </employee>
    <employee>
    <firstname>Paul</firstname>
    <lastname>McNealy</lastname>
    </employee>
    <employee>
    <firstname>Vaibhav</firstname>
    <lastname>Pandey</lastname>
    </employee>
    </organization>
    </ns0:MT_SRC>
    Example of target structure is -
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_TRGT xmlns:ns0="http://www.sap-press.com/xi/training/00"><Organization><employee><name>JackRose</name></employee><employee><name>PaulMcNealy</name></employee><employee><name>VaibhavPandey</name></employee></Organization></ns0:MT_TRGT>
    and here's the code I'm using
    package com.mapping;
    import java.io.*;
    import java.util.Map;
    import java.util.HashMap;
    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 javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.api.MappingTrace;
    import com.sap.aii.mapping.api.StreamTransformation;
    public class JavaMap implements StreamTransformation{
         private Map param = null;
            private MappingTrace  trace = null;
            public void setParameter (Map param) {
                this.param = param;
                if (param == null) {
                    this.param = new HashMap();
            public void execute(InputStream in, OutputStream out) {
                   OutputStreamWriter buf_writer = new OutputStreamWriter(out);        
                   InputStreamReader buf_reader = new InputStreamReader(in);
                   String mat = new String();
                   String extmat = new String();
                   try {
                        buf_writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" ,0,56);
                        buf_writer.write("<ns0:MT_TRGT xmlns:ns0=\"http://www.sap-press.com/xi/training/00\">");
                        buf_writer.write("<Organization>",0,20);
                        buf_writer.flush();
                  } catch(IOException e){};
                  try {
                       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();          
                       factory.setValidating(false);          
                       DocumentBuilder builder = factory.newDocumentBuilder();          
                       Document doc = builder.parse(in);
                        String fname = null;
                        String lname = null;
                        doc.getDocumentElement().normalize();
                        //System.out.println("Root element " + doc.getDocumentElement().getNodeName());
                        NodeList nodeLst = doc.getElementsByTagName("employee");
                        //System.out.println("Information of all employees");
                        for (int s = 0; s < nodeLst.getLength(); s++) {
                        Node fstNode = nodeLst.item(s);
                        if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
                             buf_writer.write("<employee>");     
                        Element fstElmnt = (Element) fstNode;
                        NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("firstname");
                        Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
                        NodeList fstNm = fstNmElmnt.getChildNodes();
                        //System.out.println("First Name : " + ((Node) fstNm.item(0)).getNodeValue());
                        fname = fstNm.item(0).getNodeValue();
                        NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("lastname");
                        Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
                        NodeList lstNm = lstNmElmnt.getChildNodes();
                        //System.out.println("Last Name : " + ((Node) lstNm.item(0)).getNodeValue());
                        lname = lstNm.item(0).getNodeValue();
                        buf_writer.write("<name>"fname" "lname"</name>");
                        buf_writer.write("</employee>");
                        buf_writer.write("</Organization>");
                        buf_writer.write("</ns0:MT_TRGT>");
                        TransformerFactory tFactory = TransformerFactory.newInstance();
                     Transformer transformer = tFactory.newTransformer();
                     transformer.setOutputProperty("indent", "yes");
                     DOMSource source = new DOMSource(doc);
                     StreamResult result = new StreamResult(out);
                     transformer.transform(source, result);
                        } catch (Exception e) {
                        e.printStackTrace();
    However, when I'm testing my Interface mapping, I'm getting the following error -
    Call method execute of the application Java mapping com.mapping.JavaMap
    Error during appliction Java mapping com/mapping/JavaMap
    java.lang.StringIndexOutOfBoundsException at java.lang.String.getChars(String.java:672)
    Could anyone please help me out with this?
    Thanks and Regards,
    Shiladitya

    HI,
    It looks to be that your JavaMap class have one field whihc will be not getting the proper value as input thus its creating the array Index out of bound exception.
    Please can you verify if you have assigned the proper String size for all the fields.
    Or probably you are getting the blank value which have created the execption.
    Also can you narrow down and let me know about the line String.getChars(String.java:672)
    Here you have used the try and catch option but may be the exact line no. can give better idea about the problem.
    Thanks
    swarup

Maybe you are looking for

  • How do I get old email addresses to stop popping up on my iPhone?

    When typing email, if I am typing an address for someone who has since had a new address, the old address still pops up as an option when prepopulating suggestions. For instance, if my old address was [email protected] and is now [email protected], t

  • How to align text vertically?

    This seems like it should be really easy: On a simple text slide, how do I align multiple lines of text vertically? Do I have to eyeball it, or is there a way to fix it exactly in the center, top to bottom?

  • Can't create MBO from SAP servers

    Hi, I'm trying to create MBO from SAP servers with Sybase Unwired WorkSpace. I created Connection Profile and it worked well(Ping succeeded!). However, I expanded profile tree, no BAPI was shown. Any ideas what is happening here? SAP version is below

  • Pickup only the newest record in an Internal Table.

    Hi all: I have and internal table that i am accesing in a transformation. Which is the best approach to read from the internal table only the record with the newest date. Data look like this: Date_________MAT___ Qty 12.08.2009___4050___70 10.05.2009_

  • How to make already written Encryption code in JDK 1.3  work in JDK 1.4

    Hi, We are using JCE to encrypt a number.The following code was written in JDK 1.3 and is now on the Live site.           byte[] publicKeyBytes =new BigInteger("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", Character.MAX_RADIX).toByteArray();      En