Creation of additional attachment in Java Mapping

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

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

Similar Messages

  • Creating a PDF-Mail-Attachment via Abap Mapping possible ?

    Hi folks,
    I am trying to build a szenario like: Getting an Idoc -> sending it to abap mapping -> map a pdf from smartforms in abap -> map the from/to for the mail payload -> come back from abap mapping -> send it with the mail adapter .
    But now I am stuck at the point "coming back from abap mapping", because the pdf -data seems to become unreadable because of conversion. I am using Ixml and trying to attach the create pdf (looks hex-right at that point) by method create_simple_element as content-tag of the mail. But after rendering and coming back out of mapping, it seams that that data is not converted from xstring back in the right way. Can someone give a hint ? Is that way by IXML not possible for data including binary-data ? Have I to go another way?
    Thanks in advance
    Detlef

    > as content-tag of the mail.
    Sometimes I have to read the request several times to find the issue:
    No you cannot put a binary as part of an XML element.
    You can only send a plain binary as payload, so the whole mail would be nothing besides the PDF.
    In PI 7.1 you can create also an additional attachment out of mapping, but I do not know if this works for ABAP mapping also.
    The whole "I want to send an email with attachment out of PI" topic is not supported from PI development in any way.
    So you have to write a lot of code (especially Java code) to achieve this.
    > Regarding your opinion. Its based on customer requirements to have central focal point in dezentral landscape.
    The PI expert has to advise the customer for the scenarios. That is part of the job.

  • Java Mapping PI 7.0 to 7.1

    Hi,
    The below mentioned code is for sending email with attachment using Java Mapping which was implemented in PI 7.0
    I know the API for PI 7.1 has changed, I changed the below code using extends AbstractTransformation using Transform instead of implements streamTransformation and few other changes but I get lot of issues.
    Could anyone point out what and all need to be changed in PI 7.1 for the below mentioned code. It would be greatly if anyone could let me know the changes
    package dynamicconfmail;
    import com.sap.aii.mapping.api.*;
    import java.io.BufferedReader;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Properties;
    import javax.mail.*;
    import javax.activation.*;
    import javax.mail.internet.*;
    import javax.mail.util.ByteArrayDataSource;
    public class DynamicConfMail implements StreamTransformation {
        private Map param;
    //// Start of Main Class
    //         public static void main(String[] args) throws Exception
    //     try
    //     FileInputStream fin = new FileInputStream("c:/test/sam.txt");
    //     FileOutputStream fout =     new FileOutputStream("H:/test/sam2_O.txt");
    //     DynamicConfMail mapping = new DynamicConfMail();
    //     mapping.execute(fin, fout);
    //     catch (Exception e)     
    //     //   e.printStackTrace();
    // //End of Main Class
        public DynamicConfMail() {
        public void setParameter(Map map) {
            param = map;
            if (param == null) {
                param = new HashMap();
        public void execute(InputStream inputstream, OutputStream outputstream)
            int IO_BUFFER_SIZE = 4 * 1024;
                String llkj = "1111";
                String llkj_f = "llkj.txt";
                String llkj_dir = "/usr/sap/llkj/in";
                String xyzv = "9999";
                String xyzv_f = "xyzv.txt";
                String xyzv_dir = "/usr/sap/xyzv/in";
               String default_dir = "/usr/sap/Error";
               String Flag = "";
               String FileName = "";
            try
    //           The following is for the FileName in the File Adapter
                DynamicConfiguration conf = (DynamicConfiguration) param.get("DynamicConfiguration");
                DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
                DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");
                InputStream ins = inputstream;
                // Start Copy the InputStream to OutputStream
                byte[] b = new byte[IO_BUFFER_SIZE];
                int read;
                StringBuffer out = new StringBuffer();
                 try {
                        while ((read = inputstream.read(b)) != -1)
                            out.append(new String(b, 0, read));
                            String InputString =  out.toString();
                            String substr = InputString.substring(2, 18);
                            System.out.println(substr);
                            if (substr.equals(llkj))
                                     System.out.println("The given string is equals");
                                     conf.put(key, llkj_f);
                                     conf.put(key1, llkj_dir );
                                       FileName = llkj_f;
                            else if (substr.equals(xyzv))
                                     System.out.println("The given string is equals");
                                     conf.put(key, xyzv_f);
                                     conf.put(key1, xyzv_dir);
                                       FileName = xyzv_f;
                            else
                                    conf.put(key1, default_dir);
                                    Flag = "F";
                                    System.out.println("The given string is not equals");
                                     FileName = substr;
                            // Writes to outputstream
                            outputstream.write(b, 0, read);
                        if (Flag.equals(""))
                         //* Code to Send Email*/
                            String att = outputstream.toString();
                            email obj1 = new email();
                          obj1.send("mailhost", "emailID", "Success", "Success", "emailID",InputString, FileName);
                         //End of Email          Code/
                        else if (Flag.equals("F"))
                        //* Code to Send Email*/
                            String att = outputstream.toString();
                            email obj1 = new email();
                         obj1.send("mailhost", "emailID", "Failed", "Failed", "emailID",InputString, FileName);
                        //End of Email          Code/
                catch (IOException ex)
                    ex.printStackTrace();
               // End of Copy the InputStream to OutputStream
            catch (Throwable throwable)
                throwable.printStackTrace();
       public class email {
         public void postMail(String mailhst, String recivers, String subject, String message, String from, String attachment, String FileName) throws MessagingException
              boolean debug = false;
                    byte[] AttByteArray = attachment.getBytes();
              Properties props = new Properties();
              props.put("mail.smtp.host", mailhst);
                    Session session = Session.getDefaultInstance(props, null);
              session.setDebug(debug);
                    Message msg = new MimeMessage(session);
              InternetAddress addressFrom = new InternetAddress(from);
              msg.setFrom(addressFrom);
                    String recipients[] = recivers.split(",");
              InternetAddress[] addressTo = new InternetAddress[recipients.length];
              for (int i = 0; i < recipients.length; i++)
                   addressTo<i> = new InternetAddress(recipients<i>);
                    msg.setRecipients(Message.RecipientType.TO, addressTo);
              msg.addHeader("MyHeaderName", "myHeaderValue");
              msg.setSubject(subject);
                    // Create the message part
                    BodyPart messageBodyPart = new MimeBodyPart();
                    // Fill the message
                    messageBodyPart.setText("TEST");
                    Multipart multipart = new MimeMultipart();
                    multipart.addBodyPart(messageBodyPart);
                    // Part two is attachment
                    messageBodyPart = new MimeBodyPart();
                    DataSource source = new ByteArrayDataSource("Test","text/plain", AttByteArray );
                    messageBodyPart.setDataHandler(new DataHandler(source));
                    messageBodyPart.setFileName(FileName);
                    multipart.addBodyPart(messageBodyPart);
                    // Put parts in message
                    msg.setContent(multipart);
                    Transport.send(msg);
         public void send(String mailhst, String recivers, String subject, String message, String from, String attachment, String FileName)
         try {
              this.postMail(mailhst, recivers, subject, message, from, attachment, FileName );
         catch (MessagingException mex) {
              System.out.println("send failed, exception: " + mex);
            class ByteArrayDataSource implements DataSource {
             byte[] bytes;
             String contentType;
             String name;
             ByteArrayDataSource( String name, String contentType, byte[] bytes ) {
               this.name = name;
               this.bytes = bytes;
               this.contentType = contentType;
             public String getContentType() {
               return contentType;
             public InputStream getInputStream() {
               return new ByteArrayInputStream(bytes);
             public String getName() {
               return name;
             public OutputStream getOutputStream() throws IOException {
               throw new FileNotFoundException();
    Edited by: PI-seeker on Feb 3, 2011 10:58 PM

    Thansk a lot for your link.
    I did implemented the same way as it mentioned, but I am getting the following error message
    SAP:Error SOAP:mustUnderstand="" xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">LINKAGE_ERROR</SAP:Code>
      <SAP:P1>dynamicconfmail/DynamicConfMail</SAP:P1>
      <SAP:P2>java.lang.UnsupportedClassVersionError: dynamiccon</SAP:P2>
      <SAP:P3>fmail/DynamicConfMail : Unsupported major.minor ve</SAP:P3>
      <SAP:P4>rsion 50.0</SAP:P4>
      <SAP:AdditionalText />
      <SAP:Stack>Linkage error while loading class dynamicconfmail/DynamicConfMail; java.lang.UnsupportedClassVersionError: dynamicconfmail/DynamicConfMail : Unsupported major.minor version 50.0</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
    I am sure that I need to do include some library files, but I couln't figure it out. Couls you pls help to resolve this. The following library jar files were included
    activation.jar
    aii_map_api.jar
    com.sap.xpi.ib.mapping.lib.jar
    jce.jar
    mail.jar
    JRE System Library.............is anything else missed out??
    By the way I included all these in Netweaver Developer studio , in JavaBuildPath ->Libraries.
    Added those jar files as external jar's for development and then compiled it and  exported as DynamicConfMailJar  and imported in PI .
    could anyone help?

  • XI Mail Adapter: sending emails with attachment with help of java mapping

    Hi ,
    On trying out the scenerio mentioned in the blog, using the java mapping provided
    "XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping
    The scenerio works just fine.
    But the payload as the content of the attachment is not getting generated in proper XML format.
    I suppose it's because of the replace special characters code part..
    Can anyone help me state the modification required in the code.
    Thanks!
    Regards,
    Faria Mithani

    It might be a codepage issue. Is your original payload UTF-8?

  • Modify Java Mapping on Mexico Digital Invoice

    I have installed all oss notes related to the Mexico Digital Invoice on our ERP system and XI system.  Since we made additional modifications to the Invoice02 extension, I need to modify the Java mapping on XI.  The note (1296042) states if you make changes to the idoc, you will need to make changes to the java mapping as well, and recompile it to install the class on XI.
    I have a java editor, however, I cannot find the java project anywhere.  Does anyone know where I would access this from?  The pdf on the note related to modifying the java mapping only says to open the project; It doesn't have the project in the note, from what I can see.  And I don't see it within XI. 
    Anyone know?  Or has anyone done this?

    >
    Henrique Pinto wrote:
    > Just a follow-up.
    > Note https://service.sap.com/sap/support/notes/1296042 has been updated with the Java mapping source codes.
    >
    > BR,
    > Henrique.
    Hi Henrique,
    We are also implementing the mexico invoice and I am trying to change the java mapping and I can't figure out where the '.JAVA' file exist? We could not find it in the imported archives (on the repository)... I have checked most of the attached files on the notes (can you let me know the name of the file with source code?)

  • PI Java Mapping NullPointerException

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

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

  • Using the Mail content and Mail Attachment in the mapping

    Hi,
    I have a requirement in which I need to read a file from the mail server and I am using the sender mail adapter for this. I have to convert the attachment of the mail in to the payload. To do this I am using the payload swap bean and mail transform bean. Now the issue is I have to get the information from both attachment and the mail content and need to map it to the target message. Please let me know how to do this.
    Thanks!
    ~Vaas

    Not sure if there is a staright forward way to achieve this.
    But I can think of a work around for your scenario.
    >>To do this I am using the payload swap bean and mail transform bean.
    Instead of doing it this way, try
    1. Message Transform bean that will transform the payload(content of the mail) to XML.
    2. PayloadSwapBean to switch Payload and Attachment.
    3. Message Transform bean to transform the attachment to XML.
    4. Custom adapter module to read the attachment, contnet and create your own desired XML.
    Alternatively, step 4 could be replaced by a Java mapping doing the same operation.
    Regards
    Jai

  • 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

  • Can I leverage JDom or Dom4J for java mapping in PI 7.0?

    Hi,
    since we know that PI 7.0 is based on jdk1.4 which officially allows DOM and SAX,but could I using the open source API like JDom or Dom4J via importing the related jar file to PI IR for java mapping?Anyone tried that?

    Hi ,
             I tried importing jar files into PI7.0 I was able to do so.
    First add the external jar file for JDOM into build path in eclipse (or NWDS). I did this in eclipse.
    Again I tried to import the same jar file into project within eclipse. Then the jar file will be broken into class files.
    Now compile the JDOM code you wrote and do project ->build all. This will generate the class file for your source code in addition to the class files formed earlier. Now exit from eclipe. Move to source folder of the eclipse. there you will find the .java file and the set of class files which were imported into the project earlier. Copy these files to separete folder say "myclass". Now again move to "bin" folder of your eclipse settings and obtain the .class file for the source code you have written. Copy this class file to the  "myclass" folder. Now using WINZIP zip all files into one ZIP file within "myclass" folder. Finally import this ZIP into PI 7.0 server. Run the mapping code using test tab. If you are getting any linkage error then you need to obtain correct external jar for JDOM parser else the mapping should run fine.
    Regards
    Anupam

  • Java Mapping of Adapter-Specific Message Attributes

    Hi!
    I've got a problem with the help.sap.com-example for the above mentioned task:
    DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
        “http://sap.com/xi/XI/System/File”,
        “FileName”);
    String valueOld = conf.get(key);
    if (valueOld != null) {
        String valueNew = valueOld.replaceAll(“input”,”output”);
        conf.put(key, valueNew);
    The Container-class I  have doesn't offer the method getTransformationParameters(). Additionally, the method get() from class DynamicConfiguration doesn't accept a DynamicConfigurationKey-object. Finally: how do I instantiate the Container-object (I think it's stored in the Parameter-Map, but what's its name?).
    Thanks!
    BR
    Christian

    Hi Christian,
    Pls see these sap help links on the Java mapping.
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/43/09b16006526e72e10000000a422035/frameset.htm
    As you would see in the example shown in the link...you donot require a container object in case of java mapping(that is required when you are using the user defined functions)...
    here you can call the get() method from the map in the java mapping class....this map is set by the mapping runtime by calling the setParameter() method in your java mapping class.
    Thanks,
    Renjith

  • Help Required in java mapping using XI

    Does any body worked on java Mapping in XI
    where do u find the com.sap.aii.*;
    thank's in advance
    swamy

    Hi,
    To access the mapping API, you must include the Jar file aii_map_api.jar in your class path. The Jar file is located in the following directory:
    <SAP_install_dir>/<system_name>/<instance_name>/j2ee/cluster/server<number>/apps/sap.com/com.sap.xi.services/
    To include the three J2EE standard libraries in the class path of the NetWeaver Developer Workplace, call the Set Additional Libraries... function in your Eclipse project by calling the context menu and selecting the libraries
    com.sap.tc.Logging,
    com.sap.mw.jco
    sapxmltoolkit.
    Hope this solves your problem.
    Regards,
    Siva Maranani.
    Message was edited by: siva  maranani

  • How to avoid Linkage Error in JAVA Mapping

    Dear Experts,
    I am trying to test the JAVA mapping compiled in NWDS but receiving the error
    "LinkageError at JavaMapping.load(): Could not load class".
    java.lang.NoClassDefFoundError: JSONXMLProject/bin/com/sap/json/ConvJson2Xml (wrong name: com/sap/json/ConvJson2Xml)
    at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:735)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:716) at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    at com.sap.aii.ib.server.mapping.execution.MappingLoader.findClass(MappingLoader.java:195)
    Following are the details:
    SAP PO 7.4
    SP Stack Number 05
    JDK Version jdk16
    NWDS
    SAP Enhancement Package 1 for SAP NetWeaver Developer Studio 7.3 SP10 PAT0000
    1.Created the Project , Package and then class (Included the logic)
    2. Included 1 JSON Jar file into my project and the Added to build path.
    3.Exported the project as Archive File and saved in desktop
    4.Imported into SAP PO system as Imported Archive
    5.Could not observe the JSON jar file which i used as referenced JAR in NWDS
    6.Tested in OM after referencing the JAVA class and found the above error.
    I have JDK 5, 6 and 7 present in my local desktop and I am trying to export the compiled code using both JAVA SE 1.6 and 1.5 in NWDS seperatly after going several discussions.
    Can any one hep me with the screenshots and tell me how to include all the reference jar files in exported project..
    Regards..

    Dear Anand,
    I did exactly as you shared. As the JSON jar has number of classes, then in OM all the Classes had to be assigned. Then the linkage error went.
    But in execution , it shows a new error that all the classes of the JSON jar has to be implemented with interface StremTransformation or AbstractTransformation.
    I assume in the Operation Mapping I will use only 1 class as JAVA Class. Anyway I am attaching the document with navigation.
    Do we have any other alternative??
    Please rename the extension of the document by remove .txt
    Regards

  • Java Mapping for HTTP Post

    Hi
    Im following this blog http://scn.sap.com/community/pi-and-soa-middleware/blog/2014/09/12/html-form-upload-using-http-plain-adapter-with-java-mapping but I have encountered an issue which I cannot solve.
    My issue is, in addition to the required output, I am also getting unwanted XML added, which originates from the Message Type in the source Service Interface,
    i.e.
    Content-Type: multipart/form-data; boundary=--ejjeeffe1
    --ejjeeffe1
    Content-Disposition: form-data; name="event"
    Content-Type: text/plain
    Import File
    --ejjeeffe1
    Content-Disposition: form-data; name="Filename"
    Content-Type: text/plain
    TestFile.zip
    --ejjeeffe1
    Content-Disposition: form-data; name="content";filename="TestFile.zip"
    Content-Type: application/zip
    Content-Transfer-Encoding: binary
    <?xml version="1.0" encoding="UTF-8"?><__EmptyDoc></__EmptyDoc>
    --ejjeeffe1
    Any suggestions much appreciated.
    Regards
    Steve

    Hi Stephen
    The xml must be getting added in the below part of the code. It is coming from arg[0]
    You can put a check and get it removed.
    while ((len = arg0.read(buffer)) != -1) {
      arg1.write(buffer, 0, len);
    Regards
    Osman

  • Java mapping for XSD Validation

    Hello,
    I have developed a Java mapping to validate an XML based on XSD.
    I works fine and generates a message with error details.
    I would like to create a report with all errors encountered during this Validation and to stop this message from being sent to the partner.
    But this Java mapping stops at first error encountered and generates an error message with first error only even though document has more errors further.
    Can anyone please let me know if there is an option to log all errors without allowing the message to go through?
    Thanks.
    Best Regards,
    Shweta

    Yes, as abhishek mentioned when you validate the instance document (XML) using standard parsers then they validate based on the spec provided in XSD and they stop at the first error. The link given using dom parser via java code will also stop at the first error.
    If you really want to validate the entire instance document then you might have to create a custom validator class which does validation for each and every fields and store it in an object like Vector or List or Map object.  Then when you throw exception you can retrieve that Map object  in the catch block and read all the individual error messages and display in log. This requires additional effort. In this case you dont rely on parser validation. Completely custom based.
    Example:
    Vector errorList = new Vector();
    if the field name is  SSN and if you see any alpha characters you add error for that field in the errorList
    If(SSN.matches("[a-zA-Z]")){
        do nothing
    }else{
        errorList.add("The fieldName SSN contains other than alpha characters");
    Like that you have to add error string mesg in the errorList object and return the errorList at the end.

  • Problem by adding attachments in Java Mapping

    Hi,
    we have to add some attachments in Java Mapping.
    So we are using the Java Mapping API.
    But it doesn't work correctly.
    We got the following error in sxmb_moni:
    Attribute Manifest ExampleAttachment is initial
    So we checked what happened in the Manifest and in the SAP SOAP Envelope and we see that there is an inconsistence.
    In the SAP Manifest we find the following entries:
    <SAP:Manifest xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wsu="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="wsuid-manifest-5CABE13F5C59AB7FE10000000A1551F7">
         <SAP:Payload xlink:href="cid:payload-79a6e3c088db11dfa4dd0017a477c1e8<at>sap.com">
              <SAP:Name>MainDocument</SAP:Name>
              <SAP:Description/>
              <SAP:Type>Application</SAP:Type>
         </SAP:Payload>
         <SAP:Payload xlink:href="ExampleAttachment">
              <SAP:Name>ExampleAttachment</SAP:Name>
              <SAP:Description/>
              <SAP:Type>ApplicationAttachment</SAP:Type>
         </SAP:Payload>
    </SAP:Manifest>
    For us it seems the entry for our ExampleAttachment is wrong. I think there must be a real content id for the attachment like the cid for the MainDocument. In the SOAP Envelope you can find the following entry for the attachment:
    content-type:text/plain
    content-length:45
    content-id:payload-79a6e3c088db11dfa4dd0017a477c1e8<at>sap.com
    This is an example for an attachment!
    --SAP_0017A477C1EC1DEFA3D200A5CB55CE04_END--
    So here you can see a real content ID, but you can't find it in the Manifest.
    So do we anything wrong in our source code or is it a bug of the SAP API?
    Do you have any ideas?
    Here the Java Mapping we're using for adding an attachment (as a test):
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.DynamicConfigurationKey;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import com.sap.aii.mapping.api.Attachment;
    public class SUSAttaHandler extends AbstractTransformation {
         private static final DynamicConfigurationKey KEY_FILENAME    = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
         // Transform Method
         public void transform(TransformationInput in, TransformationOutput out)
                   throws StreamTransformationException {
              // An info message is added to trace
              getTrace().addWarning("JAVA Mapping AttaHandler called!");
              // Input payload
              String inData = convertStreamToString(in.getInputPayload().getInputStream());
              // dynamic configuration
              DynamicConfiguration conf = in.getDynamicConfiguration();
              String fileName          = conf.get(KEY_FILENAME);
              getTrace().addWarning("AttaHandler: FileName = " + fileName);
              String text = new String("This is an example for an attachment!");
              Attachment atta = out.getOutputAttachments().create("ExampleAttachment", "text/plain", text.getBytes());
              out.getOutputAttachments().setAttachment(atta);
              String outData = inData;
              try {
                   out.getOutputPayload().getOutputStream().write(outData.getBytes("UTF-8"));
              catch(Exception exception1) { }
         // convert Stream to String
         public String convertStreamToString(InputStream in){
              StringBuffer sb = new StringBuffer();
              try {
                   InputStreamReader isr = new InputStreamReader(in);
                   Reader reader = new BufferedReader(isr);
                   int ch;
                   while((ch = in.read()) > -1) {
                        sb.append((char)ch);}
                        reader.close();
              } catch(Exception exception) { }
              return sb.toString();
    Thanks for your help,
    Thorsten

    Hi,
    we created an OSS ticket for this problem and SAP created a SAP note.
    Here the number of the note: 0001501345
    I hope this will help you.
    Thorsten

Maybe you are looking for

  • Splitting does not work on a networked drive.

    My iPhoto Library is on a following networked drive connected by cat6. Linux:CentOS 4.2+samba 3.0.10-1.4E.12.2. In this environment, splitting photos does not work. When splitting photos, initially photos are splitted into two events. Then I change a

  • Se54 documentation

    Hi gurus! Does anyone have some documentation (reference guide) about using transaction se54? I need to create a maintenance dialog with its structure. But I don't completely understand how to achieve this using that transaction. Regards, Pavel Or ma

  • Directory Tab in httpd.conf

    Hi Does anybody know how to configure Directory Tag in httpd.conf, to eliminate access to directories under Oracle9iAS for different users (i.e. each user would have access to only one directory). Thank's, Tomaz

  • How to uninstall vsts....?

    hi ive installed a few vsts to use in logic pro, some worked , some didnt. one worked, and then when i added some more, i get au error message on the one that worked. strange. so i want to uninstall some of them. but they are not listed in my applica

  • XP on MacBook Pro - Issues.

    Hello, Running into an interesting issue... After successfully installing windows XP SP2, then attempting to install the Apple Drivers – all seems to be going well then it starts the video drivers instal and comes up with the "this has not been teste