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.

Similar Messages

  • 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

  • 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 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

  • 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 ?

  • Namespace missing in java mapping DOM ?

    Hi,
    I am creating java mapping using DOM, but why i cannot create a namespace using this code ?
    Document targetDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    // create source and result wrappers and perform transformation
    DOMSource source = new DOMSource(targetDoc);
    StreamResult result = new StreamResult(outputStream);  
    transformer.transform(source, result);
    expected result in xml :
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Vendor_SQL xmlns:ns0="urn:sap-com:atp:ABC40:base">
    </ns0:Vendor_SQL>
    result :
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Vendor_SQL>
    </ns0:Vendor_SQL>
    Please advise whether i was missing any other required step ?
    Note : testing using NWDS 7.0 SP 17
    Thank You and Best Regards
    Fernand

    Hi Lesmana,
    Can you change the second line in the code like below and give a try::
    Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("ns1:urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));
    Regards,
    ---Saish

  • 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 to override namespace prefix (startPrefixMapping)

    Does anyone have an example of using a Java Map to override the default XI namespace prefix. The method startPrefixMapping looks like it might do the job but I can't find any example of how this works.

    You can use the Anonymizer Module Processor.
    In your adapter, go to the "Modules" tab, than insert a new entry <b>before</b> the default adapter module processor. Enter module name <b>localejbs/AF_Modules/XMLAnonymizerBean</b> and <b>Local Enterprise Bean</b> type. In the parameters tab, enter parameter <b>anonymizer.acceptNamespaces</b> and parameter value <b>'<namespace>' <prefix></b>. You can enter more than one namespace, like in <b>'<namespace1>' <prefix1> '<namespace2>' <prefix2></b>.
    Note that your namespace must be inside apostrophes by default. If instead you want to use quotes to define the namespace, you must use another parameter before the one above: parameter name <b>anonymizer.quote</b> and in the value enter a single quote <b>"</b>.
    To define an empty prefix (meaning, that namespace is the default namespace) use '' (two apostrophes) instead of <prefix> (or "" (two quotes), if you have used anonymizer.quote).
    Check SAP Note 880173 for more information.
    Regards,
    Henrique.

  • How to replace namespace tag with new value using -JAVA MAPPING

    Hi Guys,
    I need to replace namespace Tag in Target xml with a new value.
    For Eg: My namespace Tag is - <ns0:TestHeader xmlns:ns0="http://0020.TestHeader.SS.com">
    I want My target xml to have value- <ns0:TestHeader>
    How can i achieve it using JAVA mapping?
    Can you provide me the code to do so.

    Sarjana,
    Not well-formed XML is only possible by Java Mapping. Please use below replace logic in Java map.
    inputContent.replaceAll("<ns0:TestHeader xmlns:ns0=\"http://0020.TestHeader.SS.com\">", "<ns0:TestHeader>");
    Link1, Link2.

  • 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();

  • XSLT Mapping: Namespace for prefix 'ns0' has not been declared

    Hello, I am working on a synchronous SOAP call and having some trouble with the response message. The web service has its own namespace and I am trying to convert this to my custom data type in PI. PI wants the message to be in format of having ns0 prefix and namespace like we have defined (http://foo for example).
    I have an XSLT mapping (see below) which works fine with my test response payload (pulled from SXMB_MONI source) on this online XSLT test site:
    http://www.freeformatter.com/xsl-transformer.html
    However when I import this archive to PI and test with operation mapping it always says "Namespace for prefix 'ns0' has not been declared."
    This is very confusing because when I test it online, I see both prefix and namespace declaration perfectly. Is there a way to see the results in the PI test tool? After this XSLT java error it doesn't give me the output even in Trace Level All mode.
    Please advise on this issue or if you know an easier way (such as altering my datatype/message type to match the inbound SOAP message). I tried working with the 3rd party WSDL but the response message types show a different root level node than what PI is receiving so I gave up to make my own matching datatype. I just have to solve this last inbound namespace issue and should be finished.
    FYI I have refreshed all PI caches and activated all objects.
    Thanks for your ideas!
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:ns0="http://foo"
      <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
      <xsl:template match="@* | node()">
        <xsl:copy>
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
      <xsl:template match="/*">
        <xsl:element name="ns0:{local-name()}">
          <xsl:apply-templates select="@* | node()" />
        </xsl:element>
      </xsl:template>
      <xsl:template match="/">
        <xsl:element name="{local-name()}">
          <xsl:apply-templates select="@* | node()" />
        </xsl:element>
      </xsl:template>
    </xsl:stylesheet>

    Some additional info, here is an example payload which goes through the XSLT mapping perfectly, but in PI I get the error about missing ns0 declaration.
    XML input:
    <bar xmlns='http://irrelevantnamespace'
    xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:xsd='http://www.w3.org/2001/XMLSchema'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    <foo/>
    </bar>
    XSLT mapped output using test tool and XSL above:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:bar xmlns:ns0="http://foo">
       <foo />
    </ns0:bar>

  • Message splitting using java mapping and BPM

    Hi all,
    I have a PLAIN FILE to IDOC Scenario.
    We decide to use javamapping instead of message mapping because we have several hierachical structures.
    We has more than one IDOC for file. And the mapping it's unable to detect the another header and create it at XI.
    I had seen:
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    "XI: IDOC bundling - the "trick" with the occurance change"
    But the problem it's we doesn't use mapping programs, so we can't apply to this case.
    So now i need to create a BPM scenario for resolve this issue. Anyone knows any example for split the income message and send any idocs to destination?
    Thanks in advance,

    IT WORKED !!!!
    The only thing it's at out code line we must improve it in another way.
    For everyone who needs to resolve, i copy the code line of the java mapping program.
    The relationship is from the specific mapping for every scenary calling GenToHierMap.
    0.0.0.0.0.0.0.0.0.0.0.0.1. GENERIC PACKAGE (GenToHierMap)
    0.0.0.0.0.0.0.0.0.0.0.0.2.
    package com.sap.javaMapping;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import java.util.Vector;
    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 org.w3c.dom.Text;
    import com.sap.aii.mapping.api.StreamTransformation;
    public class GenToHierMap
         private Element root, idoc;
         private Element nodeArrayRef[];
         private String nodeArrayTagName[];
         private Relation  rel ;
         private int  stack_count ;
         private String nameSpace;
         private String separator="#!";
         protected String msgName;
         GenToHierMap(InputStream in, OutputStream out,Vector v1,String msgName1,String nameSpace1)
         msgName = msgName1;
         nameSpace = nameSpace1;
         rel = new Relation(v1);
         execute(in,out);
        public void execute(InputStream in, OutputStream out)
              Element e ;
              Relation cur_rel;
              DOMSource domS = null;
              Element keyNodeParent;
              //int numdocs;
              try
                           DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                           factory.setNamespaceAware(true);
                             TransformerFactory tf = TransformerFactory.newInstance();
                             Transformer transform = tf.newTransformer();
                             // Create DOM structure from input XML
                             DocumentBuilder builderel = factory.newDocumentBuilder();
                             Document docIn = builderel.parse(in);
                            NodeList rows = docIn.getElementsByTagName("ROW");
                            nodeArrayTagName = new String[rows.getLength() + 1];
                            nodeArrayRef = new Element[rows.getLength() + 1];
                             Document docOut = builderel.newDocument();
                             root = docOut.createElement(msgName);
                             docOut.appendChild(root);
                             //idoc = docOut.createElement("IDOC");
                             //root.appendChild(idoc);     
                            //Número de documents inicialitzat a 0
                            //numdocs=0;
                            //Per cada filera ROW
                       for (int count=0;count<rows.getLength();count++)
                                  String dataRecord = "";
                                  Node node = rows.item(count);
                                  node = node.getFirstChild();
                                  dataRecord = node.getNodeValue();
                                  String fieldValue [] = dataRecord.split(separator);
                                  //Cada cop que es troba una nova capçalera es crea un nou document.
                                  //Això permet que hi hagi més d'un IDOC per missatge processat.
                                  if (Integer.valueOf(fieldValue[0]).intValue()==1){
                                       //numdocs = numdocs + 1;
                                       //if (numdocs > 1){
                                            //Es dona sortida al document anterior abans de crear-ne un de nou - BE AWARE BECAUSE IN THE NEXT LINES WE DEFINE THE UNBOUNDED IDOC ATTRIBUTE, WITH BEGIN = 1 ****
                                            //transform.transform((domS),new StreamResult(out));
                                            //docOut = builderel.newDocument();
                                            //root = docOut.createElement(msgName);
                                            //docOut.appendChild(root);
                                            idoc = docOut.createElement("IDOC");
                                            idoc.setAttribute("BEGIN","1");
                                            root.appendChild(idoc);     
                                  cur_rel = (Relation) rel.v.get(Integer.valueOf(fieldValue[0]).intValue());                    
                                  String keyId = cur_rel.node;
                                  keyNodeParent = searchNode(keyId);
                                  nodeArrayTagName[count] = keyId;
                               e = docOut.createElement(keyId);
                                  e.setAttribute("SEGMENT",fieldValue[0]);
                               nodeArrayRef[count]= e;
                              keyNodeParent.appendChild(e);
                              createXmlTree(docOut,e,keyId,fieldValue);
                              domS = new DOMSource(docOut);
                              stack_count = stack_count + 1;
                         transform.transform((domS),new StreamResult(out));
           catch (Exception t)
                  t.printStackTrace();
    return;
    //returns the parent of the given node
    private Element searchNode(String keyId)
         Relation cur_rel;
         for (int i=0;i<rel.v.size();i++)
              cur_rel = (Relation) rel.v.get(i);
              if (cur_rel.node.equals(keyId))
                     for (int j=0;j<cur_rel.parents.length;j++)
                              if (cur_rel.parents[j].equals("NULL")) return root;
                              if (cur_rel.parents[j].equals("IDOC")) return idoc;
                               for (int k=(stack_count-1);k>=0;k--)
                                   for (int p=0;p<cur_rel.parents.length;p++)
                                       if (nodeArrayTagName[k].equals(cur_rel.parents[p]))
                                       return nodeArrayRef[k];
    return null;
    //Creates all the elements of the given node
    private void createXmlTree(Document docOut,Element node,String keyId, String fieldValue[])
          Element tagName;
          Text tagValue;
          Relation cur_rel;
          for (int i=0;i<rel.v.size();i++)
                     cur_rel = (Relation) rel.v.get(i);
                     if (cur_rel.node.equals(keyId))
                        for (int j=1;j<cur_rel.elements.length;j++)
                           tagName = docOut.createElement(cur_rel.elements[j]);
                           node.appendChild(tagName);
                           if ( j < fieldValue.length  && fieldValue[j].length() != 0 )
                           if ( fieldValue[j].substring(0,1).equals("""))
                           if ( fieldValue[j].length() > 2 )
                           fieldValue[j] = fieldValue[j].substring(1,( fieldValue[j].length() - 1 ));
                           else
                           fieldValue[j] = new String ();
                           if ( j >= fieldValue.length )
                           tagValue = docOut.createTextNode(new String());
                           else
                           tagValue = docOut.createTextNode(fieldValue[j]);
                           tagName.appendChild(tagValue);
                        return;
    //Main thread of execution
    0.0.0.0.0.0.0.0.0.0.0.0.1. SPECIFIC ONE
    0.0.0.0.0.0.0.0.0.0.0.0.2.
    package com.sap.javaMapping;
    * Mapping Program to Convert NOM IDOC Master Structure to the Generic structure Expected by
    * the FTP Receiver adapter
    import com.sap.aii.mapping.api.*;
    import java.io.*;
    import java.util.Map;
    import java.util.Vector;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    //Specify the Hirearchial Structure
    public class INT938_mapping implements StreamTransformation
         public Vector v;
        private Map map;
        /** * method setParamters is required, but we do not anything with it */
         public void setParameter(Map param)
              map = param;
         } /** * method execute is called by the XI mapping program */
    public void buildXsd()
      Relation  mriRel ;
      v = new Vector();
      /* INICI MODIFICACIÓ ESTRUCTURA DE SORTIDA DEL MAPPING */
      // --> TOCAR AQUEST NODE IMPLICA MODIFICAR EL CÒDI!!!
      mriRel = new Relation();
      mriRel.parents = new String[1];
      mriRel.node =  "IDOC" ;
      mriRel.parents[0] =   "NULL" ;
      v.add(mriRel) ;
      /* ESTRUCTURA DEL IDOC DE SORTIDA */
      //NODE - 01
      mriRel = new Relation();                          
      mriRel.parents = new String[1];                                                    
      mriRel.elements = new String[22];                                                                 
      mriRel.node = "E1BPEBANC";                                    
      mriRel.parents[0]   =   "IDOC";                                              
      mriRel.elements[0]  =   "SEGMENT";   
      mriRel.elements[1]  =   "PREQ_ITEM"; 
      mriRel.elements[2]  =   "DOC_TYPE";  
      mriRel.elements[3]  =   "PUR_GROUP"; 
      mriRel.elements[4]  =   "CREATED_BY";
      mriRel.elements[5]  =   "PREQ_NAME"; 
      mriRel.elements[6]  =   "PREQ_DATE"; 
      mriRel.elements[7]  =   "SHORT_TEXT";
      mriRel.elements[8]  =   "MATERIAL";  
      mriRel.elements[9]  =   "PLANT";     
      mriRel.elements[10] =   "STORE_LOC";
      mriRel.elements[11] =   "TRACKINGNO";
      mriRel.elements[12] =   "MAT_GRP";   
      mriRel.elements[13] =   "QUANTITY";  
      mriRel.elements[14] =   "UNIT";      
      mriRel.elements[15] =   "DELIV_DATE";
      mriRel.elements[16] =   "ACCTASSCAT";
      mriRel.elements[17] =   "DES_VENDOR";
      mriRel.elements[18] =   "PURCH_ORG"; 
      mriRel.elements[19] =   "BATCH";     
      mriRel.elements[20] =   "VEND_MAT";  
      mriRel.elements[21] =   "CURRENCY";
      v.add(mriRel) ; 
      //NODE - 02
      mriRel = new Relation();                                   
      mriRel.parents = new String[1];                                                    
      mriRel.elements = new String[2];                                                                  
      mriRel.node = "Z1SOLCOM";                                    
      mriRel.parents[0]  =   "E1BPEBANC";                                                     
      mriRel.elements[0] =   "SEGMENT";  
      mriRel.elements[1] =   "ZPO_NUMBER";
      v.add(mriRel) ;
      //NODE - 03
      mriRel = new Relation();                                   
      mriRel.parents = new String[1];                                                    
      mriRel.elements = new String[3];                                                                 
      mriRel.node = "E1BPEBKN";                                    
      mriRel.parents[0]  =   "IDOC";                                                   
      mriRel.elements[0] =   "SEGMENT";
      mriRel.elements[1] =   "PREQ_ITEM";   
      mriRel.elements[2] =   "COST_CTR";
      v.add(mriRel) ;
      //NODE - 04
      mriRel = new Relation();                                   
      mriRel.parents = new String[1];                                                    
      mriRel.elements = new String[8];                                       
      mriRel.node = "Z1SOLRES";                                    
      mriRel.parents[0]  =   "E1BPEBKN";                                                   
      mriRel.elements[0] =   "SEGMENT";            
      mriRel.elements[1] =   "DADES_PACIENT";      
      mriRel.elements[2] =   "NOHIS";              
      mriRel.elements[3] =   "ZNINTER";            
      mriRel.elements[4] =   "ZFEIMP";             
      mriRel.elements[5] =   "NMPAC";              
      mriRel.elements[6] =   "ZNLOTE";             
      mriRel.elements[7] =   "ZNSERIE";            
      v.add(mriRel) ;
      /* FI    MODIFICACIÓ ESTRUCTURA DE SORTIDA DEL MAPPING */
    public void execute(InputStream in, OutputStream out) throws com.sap.aii.mapping.api.StreamTransformationException
         INT938_mapping rel = new INT938_mapping();
         rel.buildXsd();
         new GenToHierMap(in,out,rel.v,"ZPREEX01","http://namespace1/namespace");
    public static void main (String[] args) throws Exception
              try
                   INT938_mapping rel = new INT938_mapping();
                   FileInputStream in = new FileInputStream ("C:/DOM_IN.xml");
                   FileOutputStream out = new FileOutputStream ("C:/DOM_OUT.xml");
                   rel.buildXsd();
                   new GenToHierMap(in,out,rel.v,"ZPREEX01","http://namespace1/namespace");
              }catch(Exception e) {e.printStackTrace();}
    //Transformation of flat structure to hirearchial structure
    Any issue you can contact me. Best regards and reward points !

  • Error while doing java mapping

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

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

Maybe you are looking for