Imported java mapping trouble

Hello.
I'm in the process of moving all of our XI 2.0 applications to XI 3.0. One of these apps uses an imported archive as an interface mapping. I'm getting this error message: "XML not well-formed", when I try to test my mapping in IR.
The java mapping imports the StreamTransformation class, then references the RECEIVER_NAME and RECEIVER_NAMESPACE components. However, these are always blank in the XML being created.
This is a part of my Java mapping:
package wtGas;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import java.io.*;
import java.util.Map;
import java.util.Vector;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
public class JM_WTGas extends DefaultHandler implements StreamTransformation {
     public void setParameter (Map param){
          map = param;
     public void execute(InputStream in, OutputStream out) throws com.sap.aii.mapping.api.StreamTransformationException {
          DefaultHandler handler = this;
          SAXParserFactory factory = SAXParserFactory.newInstance();
          try{
               SAXParser saxParser = factory.newSAXParser();
               this.out=out;
               saxParser.parse(in, handler);
          }catch(Throwable t){
               t.printStackTrace();
     public void startDocument() throws SAXException {
          write("<?xml version='1.0' encoding='UTF-8'?>");
          write("<ns1:" + (String)map.<b>get(StreamTransformationConstants.RECEIVER_NAME)</b> + " xmlns:ns1=\"" + (String)map.<b>get(StreamTransformationConstants.RECEIVER_NAMESPACE)</b>+ "\">");          
write("<TABLE2>");
     public void endDocument() throws SAXException{
write("</ns1:" + (String) map.<b>get(StreamTransformationConstants.RECEIVER_NAME)</b> + ">")
And this is the resulting XML file:
<?xml version='1.0' encoding='UTF-8'?>
<b><ns1: xmlns:ns1=""></b>
<TABLE2>
<item>
<REC_TYPE>0001</REC_TYPE>
<POSTKEY>50</POSTKEY>
<ACCOUNT></ACCOUNT>
<AMOUNT>0000000000000000</AMOUNT>
<TAX_CODE>1o</TAX_CODE>
<JURIS>camb</JURIS>
<BUNIT></BUNIT>
<COST_CTR></COST_CTR>
<ORD_NO></ORD_NO>
<ASSIGNMENT></ASSIGNMENT>
<DET_TEXT></DET_TEXT>
</item>
<b></ns1:></b>
As you can see, it's leaving out the receiver name and namespace. Can anyone tell me what's going on, please? This was working in XI 2.0.
Thank you.
Nicole

Are you doing the single test in the IR ?
If then the streamtransformation map will not be set by default...it needs to be set explicitly...on the 'Test' tab, there are in turn 2 sub tabs 'Document' and 'Parameters'....the streamtransformation values need to be set in the 'Parameters' tab...
Thanks.

Similar Messages

  • Importing jar files for Java mapping ?

    Hi Guys,
    I am developing a java mapping by using Eclipse. I want to know <b>where can i find the jar files of xi which i need to import into Eclipse to develop the Java Mapping</b>.
    I need to use the external jar files for this Java Mapping and once i am done with the mapping, <b>How can import the external .jar files into XI</b>
    any hep would be really appreciated
    Thanks,
    srini

    Sri,
    check <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions's XI FAQ</a> for the location of .jar of mapping API.
    <b>5. Where can I find aii_map_api.jar to create my Java mapping?</b>
    After you have created your java mapping class, export your project to a .jar file and import this .jar into Imported Archives (under Mapping node) in Integration Repository.
    Regards,
    Henrique.

  • Compile error import java.util.map$entry

    Hi,
    I am trying to compile code which imports the following package
    import java.util.Map$Entry.
    The error thrown up is : cant resolve symbol Map$Entry. Why is there a $ in the package import path and is there some configuration required to compile the file.
    I am not allowed to change the code. Does anyone have an idea on how this problem can be solved.
    Thanks and regards
    Kumar Vellal

    Btw java docs for the interface are available at:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.Entry.html
    Changing the import should probably help compile the code, but without changing the import .. need to check. This is just from what i remember now. Lets see if anyone else comments on this.

  • PI Java Mapping NullPointerException

    Hi Gurus,
    I'm having some troubles doing the mapping through java mapping in PI.
    I've done the java class in the SAP NWDS and imported it on PI through the ESR.
    Now i'm trying to test through the SOAP and i've found the following error in the "Communication Channel Monitor":
    500   Internal Server Error  SAP NetWeaver Application Server/Java AS 
    java.lang.NullPointerException: while trying to invoke the method com.sap.aii.af.sdk.xi.lang.Binary.getBytes() of a null object returned from com.sap.aii.af.sdk.xi.mo.xmb.XMBPayload.getContent()
    And the following error in the SXMB_MONI:
    <SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="INTERNAL">CLIENT_SEND_FAILED</SAP:Code>
      <SAP:P1>500</SAP:P1>
      <SAP:P2>Internal Server Error</SAP:P2>
      <SAP:P3>(See attachment HTMLError for details)</SAP:P3>
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:Stack>Error while sending by HTTP (error code: 500 , error text: Internal Server Error) (See attachment HTMLError for details)</SAP:Stack>
    I've developed the code below:
    public class PI_Mapping_IF extends AbstractTransformation {
      public void transform(TransformationInput in, TransformationOutput out)    throws StreamTransformationException  {  
      this.execute(in.getInputPayload().getInputStream(), out.getOutputPayload().getOutputStream()); 
      public void execute(InputStream in, OutputStream out)  throws StreamTransformationException { 
      try  
      // Inicio do java mapping
      getTrace().addInfo("JAVA Mapping Iniciado"); //Log para o PI/XI
      // Declarações referentes ao XML de entrada
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document xml_in = db.parse(in);
      // Declarações referentes ao XML de saída
      Document xml_out = db.newDocument();
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
      // Remove o standalone
      xml_in.setXmlStandalone(true);
      // Declara a estrutura que a RFC irá receber
      Element root = xml_out.createElement("ns1:ZFSD_VMOI_UPLOAD_CF_PG");
      root.setAttribute("xmlns:ns1","urn:sap-com:document:sap:rfc:functions");
      xml_out.appendChild(root);
      Element i_cenario = xml_out.createElement("I_CENARIO");
      root.appendChild(i_cenario);
      Element t_input = xml_out.createElement("T_INPUT");
      root.appendChild(t_input);
      Element item = xml_out.createElement("ITEM");
      t_input.appendChild(item);
      Element STRING = xml_out.createElement("STRING");
      item.appendChild(STRING);
      Element t_return = xml_out.createElement("T_RETURN");
      root.appendChild(t_return);
      Element item_r = xml_out.createElement("ITEM");
      t_return.appendChild(item_r);
      Element message = xml_out.createElement("MESSAGE");
      item_r.appendChild(message);
      // Verifica se existe algum filho no nó
      NodeList nodos = xml_in.getChildNodes(); 
      if (nodos.item(0) != null)
      getTrace().addInfo("O nó(XML) possui filhos"); //Log para o PI/XI
      // Declaração de variáveis
      String ident = ""; // <Ident>
      String buyer = ""; // <BuyerLineItemNum>
      String result = ""; // <Ident>;<BuyerLineItemNum>;<Date>;<QuantityValue>
      // Inicia a extração das informações do XML
      try{
      // Recupera o nó ShipToParty
      NodeList nodeShip = xml_in.getElementsByTagName("ns0:ShipToParty");
      Node node = nodeShip.item(0);
      Element elemXML = (Element) node;
      try{
      NodeList nodeIdent = elemXML.getElementsByTagName("ns0:Ident");
      Element nameElement = (Element) nodeIdent.item(0);
      nodeIdent = nameElement.getChildNodes();
      // Recupera o valor da chave <Ident>
      ident = PI_Mapping_IF.VerifyNull(((Node) nodeIdent.item(0)).getNodeValue());
      }catch(Exception e){
      result += "0.0;";
      // Recupera o nó ListOfMaterialGroupedPlanningDetail
      NodeList nodeBuyer  = xml_in.getElementsByTagName("ns0:MaterialGroupedPlanningDetail");
      for (int i = 0; i < nodeBuyer.getLength(); i++) {
      node = nodeBuyer.item(i);
      elemXML = (Element) node;
      try{
      // Preenche a chave BuyerLineItemNum
      NodeList nodeBuyerLine = elemXML.getElementsByTagName("ns0:BuyerLineItemNum");
      Element elemBuyerLine = (Element) nodeBuyerLine.item(0);
      nodeBuyerLine = elemBuyerLine.getChildNodes();
      buyer = PI_Mapping_IF.VerifyNull(((Node) nodeBuyerLine.item(0)).getNodeValue());
      }catch(Exception e){
      buyer += "0;";
      result = ident+";"+buyer+";";
      Node nodeDt_Qnt = nodeBuyer.item(i);
      Element elemDt_Qnt = (Element)nodeDt_Qnt;
      NodeList nodeValores = elemDt_Qnt.getElementsByTagName("ns0:ScheduleDetail");
      for (int j = 0; j < nodeValores.getLength(); j++) {
      node = nodeValores.item(j);
      elemXML = (Element) node;
      try{
      // Preenche a chave Date
      NodeList modelExtra = elemXML.getElementsByTagName("ns0:Date");
      Element extraElement = (Element) modelExtra.item(0);
      modelExtra = extraElement.getChildNodes();
      result += PI_Mapping_IF.VerifyNull(((Node) modelExtra.item(0)).getNodeValue())+";";
      }catch(Exception e){
      result += "//;";
      try {
      // Preenche a chave QuantityValue
      NodeList modelURL = elemXML.getElementsByTagName("ns0:QuantityValue");
      Element urlElement = (Element) modelURL.item(0);
      modelURL = urlElement.getChildNodes();
      result += PI_Mapping_IF.VerifyNull(((Node) modelURL.item(0)).getNodeValue())+";";
      } catch (Exception e) {
      result += "0.0;";
      // Marca o final do registro
      result += "||";
      // Preenche os nós itens
      Text srcxml = xml_out.createTextNode(result);
      STRING.appendChild(srcxml);
      result = "";
      buyer = "";
      }catch(Exception e){
      // Remove o standalone
      xml_out.setXmlStandalone(true);
      // Preenche o Cenario
      Text cenario = xml_out.createTextNode("P&G");
      i_cenario.appendChild(cenario);
      // Preenche mensagem de retorno
      Text msgxml = xml_out.createTextNode("XML lido com sucesso!");
      message.appendChild(msgxml);
      // Escreve a saida do XML            
      transformer.transform(new DOMSource(xml_out), new StreamResult(out));
      getTrace().addInfo("Fim da execução do Java Mapping");
      } catch (ParserConfigurationException e) {
      getTrace().addWarning(e.getMessage());
      throw new StreamTransformationException("Can not create DocumentBuilder.", e);
      } catch (SAXException e) {
      e.printStackTrace();
      } catch (IOException e) {
      e.printStackTrace();
      } catch (TransformerConfigurationException e) {
      e.printStackTrace();
      } catch (TransformerException e) {
      e.printStackTrace();
    Am i doing anything wrong in the code? Where can this nullpointerexception be triggered?
    Thanks.

    These three xml are the same:
    <?xml version="1.0"?><a:xml xmlns:a="urn:123">root</a:xml>
    <?xml version="1.0"?><xml xmlns="urn:123">root</xml>
    <?xml version="1.0"?><ns0:xml xmlns:ns0="urn:123">root</ns0:xml>
    But your code will work only with last one, because it doesn't bound namespace to prefix ns0.

  • Java mapping runtime issue

    Hi,
    I have currently created a java mapping which unzips files and transforms plain text/falt files to xml according to a specific structure... So far so good. This stuff works perfectly when testing interface mapping in the repository. However at runtime it does not work, and this is where you clever guys come into the picture:-)
    It should be mentioned that the zip-file is dropped on a MQ-queue and picked up in XI and passed on to a BPM - the only thing the BPM does is to perform the java mapping and afterwards send one of the messages to R/3 and the other to CRM.
    The concrete error given at runtime in the PE is:
    Error handling for work item 000000718016
    Work item 000000718016: Object CL_SWF_XI_MSG_BROKER method CALL_TRANSFORMATION cannot be executed
    Parsing error before mapping: unexpected end-of-file (line 1, column 1)
    Hope somone can help me on this matter,
    Best regards,
    Daniel
    PS: In case it is of interest/use the java code used is this:
    package dk.post.xi.unzipAndConvert;
    import java.io.*;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    import com.sap.aii.mapping.api.MappingTrace;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.StreamTransformationException;
    public class UnzipMain implements StreamTransformation {
         private MappingTrace mappingTrace = null;
         private Map param = null;
         private StringBuffer currentXmlRecord = new StringBuffer();
        private StringBuffer currentPlainRecord = new StringBuffer();
        private int[][] dataRanges = null;
        private char[] charsInCurrentRange = new char[650];
         private String[] xmlTagNames = null;
         /* (non-Javadoc)
    @see com.sap.aii.mapping.api.StreamTransformation#setParameter(java.util.Map)
    Method must be implemented when class is implementing streamTransformation
           public void setParameter(Map param) {
            this.param = param;
            if (param == null) {
               this.param = new HashMap();
    (non-Javadoc)
    @see com.sap.aii.mapping.api.StreamTransformation#execute(java.io.InputStream, java.io.OutputStream)
    Main function -- called by XI to start execution of java mapping
           public final void execute(InputStream in, OutputStream out)
                throws StreamTransformationException
                //if no input, then cancel program execution
                if (in == null) {
                     throw new RuntimeException("Something wrong with input zip file - is null");
                //input <> null. Begin upzip operation
                try {
                     //test is only relevant outside of XI
                     if (param != null) {
                          mappingTrace = (MappingTrace) param.get(StreamTransformationConstants.MAPPING_TRACE );
                  ZipInputStream zip = null;
                     try {
                          zip = new ZipInputStream(in);
                          ZipEntry ze = null;
                          out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><ns0:Messages xmlns:ns0=\"http://sap.com/xi/XI/SplitAndMerge\">".getBytes());
                          while ((ze = zip.getNextEntry()) != null) {
                               writeDebugInfo("File: " + ze.getName() + " with compressed size: " + ze.getCompressedSize());
                               scrutinize(zip,(ZipEntry) ze, out);
                          out.write("</ns0:Messages>".getBytes());
                     finally {
                          if (zip != null)
                               zip.close();
                          out.flush();
                          out.close();
                } catch (Exception e) {
                     throw new RuntimeException(e + "\nSomething went wrong...");
           //Unzip flat files and convert to xml
           private void scrutinize(ZipInputStream inStream,ZipEntry zipEntry, OutputStream outstream) throws Exception {
                long start = System.currentTimeMillis();
              InputStreamReader inStreamReader = null;
              BufferedReader buffReader = null;
              byte[] xmlBytes = null;
              try {
                   inStreamReader = new InputStreamReader(inStream);
                   buffReader = new BufferedReader(inStreamReader);
                 boolean masterData = zipEntry.getName().equals("PD-01-STAMDATA.DAT");
                 boolean creditData = zipEntry.getName().equals("PD-02-KREDITVURDERING.DAT");
                 String currentLine = null;
                 if (masterData) {
                      writeDebugInfo("- Begin reading and converting every line of MasterData...");     //out-comment this outside of XI, or compilation will fail (functionality is only available in XI)
                      outstream.write("<ns0:Message1><ns1:masterData_MT xmlns:ns1=\"http://pdk/xi/kob/importDataToSap\">".getBytes());
                        while ((currentLine = buffReader.readLine()) != null) {
                           //convert one line of credit data plain into an xml record structure
                           makeXmlRecord(currentLine,true);
                           //Write record XML to XI's outputstream (appends)
                           xmlBytes = currentXmlRecord.toString().getBytes();
                           outstream.write(xmlBytes);
                      outstream.write("</ns1:masterData_MT></ns0:Message1>".getBytes());
                      writeDebugInfo("- Finished reading and converting every line of MasterData...");     //out-comment this outside of XI, or compilation will fail (functionality is only available in XI)
                 if (creditData) {
                      writeDebugInfo("- Begin reading and converting every line of CreditData...");
                      outstream.write("<ns0:Message2><ns1:creditData_MT xmlns:ns1=\"http://pdk/xi/kob/importDataToSap\">".getBytes());
                      while ((currentLine = buffReader.readLine()) != null) {
                           //convert one line of credit data plain into an xml record structure
                           makeXmlRecord(currentLine,false);
                           //Write record XML to XI's outputstream (appends)
                           xmlBytes = currentXmlRecord.toString().getBytes();
                           outstream.write(xmlBytes);
                      outstream.write("</ns1:creditData_MT></ns0:Message2>".getBytes());
                      writeDebugInfo("- Finished reading and converting every line of CreditData...");
              } finally {
                   long timeUsed = System.currentTimeMillis() - start;
                   writeDebugInfo(zipEntry.getName() + "  - Write took: " + timeUsed + " ms");
                   writeDebugInfo("Final statement entered...\n");
           //check for invalid xml chars (plus a few other strange chars) in a plain text record and if any are found update the ranges of so they correspond to the new length of a record
           private int[][] checkRange(String currentPlainLine, boolean isMasterData) {
                int counter = 0;
                int beginRange = 0;
                int endRange = 0;
                //populate array with proper data ranges/intervals according to how data is to be split
                dataRanges = isMasterData ? new int[][] {{0,2},{2,12},{12,44},{44,47},{47,50},{50,295},{295,298},{298,356},{356,426},{426,496},{496,499},{499,506},{506,510},{510,518},{518,540},{540,546},{546,552},{552,558},{558,564},{564,570},{570,576},{576,582},{582,588},{588,594},{594,604}} : new int[][] {{0,2},{2,12},{12,20},{20,23},{23,26},{26,29},{29,44}};
                //ensure stringbuffer is empty
                currentPlainRecord.delete(0,currentPlainRecord.length());
                //insert the current plain text line into stringbuffer
                currentPlainRecord.append(currentPlainLine);
              //loop through outer array (array of ranges)
              for (int i = 0; i <= (dataRanges.length-1); i++) {
                   beginRange = dataRanges<i>[0];
                   counter = beginRange;
                   endRange = dataRanges<i>[1];
                   //loop through stringbuffer, based on the value-pairs of ranges/intervals in array of arrays
                   while (counter < endRange) {
                        switch (currentPlainRecord.charAt(counter)) {
                             case '&':
                                  currentPlainRecord.insert(counter+1,"amp;");          //insert 'amp;' after '&', so that syntax conforms to xml syntax requirements (&amp;)
                                  counter += 5;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,4);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '\'':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '\'' with '&'
                                  currentPlainRecord.insert(counter+1,"apos;");          //insert 'apos;' after '\'', so that syntax conforms to xml syntax requirements (&apos;)
                                  counter += 6;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,5);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '"':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '"' with '&'
                                  currentPlainRecord.insert(counter+1,"quot;");          //insert 'quot;' after '"', so that syntax conforms to xml syntax requirements (&quot;)
                                  counter += 6;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,5);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '<':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '<' with '&'
                                  currentPlainRecord.insert(counter+1,"lt;");               //insert 'lt;' after '&', so that syntax conforms to xml syntax requirements (&lt;)
                                  counter += 4;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,3);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '>':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '>' with '&'
                                  currentPlainRecord.insert(counter+1,"gt;");               //insert 'gt;' after '&', so that syntax conforms to xml syntax requirements (&gt;)
                                  counter += 4;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,3);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case 0x7F:
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace 0x7F with ' '
                                  writeDebugInfo("-- Corrected the character 0x7F ('') to ' '");
                                  counter++;
                                  break;
                             case '‘':
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace 0x91 ('‘') with ' '
                                  writeDebugInfo("-- Corrected the character '‘' to ' '");
                                  counter++;
                                  break;
                             case '›':
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace 0x9B ('›') with ' '
                                  writeDebugInfo("-- Corrected the character 0x9B to ' '");                              counter++;
                                  break;
                             case '†':
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace '†' with ' '
                                  writeDebugInfo("-- Corrected the character '†' to ' '");
                                  counter++;
                                  break;
                             default :
                                  counter++;
                                  break;
                return dataRanges;
           //update array of ranges so that is corresponds to the new range
           private void updateRange(int currentRange, int updateRangeBy) {
              for (int k = currentRange; k < dataRanges.length; k++) {
                   if (k != currentRange) {     //never update begin interval for the current range - only for the remaining intervals
                             dataRanges[k][0] += updateRangeBy;
                   dataRanges[k][1] += updateRangeBy;     //always update end intervals
           //convert one flat record line to a xml record structure
         private void makeXmlRecord(String currentPlainLine,boolean isMasterData) {
              dataRanges = checkRange(currentPlainLine,isMasterData);
              //clear StringBuffer
              currentXmlRecord.delete(0,currentXmlRecord.length());
              //get the correct set of xml tags to be used when performing mapping between plain text and xml
              if (isMasterData) {
                   xmlTagNames = new String[] {"dum1","kob_no","dum2","corp_status","legal_form","dum3","pr_protec_code","dum4","uri","email","emp_no_grp_code","exact_no_emp","dum5","founding_date","dum6","main_industry_code","industry_code1","industry_code2","industry_code3","industry_code4","industry_code5","industry_code6","industry_code7","industry_code8","dum7"};
              } else {
                   xmlTagNames = new String[] {"dum1","kob_no","rating_date","rating_value","risc_grp_code","currency","max_credit"};
              //copy all chars in stringBuffer to the specified char[]
              currentPlainRecord.getChars(0,currentPlainRecord.length(),charsInCurrentRange,0);
              //populate XML record structure
              currentXmlRecord.append("<record>");
              for (int i = 0; i < xmlTagNames.length; i++) {
                   currentXmlRecord.append("<" + xmlTagNames<i> + ">");
                   currentXmlRecord.append(charsInCurrentRange,dataRanges<i>[0],(dataRanges<i>[1])-(dataRanges<i>[0]));
                   currentXmlRecord.append("</" + xmlTagNames<i> + ">");
              currentXmlRecord.append("</record>");
         //write debug information to correct "place"
         private void writeDebugInfo(String debugInfo) {
              if (mappingTrace == null) {
                   System.out.println("Debug: " + debugInfo);
              } else {
                   mappingTrace.addInfo("Debug: " + debugInfo);

    Hi Alex,
    Thanks for your reply. First of all I was wondering if I missed something somewhere in my generel understanding of XI and BPM's!? - I kind of sense some irony/sarkasm in beginning of your reply:-) As far as I know BPM should have no trouble receing non-xml (in my case zip-files)!?
    Anyways here goes:
    1. Yes, this is also my impression that is should be possible somehow (we do currently run sp14). However, I havent yet figured out how to do it in this case. When trying to create interface mapping between the three involved software components, I get a 'MESS_MULTI_MAP_IF_WRONG_SWCV' three times. I've searched around without being able to find any information on the error. I does seem, though, like the problem is that all objects aren't in the same software component!! But this approach is of course the prefered one...
    2. Well - you got me there. Kind of expected someone to point that out:-) This is of course something to be looked into also in order to "improve"/"enhance" the program - though it, as already pointed out, works perfectly as is.
    3. This part I have also thought about - though quickly moved away from the idea, but that is only due to lacking insight/knowhow on the subject. Interesting weblog you have written, something so I will investigate further when  time allows for it:-)
    Best regards,
    Daniel

  • Get dynamic filename in a Java Mapping (NOT UDF)

    Hi,
    we are using a Java Mapping step in XI (not UDF). We need to have access to the filename. In the File Adapter we set the message attributes and can see the filename value in the SXMB_MONI.
    We use the following code fragment to have access to the filename:
    Container container = new Context(new FunctionWrapper(0));
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String sourceFileName = conf.get(key);
    This doesn't work. We think the declaration of the container class is wrong. Does anybody have some information about using the dynamic attributes in Java Mappings?
    Thanks in advance
    Michael

    import com.sap.aii.mapping.api.*;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.HashMap;
    import java.util.Map;
    public class JavaProgram
        implements StreamTransformation
        public JavaProgram()
        public void setParameter(Map map)
            param = map;
            if(param == null)
                param = new HashMap();
        public void execute(InputStream inputstream, OutputStream outputstream)
            try
                DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get("DynamicConfiguration");
                DynamicConfigurationKey dynamicconfigurationkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
                String s = dynamicconfiguration.get(dynamicconfigurationkey);
             //Your logic
            catch(Throwable throwable)
                throwable.printStackTrace();
        private Map param;

  • 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

  • Keystore access in Java Mapping Program - user J2EE_GUEST

    Dear Gurus,
    I have the following problem:
    I need to validate the digital signature of a XML document and I'm using some examples provided by SAP as follows:
              InitialContext ctx = ctx = new InitialContext();          
              Object o = (Object) ctx.lookup("keystore");          
              KeystoreManager manager = (KeystoreManager) o;          
              KeyStore ks = manager.getKeystore("Serasa");
    {/code}
    But I get the error below, saying that user J2EE_GUEST is not authorized. How do I change the user who executes java mapping, because I granted permissions in Visual Admin to another user.
         at com.sap.aii.ibrun.sbeans.mapping.MappingServiceObjectImpl0_0.processFunction(MappingServiceObjectImpl0_0.java:131)
         at sun.reflect.GeneratedMethodAccessor267.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:62)
         at java.lang.reflect.Method.invoke(Method.java:391)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy218.processFunction(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor266.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:62)
         at java.lang.reflect.Method.invoke(Method.java:391)
         at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.call(RFCDefaultRequestHandler.java:284)
         at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:219)
         at com.sap.engine.services.rfcengine.RFCJCOServer$J2EEApplicationRunnable.run(RFCJCOServer.java:254)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(AccessController.java:219)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
    Caused by: com.sap.engine.services.keystore.exceptions.BaseKeystoreException: User is not authorized to execute keystore operation[{GET_VIEW Serasa }]
         at com.sap.engine.services.keystore.impl.security.UserBasedSecurityConnector.checkUserPermission(UserBasedSecurityConnector.java:889)
         at com.sap.engine.services.keystore.impl.security.SecurityRestrictionsChecker.checkUserPermission(SecurityRestrictionsChecker.java:52)
         at com.sap.engine.services.keystore.impl.security.SecurityRestrictionsChecker.isUserAuthorized(SecurityRestrictionsChecker.java:148)
         at com.sap.engine.services.keystore.impl.security.SecurityRestrictionsChecker.checkPermission(SecurityRestrictionsChecker.java:174)
         at com.sap.engine.services.keystore.impl.ParameterChecker.checkPermission(ParameterChecker.java:35)
         at com.sap.engine.services.keystore.impl.KeystoreManagerImpl.checkPermission(KeystoreManagerImpl.java:46)
         ... 28 more
    Caused by: java.security.KeyStoreException: (thread: SAPEngine_Application_Thread[impl:3]_56,view:Serasa, entry: , user: J2EE_GUEST) - checkPermissions  'getView': com.sap.engine.services.security.exceptions.BaseSecurityException: Caller not authorized.
         at com.sap.engine.services.keystore.impl.security.UserBasedSecurityConnector.checkFailed(UserBasedSecurityConnector.java:1097)
         at com.sap.engine.services.keystore.impl.security.UserBasedSecurityConnector.checkPermissions_getView(UserBasedSecurityConnector.java:773)
         at com.sap.engine.services.keystore.impl.security.UserBasedSecurityConnector.checkUserPermission(UserBasedSecurityConnector.java:823)
         ... 33 more
    {/code}
    Thank you very much

    Hi Fabio,
    first of all have you checked if standard functions to verify digital signature for pi adpaters would work for you?
    We have used the following code to access the Keystore in a custom adapter. It accesses the keystore with the access rights of a JEE application (it has a reference to the sample adapter "sap.com/com.sap.aii.adapter.sample.ra"). Check out if it works in your mapping, too.
    import java.security.Key;
    import java.security.KeyStore;
    import java.security.KeyStoreException;
    import java.security.NoSuchAlgorithmException;
    import java.security.PublicKey;
    import java.security.UnrecoverableKeyException;
    import java.util.HashMap;
    import java.util.Map;
    import javax.resource.ResourceException;
    import com.sap.aii.af.service.resource.SAPSecurityResources;
    import com.sap.aii.security.lib.KeyStoreManager;
    import com.sap.aii.security.lib.PermissionMode;
    public class XIKeystoreAccessor {
        private static final XITrace TRACE = new XITrace(XIKeystoreAccessor.class.getName());
        static XIKeystoreAccessor instance = null;
        SAPSecurityResources securityResources;
        KeyStoreManager keystoreManager;
        Map<String, KeyStore> keystores = null;
        private XIKeystoreAccessor() throws ResourceException {
         final String SIGNATURE = "XIKeystoreAccessor()";
         TRACE.entering(SIGNATURE);
         keystores = new HashMap<String, KeyStore>();
         securityResources = SAPSecurityResources.getInstance();
         try {
             keystoreManager = securityResources.getKeyStoreManager(PermissionMode.SYSTEM_LEVEL,
                  new String[] { "sap.com/com.sap.aii.adapter.sample.ra" });
         } catch (KeyStoreException e) {
             TRACE.catching(SIGNATURE, e);
             throw new ResourceException(e);
         TRACE.exiting(SIGNATURE);
         * Get a key from AS Java keystore
         * @param view
         * @param alias
         * @param password
         * @return
         * @throws ResourceException
        public Key getPrivateKey(String view, String alias, String password) throws ResourceException {
         final String SIGNATURE = "getPrivateKey()";
         TRACE.entering(SIGNATURE);
         KeyStore keystore = getKeystore(view);
         Key privateKey = null;
         try {
             privateKey = keystore.getKey(alias, password.toCharArray());
             if (privateKey == null) {
              throw new ResourceException("Key not found. alias=" + alias);
         } catch (KeyStoreException e) {
             TRACE.catching(SIGNATURE, e);
             throw new ResourceException(e);
         } catch (NoSuchAlgorithmException e) {
             TRACE.catching(SIGNATURE, e);
             throw new ResourceException(e);
         } catch (UnrecoverableKeyException e) {
             TRACE.catching(SIGNATURE, e);
             throw new ResourceException(e);
         TRACE.exiting(SIGNATURE);
         return privateKey;
        public PublicKey getPublicKey(String view, String alias) throws ResourceException {
         final String SIGNATURE = "getPublicKey()";
         TRACE.entering(SIGNATURE);
         KeyStore keystore = getKeystore(view);
         PublicKey publicKey = null;
         try {
             publicKey = keystore.getCertificate(alias).getPublicKey();
             if (publicKey == null) {
              throw new ResourceException("Key not found. alias=" + alias);
         } catch (KeyStoreException e) {
             TRACE.catching(SIGNATURE, e);
             throw new ResourceException(e);
         TRACE.exiting(SIGNATURE);
         return publicKey;
         * Get a keystore i.e. a view from AS Java
         * @param view
         * @return
         * @throws ResourceException
        public KeyStore getKeystore(String view) throws ResourceException {
         final String SIGNATURE = "getKeystore()";
         TRACE.entering(SIGNATURE);
         KeyStore keystore;
         try {
             if (keystores.containsKey(view) == true) {
              keystore = keystores.get(view);
             } else {
              keystore = keystoreManager.getKeyStore(view);
              if (keystore == null) {
                  throw new ResourceException("Keystore not found. view=" + view);
              keystores.put(view, keystore);
             TRACE.exiting(SIGNATURE);
             return keystore;
         } catch (KeyStoreException e) {
             TRACE.catching(SIGNATURE, e);
             throw new ResourceException(e);
        static public XIKeystoreAccessor getInstance() throws ResourceException {
         if (instance == null) {
             instance = new XIKeystoreAccessor();
            return instance;

  • Error in Java Mapping for Single XML conversion

    We are working on ABAP Proxy --> SAP PI 7.1 --> SOAP (Synchronous Scenario).
    (ECC -> PI -> Legacy CRM)
    Client has provided a WSDL with Single Node of XML and asking us to pass the whole structure as an single string along with all the nodes of data structure. To perform mapping we are using Java Mapping.
    Message which we are getting after Java Mapping:
    Input
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_SOReject_Sender xmlns:ns0="http://MTSINDIA/TC/SalesOrderReject">
       <ITEM>
          <sSlsOrderCode>1001</sSlsOrderCode>
          <sDlrCode>A250</sDlrCode>
          <sRejectReason>Z2</sRejectReason>
          <nCircleCode>2</nCircleCode>
       </ITEM>
    </ns0:MT_SOReject_Sender>
    Output
    <?xml version="1.0" encoding="UTF-8"?><MT_Trg xmlns:ns="urn:Test_File_to_File"><stringinp>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;ns0:MT_SOReject_Sender xmlns:ns0="http://MTSINDIA/TC/SalesOrderReject"&gt;&lt;ITEM&gt;&lt;sSlsOrderCode&gt;1001&lt;/sSlsOrderCode&gt;&lt;sDlrCode&gt;A250&lt;/sDlrCode&gt;&lt;sRejectReason&gt;Insufficient Stock Balance&lt;/sRejectReason&gt;&lt;nCircleCode&gt;2&lt;/nCircleCode&gt;&lt;/ITEM&gt;&lt;/ns0:MT_SOReject_Sender&gt;</stringinp></MT_Trg>
    Is ther any way from which we can convert &gt; as u201C>u201D and &lt; as u201C<u201D.  Required result is as follows
    Required Output
    <?xml version="1.0" encoding="UTF-8"?><MT_Trg xmlns:ns="urn:Test_File_to_File"><stringinp><?xml version="1.0" encoding="UTF-8"?><ns0:MT_SOReject_Sender xmlns:ns0="http://MTSINDIA/TC/SalesOrderReject"><ITEM><sSlsOrderCode>1001</sSlsOrderCode><sDlrCode>A250</sDlrCode><sRejectReason>Insufficient Stock Balance</sRejectReason><nCircleCode>2</nCircleCode></ITEM></ns0:MT_SOReject_Sender></stringinp></MT_Trg>
    We are using following Java Code for the same.
    import java.io.BufferedReader;
              import java.io.FileInputStream;
              import java.io.FileOutputStream;
              import java.io.InputStream;
              import java.io.InputStreamReader;
              import java.io.OutputStream;
              import java.util.Map;
              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.Element;
              import org.w3c.dom.Document;
              import org.w3c.dom.Text;
              import com.sap.aii.mapping.api.*;
              import com.sap.aii.mapping.api.StreamTransformation;
    public class SingleStr implements StreamTransformation{
          * @author user
          * To change the template for this generated type comment go to
          * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
                    public static void main(String args[]) throws Exception {
                FileInputStream inFile =
                 new FileInputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Input.XML");
                FileOutputStream outFile =
                 new FileOutputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Output.XML");
                 SingleStr xml = new SingleStr();
                xml.execute(inFile, outFile);
                System.out.println("Success");
               public void setParameter(Map param) {
                Map map = param;
               public void execute(InputStream in, OutputStream out)
                throws com.sap.aii.mapping.api.StreamTransformationException {
                try {
                 //************************Code To Generate The XML Parsing Objects*****************************//    
                 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                 DocumentBuilder db = dbf.newDocumentBuilder();
                 TransformerFactory tf = TransformerFactory.newInstance();
                 Transformer transform = tf.newTransformer();
                 //Document doc = db.parse(in);
                 Document docout = db.newDocument();
                 Element root = docout.createElement("MT_Trg");
                 root.setAttribute("xmlns:ns","urn:Test_File_to_File");
                 docout.appendChild(root);
                 Element stringinp = docout.createElement("stringinp");
                 root.appendChild(stringinp);
                 BufferedReader inpxml = new BufferedReader(new InputStreamReader(in));
                 StringBuffer buffer = new StringBuffer();
                 String line="";
                 while ((line = inpxml.readLine()) != null)
                 buffer.append(line);
                 String inptxml=buffer.toString();
                 Text srcxml = docout.createTextNode(inptxml);
                 stringinp.appendChild(srcxml);
                 DOMSource domS = new DOMSource(docout);
                 transform.transform((domS), new StreamResult(out));
                 } catch (Exception e) {
                   System.out.print("Problem parsing the file: " + e.getMessage());
                   e.printStackTrace();
    Please help!!

    We are using following Java Code for the same.
    import java.io.BufferedReader;
              import java.io.FileInputStream;
              import java.io.FileOutputStream;
              import java.io.InputStream;
              import java.io.InputStreamReader;
              import java.io.OutputStream;
              import java.util.Map;
              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.Element;
              import org.w3c.dom.Document;
              import org.w3c.dom.Text;
              import com.sap.aii.mapping.api.*;
              import com.sap.aii.mapping.api.StreamTransformation;
    public class SingleStr implements StreamTransformation{
               public static void main(String args[]) throws Exception {
                FileInputStream inFile =
                 new FileInputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Input.XML");
                FileOutputStream outFile =
                 new FileOutputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Output.XML");
                 SingleStr xml = new SingleStr();
                xml.execute(inFile, outFile);
                System.out.println("Success");
               public void setParameter(Map param) {
                Map map = param;
               public void execute(InputStream in, OutputStream out)
                throws com.sap.aii.mapping.api.StreamTransformationException {
                try {
                 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                 DocumentBuilder db = dbf.newDocumentBuilder();
                 TransformerFactory tf = TransformerFactory.newInstance();
                 Transformer transform = tf.newTransformer();
                 //Document doc = db.parse(in);
                 Document docout = db.newDocument();
                 Element root = docout.createElement("MT_Trg");
                 root.setAttribute("xmlns:ns","urn:Test_File_to_File");
                 docout.appendChild(root);
                 Element stringinp = docout.createElement("stringinp");
                 root.appendChild(stringinp);
                 BufferedReader inpxml = new BufferedReader(new InputStreamReader(in));
                 StringBuffer buffer = new StringBuffer();
                 String line="";
                 while ((line = inpxml.readLine()) != null)
                 buffer.append(line);
                 String inptxml=buffer.toString();
                 Text srcxml = docout.createTextNode(inptxml);
                 stringinp.appendChild(srcxml);
                 DOMSource domS = new DOMSource(docout);
                 transform.transform((domS), new StreamResult(out));
                 } catch (Exception e) {
                   System.out.print("Problem parsing the file: " + e.getMessage());
                   e.printStackTrace();
    Please help!!

  • 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

  • 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

  • Java Mapping - Not able to compile .Java file

    Hi Experts,
    I am working with a sample scenario which involves Java Mapping. For this I created MappingClass.java file, After compiling the .Java file .Jar file would be used for Java Mapping by using Imported Archives.
    After compiling the MappingClass.java file, I am getting the errors as below.
    --> Java errors after compilation
    C:\j2sdk1.4.2_13\bin>javac MappingClass.java
    MappingClass.java:4: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.AbstractTrace;
                                   ^
    MappingClass.java:5: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    --> End of java errors
    In the MappingClass.java file, I had given followed imports.
    import java.util.*;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    Could some one please guide me to resolve this issue.
    Thanks in advance.
    ..Sree

    Hi
    I had copied " aii_map_api.jar " file in my Java Class path folder.. i.e " C:\j2sdk1.4.2_08\bin "     AND    " C:\j2sdk1.4.2_08\lib " folders too.. and even in C:\ i.e Root Drive also.
    After trying to Compile my java file (ex : MappingClass.java), still I am getting the errors.
    Errors shown as below.
    --> Errors
    C:\mytest>javac MappingClass.java
    MappingClass.java:2: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.AbstractTrace;
                                   ^
    MappingClass.java:3: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.StreamTransformationConstants;
                                   ^
    MappingClass.java:6: cannot resolve symbol
    symbol  : class AbstractTrace
    location: class MappingClass
        private static AbstractTrace trace = null;
                       ^
    MappingClass.java:12: cannot resolve symbol
    symbol  : class AbstractTrace
    location: class MappingClass
            trace = (AbstractTrace)inputparam.get(
                     ^
    MappingClass.java:13: cannot resolve symbol
    symbol  : variable StreamTransformationConstants
    location: class MappingClass
                       StreamTransformationConstants.MAPPING_TRACE );
                       ^
    5 errors
    --> End of Errors
    Could some one please guide me to resolve this issue.
    Thanks in advance.
    ..Sree

  • Accessing a File in a Java Mapping

    Hi,
    I am accessing one Random Access File through Java Mapping Program. This is working fine in Eclipse.
    But when I imported that jar file to IR, it is throwing FileNotFound Exception while trying to test through Interface Mapping.
    Actually it is not showing any error message but by research I understood that. Can any one please help me in this regard?
    One more thing, I used the same scenario for other interface. It is working fine.
    Please help me to chase this mistery.
    Thanks,
    Yogi.

    Hi,
    I think I am giving relative path only not direct path. I am just mentioning the path from my proj name. I am not specifying any local directories. For your Information, I am mentioning the path like below:
    "ProjectName/SomeName/File_Name.txt"
    Thanks,
    Yogi.

  • Java Mapping (not UDF) and Adapter-Specific Message Attributes

    Hello everybody,
    is it possible to create an Adapter-Specific Message Attributes in a java Mapping?
    I found in the SAP Help that the API com.sap.aii.mapping.api.DynamicConfiguration allows only to read, change or delete the attributes.
    best regards.
    Adnane Elgoute

    Hi,
    try the follwoing code
    import com.sap.aii.mapping.api.*;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.HashMap;
    import java.util.Map;
    public class JavaProgram
        implements StreamTransformation
        public JavaProgram()
        public void setParameter(Map map)
            param = map;
            if(param == null)
                param = new HashMap();
        public void execute(InputStream inputstream, OutputStream outputstream)
            try
                DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get("DynamicConfiguration");
                DynamicConfigurationKey dynamicconfigurationkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
                String s = dynamicconfiguration.get(dynamicconfigurationkey);
             //Your logic
            catch(Throwable throwable)
                throwable.printStackTrace();
        private Map param;

Maybe you are looking for

  • Session timeout problem with CCA

    I have developed a Client applicaiton in ASP.Net 2005 using the SOAP Api provided in Oracle CCA 8.1.3 The System details are as under: Product – Oracle CCA 8.1.3 Server on Windows 2003 Server – Standard Edition Web Server – BEA Weblogic 10g3 Database

  • I am receiveing error while creating Z table: Entry in table TAORA missing

    Hi Experts, I am receiving "Entry in table TAORA missing" while creating Z table. Please help Edited by: N_niki on Jun 11, 2011 9:22 AM

  • RFC Error While Creating Technical System in SLD As Web AS ABAP

    Hi Experts, I was Posted This Thread in Most of the Modules like ABAP, Exchange Infrastructure. But there is No Such Right Answers . So Finally I Got Idea to Post it in SAP NetWeaver Administrator Module. For Creating a TS for  Web AS ABAP For R/3 in

  • Multiple XMP Metadata into Multiple PDF

    Hi, recently I've been trying to change the xmp metadata of multiple pdf, I already tried using Bridge and some other 3rd Party Programs but the issue is that all of those solutions just change the same information into multiple files, and what I wan

  • Unable to open a link document

    Dear All, In test workbench , in the test case attributes tab there is an option for opening the linked document which is linked to test case which is not working for us and we are getting following error. Error message. no info object found for the