JAVA Mapping: Convert the InputStream in  to OutputStream out

Hi everybody,
I'd like to code my first JAVA Mapping. For this I would just like to convert the InputStream in  to OutputStream out.
This does not work:
out = new FileOutputStream(new File(in));
How has the code look like?
Thanks, regards
Mario

Hi Mario.
Do you want to convert input into output directly without doing any transformation?
The way I've always used is to load the input document first:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(inputStream);
After loading the document you can parse it's content with DOM API.
Finally you create the transformed document and return it through outputstream:
Document resultDoc = builder.newDocument();
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
DOMSource source = new DOMSource(resultDoc);
StreamResult result = new StreamResult(outputStream);
transformer.transform(source, result);
If  you want to convert the input to output you can use:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(inputStream);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(outputStream);
transformer.transform(source, result);
At this point, I think you will have the input into the output.
Regards,
Gari.

Similar Messages

  • JAVA Mapping: Convert a W3C DOM into OutputStream

    hi everybody,
    how do I convert a org.w3c.dom.Document into outputStream as needed in JAVA mapping?
    Thanks regards
    Mario

    Hi Mario,
    even if you already found the solution, I think the information may be useful to others.
    You could do something like:
    import org.w3c.dom.Document;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    Document doc;
    try {
         TransformerFactory tf = TransformerFactory.newInstance();
         Transformer trans = tf.newTransformer();
         trans.transform(new DOMSource(doc), new StreamResult(out));
    } catch (TransformerConfigurationException e) {
         // Implement exception handling
    } catch (TransformerException e) {
         // Implement exception handling
    Regards,
    Henrique.

  • I bought pdf converter pro but when i convert to excel it only converts the columns with figures leaving out the columns with quantity descriptions

    i bought pdf converter pro @$29.99  but when i convert to excel it only converts the columns with figures leaving out the columns with quantity descriptions

    Contact the vendor of the product for support.

  • Java mapping - Setting the name of the file dinamically

    Hi all,
    Problem: I know how to set the name of the file in an Idoc to file interface if I'm using a message mapping, but not if I'm using a Java mapping.
    I'm using this code inside a user-defined function of the message mapping so that I can set the name of the file dinamically:
    public String GetFileName(String  inboundParameter,String IdocNumber,Container container){
    String filename;
    java.text.SimpleDateFormat dateformat = new java.text.SimpleDateFormat( "yyyyMMdd" );
    filename = "cikk_" + dateformat.format( new java.util.Date() ) "_" IdocNumber + ".txt";
    DynamicConfiguration conf = (DynamicConfiguration) container
           .getTransformationParameters()
           .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    conf.put(key, filename);
    return inboundParameter;
    (See also: /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14)
    But how can I do that if I'm using a Java mapping??
    I don't have the class Container there. How can I retrieve the DynamicConfiguration object without that class?
    Thank you very much.

    Thank you Jin,
    I knew that it had to be related with the Map object got in setParameter, but in this link:
    http://help.sap.com/saphelp_nw04/helpdata/en/0f/80243b4a66ae0ce10000000a11402f/frameset.htm
    you can't find the constant DYNAMIC_CONFIGURATION.
    I think it's not up to date.

  • Exception while perfroming Java mapping in XI

    Hi there,
    Im doing some java mapping in XI using the standard/classic DOM and JAXP packages, I have tested everything outside XI and the code seems to be OK.
    However when I deploy the code into XI self and run a test, something goes wrong.
    This is the exception Im getting from my log (PS: In th eyes of XI eveything goes fine, but this is because I have all my code surrounded by try/catch statements...):
    <b>java.lang.ClassCastException: com.inqmy.lib.xml.dom.DocumentImpl</b>
    1) First, what I dont understand here is the fact that Im not doing any kind of parsing to this type "com.inqmy.lib.xml.dom.DocumentImpl" in my code, so Why XI is doing this?
    2) It seems to me like XI internally uses this "fancy" INQMY package to perform my XML parsing/mapping. But nowhere in the documentation is mentioned, at least I haven't read about it.
    3) Is there anyplace where I can find/download this package "com.inqmy.lib.xml.dom.*" so that I can test/debug my code using this specific SAP pacakge?
    Can anyone give me some clues how to solve and prevent this issue? Below is the part of the code where the exception is generated:
         private void processMultiMessages(Vector indexVector, NodeList msgList) {
              Iterator iter = indexVector.iterator();
              Integer tempIndex = null;
              int index = 0;
              try {
                   for (int i = 0; i < indexVector.size(); i++) {
                        tempIndex = (Integer) indexVector.elementAt(i);
                        index = tempIndex.intValue();
                        Range range = ((DocumentRange) mainDocument).createRange();
                        range.setStartBefore(msgList.item(index));
                        if ((i + 1) > (indexVector.size() - 1)) {
                             index = msgList.getLength() - 1;
                             range.setEndAfter(msgList.item(index));
                        } else {
                             tempIndex = (Integer) indexVector.elementAt(i + 1);
                             index = tempIndex.intValue();
                             range.setEndAfter(msgList.item(--index));
                        createNewMsg(range.cloneContents());
                        range.detach();
                   getSystemParams().put("STATUS", "OK");
                   getSystemParams().put("TOTAL_MSG", new Integer(indexVector.size()));
                   getSystemParams().put(
                        "STATUS_MSG",
                        "Target directory on XI Server: " + folder);
                   this.out.write(
                        new LogDocument().createDocument(getSystemParams()).getBytes());
              } catch (Exception e) {
                   getSystemParams().put("STATUS", "FAIL");
                   getSystemParams().put("TOTAL_MSG", new Integer(indexVector.size()));
                   getSystemParams().put(
                        "STATUS_MSG",
                        "** Exception in Java Mapping: " + e.toString() +" ** System error: " +  System.err);
                   try {
                        this.out.write(
                             new LogDocument()
                                  .createDocument(getSystemParams())
                                  .getBytes());
                        e.printStackTrace();
                   } catch (IOException ioE) {
                        ioE.printStackTrace();

    Hi there,
    I have included the inqmyxml.jar in my classpath and perfor
    med some tests (outside XI), with good results.
    However, when I copy/deploy the same classes into XI then the problem still there. My Java class is complaining about some ClassCastException, the error looks like this:
    java.lang.ClassCastException: com.inqmy.lib.xml.dom.DocumentImpl
    has anyone any ideas/clues was happening here?
    Cheers,
    Rob.
    PS: These are the packages Im importing in my class:
    import com.sap.aii.mapping.api.*;
    <i>import java.io.*;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.stream.StreamResult;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.w3c.dom.*;
    import org.w3c.dom.ranges.*;
    import com.inqmy.lib.jaxp.*;
    import com.inqmy.lib.xml.*;
    import com.inqmy.lib.xml.parser.*;
    import com.inqmy.lib.xml.dom.*;</i>
    And these are the Global vars Im using:
    <i>     // declare Global vars
         private Map systemParams;
         private InputStream in;
         private OutputStream out;
         private DocumentBuilderFactory domFactory;     
         private DocumentBuilder documentBuilder;
         private Document mainDocument;
         private String path;
         private String separator;
         private File folder;</i>
    And finally this is the way I start my mapping/parsing process:
    <i>               ClassLoader cl = Thread.currentThread().getContextClassLoader();
                   Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    domFactory = DocumentBuilderFactoryImpl.newInstance();
                   Thread.currentThread().setContextClassLoader(cl);
    // Optional: set various configuration options
                   domFactory.setIgnoringComments(true);
                   domFactory.setIgnoringElementContentWhitespace(true);
    domFactory.setValidating(false);
    domFactory.setCoalescing(false);
    // Create and set documentBuilder
    documentBuilder = domFactory.newDocumentBuilder();
    // parse the input file
    mainDocument = documentBuilder.parse(in);
    </i>

  • JAVA mapping error

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

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

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

  • My First Java Mapping in PI 7.1

    Hi, i'm having a problem with my first Java Mapping in PI 7.1
    I was reading examples and i create a class that extends "AbstractTransformation", there's a "transform" method and it request two params with "TransformationInput" type.
    I created a main method to test it, but i have a problem converting the InputStream to TransformationInput.
    Anybody had this problem?
    Regards,
    Sebastián.

    Hi Sebastian,
       Trasform method is like a main method in JAVA Mapping,the execution starts from the trasform method,TrasformationInput method reads the input from Input stream reader,and TrasformtionOut write out in in output stream.
    public class FirstJavaMap extends AbstractTransformation {
         public void transform(TransformationInput in,TransformationOutput out)
          throws StreamTransformationException {
    try{
    your logic...
    }catch(Exception e)..........
    like that
    refer below link ,it helps you...
    http://help.sap.com/saphelp_nwpi71/helpdata/EN/43/bc2fd4da1e1bbce10000000a1553f7/content.htm
    Regards,
    Raj

  • 1:n Transformation using JAVA Mapping Scenario

    Hi Frnds,
    I done a scenario using 1:n Transformation Scenario using XSLT,Graphical Mapping.
    But i want to develop scenario Using JAVA Mapping.
    Can anybody done the same scenario using JAVA Mapping share the links..
    Regards,
    Raj Sekhar

    You can use SAX parser for this
    firstly create a StringBuffer sb object which will store our target output
    when startDocument() gets called append the xml declaration in this method
    sb.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
    sb.append("<Root>");
    next for the Test element you have your startElement() method called which will contain the name of your source tag i.e Test
    for this , you will need to set a variable boolean isTest to true which was initialised as a false value.
    in the characters method you will get the value present in this tag.
    test the variable isTest for true value.
    if it is true then append the following
    sb.append("<Test1>"name"</Test1>"); //name is the buffer passed in characters method
    sb.append("<Test2>"name"</Test2>");
    sb.append("<Test3>"name"</Test3>");
    at the end your endelement() will be called
    here reset the value of isTest to false.
    in your endDocument()
    sb.append("</Root>");
    lastly convert to byte[] and then to outputStream format
    Edited by: Progirl Progirl on Jul 4, 2008 2:00 PM

  • User Java-Mapping Call SAP-Mapping

    Hello to all,
    I've created a userdefined JAVA-Mapping (Everything works fine).
    Is it possible to execute a SAP-default JAVA-Mapping in the userdefined JAVA-Mapping.
    Are there any blogs about that? I haven't found any yet.
    Thanks for your help.
    Regards
    Christian

    Hey Christian,
    would you please try this?
    Inside of your custom java mapping code, just refer to the standard java mapping class, set the relevant parameters and call the execute() method.
    public class CustomMapping implements StreamTransformation {
      private Map param = null;
      private AbstractTrace trace = null;
      public void setParameter(Map param) {
        this.param = param;
      public void execute(InputStream in, OutputStream out) {
      // Call the standard mapping
      StandardMapping mapping = new StandardMapping();
      mapping.setParameter(param);
      mapping.execute(in, out);
    The out object should hold the result from the execution of the standard mapping.
    Also, for you to build this in NWDS, you'll have to export the .jar containing the StandardMapping class from the Integration Builder and add it as an external jar in your custom mapping project's class path.
    Regards,
    Henrique.

  • Imported java mapping trouble

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

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

  • XML Validation with XSD in java mapping

    Hi experts,
    I have created an interface to send differents messages between bussines system, the bussiness system receiver is put in the message, to get this value I have a configuration file indicating the path of this field for each message type. In a java mapping I transform the message sent in this structure:
    <document>
    <message>HERE THE MESSAGE AS STRING</message>
    <parameters>
    <sender>HERE SENDER BUSSINESS SYSTEM</sender>
    <receiver>HERE RECEIVER BUSSINESS SYSTEM</receiver>
    </parameters>
    </document>
    the messaging interface works fine, but now I have to validate the XML vs XSD. I need doing in a java mapping because the messaging interface send the message and a email to sender in error case.
    To do this validation I have implemented two java mappings that works fine in my local, the first way is with class Validator of java 5, but my system PI 7.1 return an error with this class. The second way is with SAX parse:
    String schema = "XXXXXxsd";
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware(true);
    docBuilderFactory.setValidating(true);
    docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema");
    InputStream is = this.getClass().getClassLoader().getResourceAsStream(schema);
    docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",is);
    in my local works fine but in PI always return OK never fail.
    For this moment the schema is hardcoded to do proofs, in the future will be loaded from my configuration file.
    Any idea?
    Thanks in advance
    Jose

    hi Jose,
    PI 7.1 has a built in feature available called XML vaidations ..
    your source xml can be validated against a XSD placed at a specific location on the PI server..
    validation can be performed at adapter/integration engine
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d06dff94-9913-2b10-6f82-9717d9f83df1?quicklink=index&overridelayout=true

  • Tips on how to write efficient  java code for java mapping

    hi
    I do not have much knowledge in Java
    Can anybody tell me some tips on how to write efficient and optimised java code to be used in java mapping
    Thanks,
    Loveena

    hi D'za,
    JAVA in xi
    A very important place where you will use JAVA in XI is while doing your Mapping. There will be cases when JAVA MAPPING is the best solution to go for. There are 2 types of Parsers available for JAVA Mapping. DOM Parser and SAX parser. Just got through the following links to understand more on Java Mapping and the APIs available.http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/package-summary.html http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Document.html http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    JAVA mapping -
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii /people/ravikumar.allampallam/blog/2005/06/24/convert-any-flat-file-to-any-idoc-java-mapping /people/amol.joshi2/blog/2006/03/10/think-objects-when-creating-java-mappings /people/sameer.shadab/blog/2005/09/29/testing-abap-mapping
    sample code for java mapping
    Re: Example code DOM PARSER API -
    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html DOM --- /people/thorsten.nordholmsbirk/blog/2006/08/10/using-jaxp-to-both-parse-and-emit-xml-in-xi-java-mapping-programs tutorial sax and dom
    For a tutorial on the methods of SAX and DOM http://java.sun.com/webservices/docs/1.1/tutorial/doc/
    SAX AND dom PARSER ( BY thorsten) -
    example /people/thorsten.nordholmsbirk/blog/2006/08/10/using-jaxp-to-both-parse-and-emit-xml-in-xi-java-mapping-programs java mapping example ( testing and debugging) /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    regards
    biplab
    Use a Good Subject Line, One Question Per Posting - Award Points

  • Multi Mapping in Java Mapping

    Hello Everyone,
    My scenario has a flat file that needs to be grouped and split into multiple xml files
    Since the source is a flat message I have used a java mapping where the splitting happens.
    I've also made sure to add the <mesages> and <messages1> tags for the target message so that my file asapter can split it
    The problem is when i test this interface i get  'Eror while constructing multi-XML Doucment' in my moni
    Anybody had similar problems..??
    Thanks
    Bharath

    Yes,
    I've worked on a few multi mappings before successfully.. so the obvious doubts can be ruled out..
    however this is the first time Im using Java mapping to do this..
    One doubt that however is hovering is "can flat files be used as input ??" or should I use FCC to convert into a simple XML with just one node and parse it to get my payload?

  • Multi Mapping using JAVA Mapping 1:n Transformation--Urgent??

    Hi,
    I have to make a 1:n Mapping with the JAVA Mapping. The situation is as follows:
    I have 1 ORDER with n positions and I have to convert this order to n ORDERS with 1 position in each order. My problem is, that I have to use the header-data of the input-order for each of the output orders and I have to use the first position of the input-order for the frist output-order the second postition for the second order and so on. Which mapping-steps do I have to use. I think this is an ordnary problem, but I could not find anything in the XI-help about this. Maybe anyon has got an idea.
    Regards,
    Raj

    hi
    The output from java mapping must look like
    <Messages>
    <Message1>
    <Your Traget Order>....
    </Message1>
    <Your Traget Order>....
    </Message1>
    </Messages>
    Create a Graphical mapping sample (1:N) to get an idea about this structure.
    refer this also
    /people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
    rgds,
    Arun

Maybe you are looking for

  • Multiple users on one mac mini server?

    We're four ios developers looking for the cheapest mac setup, so can we just buy one mac mini server and four displays and use it sumalteneously for xcode development??

  • IPod Nano not recognized by computer.

    My iPod Nano 2nd generation isn't recognized whatsoever by my computer. A short recap: On a Windows XP driven computer (not mine and on the other side of the Atlantic) I connected and downloaded music. When I returned home, I wanted to connect my iPo

  • In Health Vault, the Medications are not listed in chronological order, can this be changed?

    I am new to Health Vault and I am entering all my families Medications and Conditions from current backwards.  I am noticing that after I save, logout and return, they are still listed in the same order I entered them in.  This seems crazy, as I expe

  • Selective file transfer

    Hi, I'd like to transfer my own files, photos, music and a few applications from the family's iMac onto my new MacBook. If I transfer via Target Disk, do I have the option of grabbing only what I want, or does it bring everything from the iMac into t

  • Remote Desktop Connection/RDC display is too small on my MacBook screen

    I use the free download from MS, RDC version 1.0.3 on my MacBook - to connect remotely to a PC network at my job from home. When I connect remotely the RDC display is very small on my MB screen. Is there anyway to enlarge the display or am I locked i