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

Similar Messages

  • Java mapping & namespace issue

    Hello,
    I am doing a java mapping from a flat file to an IDOC. After the document is mapped succesfully I call an RFC via the Adapter. When monitoring the adapter I get the error:
    com.sap.aii.af.rfc.RfcAdapterException: failed to read funtionname from XML document: missing namespace declara
    so I added the namespace reference to my java mapping to look like this :
    <ns0:IDOC_INBOUND_ASYNCHRONOUS xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
    But when I test my java mapping in the builder (interface mapping) the namespace xmlns="urn:sap-com:document:sap:rfc:functions" is added to my above ns0:IDOC_INBOUND_ASYNCHRONOUS tag. The consequence is that while mapping in the integration engine the "ns0" prefix is then removed and I get the error:
    Delivery of the message to the application using connection AFW failed, due to: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: functiontemplate from repository was.
    Any help or sample code resolving the namespace issue is welcome.
    Frank

    Hi Frank,
    I am getting the same error message. You fixed yours. Can you help me with mine. The error message is
      " Delivery of the message to the application using connection AFW failed, due to: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: functiontemplate from repository was ."
    I am trying to send data to SAP SRM4.0 from SAP R/3 using SAP XI. XI content is delivered by SAP.
    The message is sent from R/3 to XI successfully and the XML monitor does not show any errors in XI . But the messages does not show up in SRM.
    Thanks
    Kishore.

  • Multi-Mapping runtime issue

    Hi, Friend:
    We are using BPM to collect two type of message (Msg1 and Msg2) and map to target message (Msg3),
                              ------Receive1-------
    Start --Fork(start)                            Fork(stop) ---Transformation--Send
                              ------Receive2-------
    When we created all the messages from scratch, the process works, the process worked.
    After we use external definition (xsd), it always fails on transformation step.
    However,if we put the payload to test in message mapping, it success.
    Any thoughts ?
    Thanks
    Liang

    Hi, Praba:
    We have tested in both multi-mapping, and also interface mapping by using the same payload the causes error in runtime, they are all fine.
    The error happens on tranformation step: some nodes have very simple mapping like one to one, it can not create target node (see attached part of trace).
    Once we change the complained node mapping from a constant value, the next test shows next target node can not be produced.
    If the node is attribute, only required attribute complains, if the node is element, the node with min occurence of 1 complains
    <?xml version="1.0" encoding="utf-8" ?>
    - <MappingTrace>
      <Trace level="1" type="T">Mapping-Namespace:http://xmlfile2xmlfile</Trace>
      <Trace level="1" type="T">Mapping-Name:Im_PBC_Audit</Trace>
      <Trace level="1" type="T">Mapping-SWCV:64968F80768C11DCC184FCEB0A01071F</Trace>
      <Trace level="1" type="T">Mapping-Step:1</Trace>
      <Trace level="1" type="T">Mapping-Type:JAVA</Trace>
      <Trace level="1" type="T">Mapping-Program:com/sap/xi/tf/_PBC_Request_Response_AuditMapping_</Trace>
      <Trace level="3" type="T">Multi mapping required.</Trace>
      <Trace level="3" type="T">Creating Java mapping com/sap/xi/tf/_PBC_Request_Response_AuditMapping_.</Trace>
      <Trace level="3" type="T">Load 64968f80-768c-11dc-c184-fceb0a01071f, http://xmlfile2xmlfile, -1, com/sap/xi/tf/_PBC_Request_Response_AuditMapping_.class.</Trace>
      <Trace level="3" type="T">Search com/sap/xi/tf/_PBC_Request_Response_AuditMapping_.class (http://xmlfile2xmlfile, -1) in swcv 64968f80-768c-11dc-c184-fceb0a01071f.</Trace>
      <Trace level="3" type="T">Loaded class com.sap.xi.tf._PBC_Request_Response_AuditMapping_</Trace>
      <Trace level="2" type="T">Call method execute of the application Java mapping com.sap.xi.tf._PBC_Request_Response_AuditMapping_</Trace>
      <Trace level="1" type="T">RuntimeException during appliction Java mapping com/sap/xi/tf/_PBC_Request_Response_AuditMapping_</Trace>
      <Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: RuntimeException in Message-Mapping transformation: Cannot produce target element /ns0:Messages/ns0:Message1/ns1:BenefitEnrollment. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
    Thanks
    Liang

  • 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

  • Java Mapping Issue

    Hi,
    I'm new to JAVA mapping and I'm having an issue which I can't get resolved :
    When I execute my mapping I get :
    <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">LINKAGE_ERROR</SAP:Code>
      <SAP:P1>XIFileNameMapClass</SAP:P1>
      <SAP:P2>http://notimportant.com/xi/SOOFT</SAP:P2>
      <SAP:P3>068fe9b0-44d1-11db-c69d-ee989e43162e</SAP:P3>
      <SAP:P4>-1</SAP:P4>
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Incompatible class versions (linkage error)</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    I'm using eclipse for the java class and I have choosen several jre versions to create the .jar file but all lead to the same error.
    I had copied the required aii_map_api.jar.jar from xi box to my local project directory and added it as an external .jar to my project.
    But since I new to JAVA and unsure on what exactly is going into the jar and what not.
    Is it important with which jre version you build the java class ? ( Xi is running on 1.4.2_12 ) I tried first with 1.5.0_06 and then with 1.4.2_9 and then 1.4.2_13 all with the same result.
    I do this by adding a different jre to the properties of my project. And then I export to the .jar file . Is that enough ? ( I was expecting something like a 'build' option somewhere but I can't find that in eclipse )
    When I imported the archive in XI, I also see a .Classpath , a .project , SAP_AG_G.RSA and a SAP_AG__G.SF file.
    This reminds me of those ugly .dll incompatibilities which I had hoped not occurring with JAVA...:(
    Any ideas ?
    PS We are on XI 7.0 SP8 ( so the older note 755302 is not relevant )

    Hi all,
    I did understand that I had something todo with different versions ( as I started to make a first attempt with version jre 1.5 and then with other versions )
    But somehow I apparently couldn't get my .jar file to be compiled to a 1.4.2_xx
    ( although I tried numerous settings in the Eclipse build path etc...)
    Finally, I removed the 1.5 version and started from scratch using jre 1.4.2_10.
    And now it works OK !
    I'm sure you can configure Eclipse correctly to generate 1.4 compatible jar files ( even when running itself on 1.5 or above ) but I must have missed the right combination of settings ( as I said I'm new in Java / Eclipse....)
    regards
    Dirk

  • Issue in Java Mapping

    Hi
    I 'm doing Java mapping implementation in one interface. Where I have tested mapping through console, it is working fine. However,when i upload .jar file into XI server, there it has been tested with unit test. It fails because of " saying one xxxxx.class file is not found". Infact, it is there in the jar. I have cross check in jar file that was uploaded to XI. Please suggest me how do i approach this issue?
    Thanks

    Hi Abhishek..
    Thanks for u r response.
    I suppose, Java version doesn't impact on package access. Since as we do for normal java class which would be bound as package includes in same jar file that we had uploaded in XI server. However, we are accessing the class irrespective of standard jar.
    In simple, as we normally can create custom jar file which we could put some class files in the same jar.
    pLZ Advice me further.
    Thanks once again.

  • Java Mapping - add external jar for runtime use

    Hi,
    I have implemented a java mapping which executes an XSLT transformation on the input XML. This way I can control (I hope) what XSLT processor is used, as I want to use the SAXON XSLT processor. The java mapping executes fine locally in NWDS.
    But when executed runtime I get the following error in default_trace and the message stops in Integration Engine:
    javax.xml.transform.TransformerFactoryConfigurationError: Provider net.sf.saxon.TransformerFactoryImpl not found
    In my java mapping I have set the following:
    System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
    The TransformerFactoryImpl class is implemented in saxon9.jar.
    Where do I store the saxon9.jar on the server so that it will find it during execution?
    Any hints are most welcome!
    Br,
    Kenneth

    Hi Kenneth,
                          First of all java mapping procedure has the capacity to transform XML using SAX or DOM parser directly. I am not sure as to why you need "SAXON XSLT processor" for the purpose.
                           Now coming to your question  "Where do I store the saxon9.jar on the server so that it will find it during execution?"
    In NWDS import the jar file saxon9.jar within your package, where you have written the source code. This you can do using File->import ->(ZIP or jar file).    Before you import slect the package or folder where you want to import the jar file. Once jar file import is complete execute the code once, see if its running properly. Then choose file->export and select all *.java and *.class files in your package. Save this under one filename say package.jar.
    Finally import this jar file in PI server by usual methods.
    Hope this solves your problem
    regards
    Anupam

  • Issue with java mapping in a multi-mapping scenario

    Hi
        We have  a 1:n multiple mapping scenario in XI and the source is R3 proxy and target side is files. So, creating multiple file from a single message from R3 .
    R3 --> XI --> Multiple files
    Structure of the output of the multi-mapping is
    - <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
    - <ns0:Message1>
    <Transaction>
    </Transaction>
    <Transaction>
    </Transaction></ns0:Message1>
    </ns0:Messages>
    wherein each Transaction node represents a file.
    Now, we need to introduce a constant /string like
    <!DOCTYPE Transaction PUBLIC \"-//XXXXXX//DTD BatchReceiptAuthorization//EN\" \"http://dtd.XXXXXXX.com/dtds/ReceiptAuthorization.dtd\">
    on each of the files at the very beginning - i.e within each transaction node , in the above structure, we need the above DTD string to be written.  To do this, we added a java mapping as the second mapping after the message mapping that creates this string. Is this the right approach and would it produce what we are expecting ?
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.util.Map;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.AbstractTrace;
    public class ModifyRootAndDelay implements StreamTransformation {
         AbstractTrace myTrace;
    public void execute(InputStream input, OutputStream output) throws StreamTransformationException {
              try{
                   BufferedReader reader = new BufferedReader(new InputStreamReader(input));
                   String NameSpacePrefix = "<!DOCTYPE Transaction PUBLIC \"-//innotrac//DTD BatchReceiptAuthorization//EN\" \"http://dtd.innotrac.com/dtds/ReceiptAuthorization.dtd\">";
                   String sLine = null;
                   StringBuffer XmlMsg= new StringBuffer();
                   String Result,PayloadBody;
                   int indexOfFirst;
                   while ((sLine = reader.readLine()) != null) {
                        XmlMsg.append(sLine);
                   String StartingTag = XmlMsg.toString();
                   indexOfFirst = StartingTag.indexOf("<MerchantID>") ;
                   PayloadBody=new String(XmlMsg.substring(indexOfFirst));
                   Result=NameSpacePrefix.concat(PayloadBody);
                   output.write(Result.getBytes());
              /*     Thread.sleep(200000); */
              }catch(Exception e){
                   myTrace.addWarning("Exception raised in the JavaMapping:modifyNamespace.java""\n The Exception Message: " e.getMessage());
                   throw new RuntimeException(e.getMessage()) ;
            }     public void setParameter(Map param) {
              myTrace = (AbstractTrace) param
                        .get(StreamTransformationConstants.MAPPING_TRACE);

    Hi XI Gurus
                       In my scenario, I sent the inputstream that is being passed to the Java execute method - to trace and I see that the whole of the xml file - as shown below  - which is the output of message mapping ( from the first mapping step ) in sent to the execute method of the java mapping a single call
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
    <ns0:Message1>
    <Transaction> </Transaction>
    <Transaction> </Transaction>
    </ns0:Message1>
    <ns0:Messages>
    So, I modified Java mapping program to look for multiple occurences of <Transaction> tag and prefix them with my constant DTD Literal - which is the primary reason , why I had to use Java mappings after the message mapping.
    Now, I get an error is XI- SXMB_MONI
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="MAPPING" />
      <SAP:P1>unexpected symbol; expected '<', '</', entity refe</SAP:P1>
      <SAP:P2>rence, character data, CDATA section, processing i</SAP:P2>
      <SAP:P3>0</SAP:P3>
      <SAP:P4>113</SAP:P4>
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>The exception occurred (program: CL_XMS_MAIN===================CP, include CL_XMS_MAIN===================CM00A, line: 609)</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Should I create multiple outputs - as many as the numberof target split files ( of type outputstream ) from the execute method in the java program ?

  • XSLT & JAVA Mapping issue.

    is there any situation,
    where we should definately go for XSLT mapping..
    where we should definately go for JAVA mapping..
    can anyone brief me plz....
    Cheers,
    Raghavesh

    No hard and fast rules.
    There never can be specific rules.
    1. Java Mapping should be used when the input is NON XML for sure. As the input is a InputSTream, you can convert it to a string and do the needful programmic logic etc.
    2. XSL can be used with HTML source etc.
    Regards
    Bhavesh

  • Handling Character Entities - Java Mapping Issue

    Hi Experts,
        I need to replace the character entities in my input XML. But, the problem is the java mapping I've written isn't replacing  the character entities as expected.  For example if my input XML  contains <NAME>&><XYZ</NAME>, then the ouput is <NAME>&amp:&gt:<0001&lt:/NAME>, whereas it should be <NAME>&amp:&gt:&lt:0001</NAME>.
    Note: I've used : instead of ; just to show it properly SDN.
    Can any of you share the code for the same if you've used it already?
    Thanks a lot in advance.
    Regards,
    Hussain.

    Hi Pooja,
        Thanks for your prompt reply.
    Are you trying to use the java mapping just to handle the character entities or your interface itself only has a java mapping?
                   - I'm using Java Mapping just to handle the character entities. Say my input XML looks like
    <?xml version="1.0" encoding="UTF-8"?>
    <resultset>
    <row>
    <ID>&<1</ID>
    <MESSAGE><![CDATA[<?xml version="1.0" encoding="UTF-8" ?><LGORT>&<0001</LGORT>]]></MESSAGE>
    </row>
    </resultset>
    I need to replace &< in <ID> to &amp:&lt: and similarly for CDATA <LGORT>&amp:&lt:0001</LGORT> before I process it in XI. In my java mapping I read the whole XML as string (line by line as mentioned below) and try to replace the character entities using some logic, which isn't working properly.
    StringBuffer buffer = new StringBuffer();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
    for (String lineRead = reader.readLine(); lineRead != null; lineRead = reader.readLine()) {
           buffer.append(lineRead);
    I've also checked the thread mentioned by Srinivas. But, StringEscapeUtils.escapeXml() would replace all the character entities like &lt:?XML... , which would result in an invalid xml...
    Please suggest.
    Thanks,
    Hussain.

  • Empty file, java mapping issue

    Hello,
    does anyone have an ide how to create java mapping to create empty file on FTP?
    Why this code always send NUL character = 1byte and not 0 byte as needed?
    public void execute(InputStream in, OutputStream out) throws StreamTransformationException {
    out = null;

    try 1 thing...
    run ur code for some standalone file.
    create a file at ur local harddisk and check out its size..
    i had tried creating such a file using the code below....
    it is creating a 0 byte file successfully.
    public class TestCode {
         public static void main(String ags[]){
         try{
         TransformerFactory tf = TransformerFactory.newInstance();
         Transformer transform = tf.newTransformer();
         FileOutputStream out;
         out = new FileOutputStream("c:
    OutTestCode.xml");
         transform.transform(null, new StreamResult(out));
         } catch (FileNotFoundException e1) {
              e1.printStackTrace();
         } catch (TransformerConfigurationException e) {
              e.printStackTrace();
         } catch (TransformerException e) {
              e.printStackTrace();

  • Mapping runtime perfermance issue.

    Hi all
    I have an interface that runtime process sometimes fast sometimes slow.In case of low process ,I figured out the mapping runtime took a lot of time.So i would like to know what factors can lead to the mapping runtime low performance?
    thanks in advance.
    Brand

    Hi
    Thanks to reply to this.
    but my mapping don't have  a huge volume data. it is just 1KB.
    in addition,i tried to run 3 times,sometimes very fast,and sometimes very low... any other cause else ?
    thanks

  • Java mapping in ccBPM works in PI 7.0 but fails in PI 7.1

    Hi guys,
    at the moment we are upgrading form SAP PI 7.0 to SAP PI 7.11.
    In a scenario for processing of incoming orders we use an ccBPM.
    In this ccBPM there is an mapping where the original xml document of the order are combined with some
    additional information form an web service (multi mapping 2 => 1)
    The result of this mapping is processed further to create an sales order in the backend.
    The multi mapping an java mapping is used.
    Now we are testing the scenario with PI 7.11 and it fails at this mapping step.
    in the workflow log following error occurs.
    An exception with the type CX_ST_MATCH_ELEMENT occ urred, but was neither handled locally, nor de
    Message no. W8899
    I tested the same message on out SAP PI 7.0 system and the whole ccBPM works well.
    When I extract the 2 messages from workflow log and paste them into the test tab of the operation mapping of Enterprise Service Builder of SAP PI 7.11, surrounding by the envelope used by multi mappings
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
       <ns0:Message1>
                   XML MESSAGE 1
       </ns0:Message1>
       <ns0:Message2>
                   XML MESSAGE 2  
       </ns0:Message2>
    </ns0:Messages>
    the mapping works without error, but at runtime it fails, throwing the error mentioned above.
    What could be the reason for this error?
    Does the multi mapping change in PI 7.11 at runtime?
    Could it be a problem parsing the multi message?
    Any help appreciated.
    Kind regards
    Jochen

    Hi Raja,
    thanks for your suggest.
    I know this issue, the java class files are compiled using jdk 1.5.
    We made some more tests.
    e.g. created an dummy ccBPM with two mappings, one two spilt the incoming message in two messages (graphical message mapping) and one to merge this two messages to one message again (java mapping)
    the mapping works at design time on test tab, but fails with the same error at rumtime.
    Also we tested one single operation mapping with this two mappings (split via graphical mapping and merge via java mapping)
    This works also at design time but fails at runtime with a similar error shown in smq2
    The error message is Error ST_MATCH_FAIL occured. P1=element-start P2=M
    we tried to add the whole incoming message to the trace by
    getTrace().addWarning()
    but an trace object is never created in for this step in the workflow log.
    it seem whether you can not add trace messages using the command or that the error occures before this command will be used.
    Kind regards
    Jochen

  • Value Mapping replication issue

    Hi  PI Experts,
    I am working on the Value mapping replication scenario using Z-table created in R/3 system.
    I have configured the value mapping Replication Out Abap proxy.
    I am getting the following error :
    Audit Log for Message: 4d404b41-39e4-0083-e100-80008b3557e6
    Time Stamp Type Description
    2011-01-27 07:56:19 Information The message was successfully received by the messaging system. Protocol: XI URL: http://gendevhrcx51.unix.appliarmony.net:54000/MessagingSystem/receive/JPR/XI Credential (User): PIAPPLUSER
    2011-01-27 07:56:19 Information Using connection JPR. Trying to put the message into the receive queue.
    2011-01-27 07:56:19 Information Message successfully put into the queue.
    2011-01-27 07:56:19 Information The message was successfully retrieved from the receive queue.
    2011-01-27 07:56:19 Information The message status was set to DLNG.
    2011-01-27 07:56:19 Information Java Proxy Runtime (JPR) accepted the message.
    2011-01-27 07:56:19 Error JPR could not process the message. Reason: Cannot locate proxy bean ValueMappingApplication.
    2011-01-27 07:56:19 Error Delivering the message to the application using connection JPR failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing inbound message. Exception: Cannot locate proxy bean ValueMappingApplication.
    2011-01-27 07:56:19 Information The message status was set to WAIT.
    2011-01-27 07:56:19 Information The asynchronous message was successfully scheduled to be delivered at Thu Jan 27 08:01:19 CET 2011.
    I have followed the threads :
    1) /people/udo.martens/blog/2009/04/03/value-mapping-replication-scenario
    2) ValueMappingReplication in PI 7.1 
    3) How to Perform Value Mapping u2013 A Walkthrough ->  Sarath Chandra Kandadai
    which had similar issue but could not make any headway.
    Questions :
    1) Are there any specific PIAPPLUSER authorizations required ,I have configured the CC as per the 3rd thread.
    2) There is an issue with SLD access when I look at the JPR monitoring,could be the possible reason.
      SLD access SLD host:port = gendevhrcx51:54000
    Error getting JPR configuration from SLD. Exception: No entity of class SAP_BusinessSystem for DHX.SystemHome.gendevhrcx51 found
    No access to get JPR configuration
    I have refered to the Note : 809420 and asked the basis team to look into this.
    I am running out of ideas ,request you guys to help on this issue.
    Thanks
    -Alok

    Hi Alok,
    i have similar error. Here the error:
    30.12.2013 20:40:17.789
    Information
    Java Proxy Runtime (JPR) accepted the message.
    30.12.2013 20:40:17.871
    Error
    JPR could not process the message. Reason: No remote bean found for reference of class com.sun.proxy.$Proxy352.
    30.12.2013 20:40:17.876
    Error
    Delivering the message to the application using connection JPR failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing inbound message. Exception: No remote bean found for reference of class com.sun.proxy.$Proxy352.
    30.12.2013 20:40:17.911
    Information
    The asynchronous message was successfully scheduled to be delivered at Mon Dec 30 20:45:17 CET 2013.
    I have registered the inbound interfaces:
    http://sap.com/xi/XI/System#ValueMappingReplication = localejbs/sap.com/com.sap.xi.services/ValueMappingApplication:valueMappingReplication
    http://sap.com/xi/XI/System#ValueMappingReplicationSynchronous = localejbs/sap.com/com.sap.xi.services/ValueMappingApplicationSynchronous:valueMappingReplicationSynchronous
    2 interfaces found
    But somehow the bean is not found and gave me the error :
    JPR could not process the message. Reason: No remote bean found for reference of class com.sun.proxy.$Proxy352.
    Can you tell me in detail what you have done to resolve the problem? I send the test data from soapui using the outbound interface ValueMappingReplicationOut provided by the content in SAP BASIS 7.11.
    Thanks,
    Ly-Na

  • Mapping Runtime failing for all messages

    Hi Experts,
    We are facing an issue with our mapping runtime in the integration engine. Any message going through the integration engine is giving a mapping error as shown below (for example):
    LinkageError during appliction Java mapping com/sap/xi/tf/_MessageAcknowledgement_to_Order_Responce_ERP_Async_In_ Thrown: java.lang.NoClassDefFoundError: com/sap/aii/utilxi/threadutil/ThreadUtil_map
    LinkageError during appliction Java mapping com/sap/xi/tf/_MM_Jdbc_test_ Thrown: java.lang.NoClassDefFoundError: com/sap/aii/utilxi/threadutil/ThreadUtil_map
    The complete trace of the error is attached here.
    The interfaces were working and messages were flowing normally. As part of our SAP HCM to SuccessFactors implementation, we configured 3 interfaces and even this was working fine. To solve a specific issue during implementation, we applied the following SAP notes:
    1869807 - SFSFI: PI Content Correction for HTTP Cookie Handling
    Pre-requisite for above note - 1838921 - Multiple cookies in HTTP Header
    After this, messages of all the interface in this system are failing with the above issue (LinkageError).
    Please guide us in resolving this issue.
    Thanks & Regards
    Sudheer

    Hi All,
    In addition to the above, if mapping is tested within ESR there is no issue. The problem is happening only during runtime.
    BTW, When we applied the note 1838921 we upgraded the Adapter Framework from SP09 to SP12.
    Could this be an issue?
    Regards,
    Sudheer

Maybe you are looking for