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

Similar Messages

  • Java Mapping for Flat file

    hello SDNers,
    I am using JAVA mapping for converting FlatFlie IDoc to IDoc and i am using metadata for this.While downloading metadata from SAP system, the first segment in the data record is having level 2.
    1) What is the use of Level in metadata?
    2)  What is the Level for first segment in data record of metadata. Is it Level 1 or Level 2?
    3) I am facing an error while appending the node. Is it because of Level differs?
    Plese help me out and thanks in advance

    Hi,
    >>>I am using JAVA mapping for converting FlatFlie IDoc to IDoc and i am using metadata for thi
    why do you develop is from scratch is the code is already there - just copy and paste...
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
    >>>1) What is the use of Level in metadata?
    this shows how the nested segments in IDOC are to be understood
    >>>3) I am facing an error while appending the node. Is it because of Level differs?
    no, it becase your code is incorrect - the level velidation will be done at the receiver
    Regards,
    Michal Krawczyk

  • Java Mapping for JDBC Interface

    Hi,
    please help on java mapping for my jdbc interface.
    my java code for jdbc is:
    Created on May 7, 2008
    TODO To change the template for this generated file go to
    Window - Preferences - Java - Code Style - Code Templates
    package XiMappingDB2.com.xi.test;
    @author miracle
    TODO To change the template for this generated type comment go to
    Window - Preferences - Java - Code Style - Code Templates
    Created on May 2, 2008
    To change the template for this generated file go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    package com.xi.test;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.util.HashMap;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.api.AbstractTrace;
    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;
    @author kotla
    To change the template for this generated type comment go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    public class NameMerge implements StreamTransformation  {
         private Map param = null;   
         private MappingTrace trace = null;
         public void setParameter(Map param){       
         this.param = param;
         if (param == null) { 
         this.param = new HashMap();
         public void execute(InputStream input, OutputStream output)      
         throws StreamTransformationException {
         AbstractTrace trace = null;     
         String RESULT = new String();
         trace =      
         (AbstractTrace) param.get(             
         StreamTransformationConstants.MAPPING_TRACE);
         try {          
        //Create DOM parser
        DocumentBuilderFactory factory =   
        DocumentBuilderFactory.newInstance();     
        DocumentBuilder builder = factory.newDocumentBuilder();
         //Parse input to create document tree
         Document doc = builder.parse(input);
                    trace.addInfo(doc.toString());
          //          Map the elements          
        Node root = doc.getFirstChild(); // gets the root element
         NodeList children = root.getChildNodes();
          for (int item = 0; item < children.getLength(); item++) {
          if (children.item(item) instanceof Element) {
          root = (Element) children.item(item);
          NodeList ch = root.getChildNodes();
          RESULT = RESULT.concat(ch.item(0).getNodeValue() + " ");
          trace.addInfo(RESULT); }
          catch (Exception e) {           
               trace.addDebugMessage(e.getMessage());      
       //Return the output document
       String document_exit = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:Person2 xmlns:ns0=\"urn:xxxxx.com:test:mapping:lookups\"><RESULT>" 
       + RESULT               
       + "</RESULT></ns0:Person2>";
         insertDB(RESULT);
       try
            output.write(document_exit.getBytes());
             catch (IOException e1) {
            trace.addDebugMessage(e1.getMessage());
    public void insertDB(String DETAILS){
        Statement stmt = null;
        Connection conn = null;
        try {
          conn = getConnection();
          conn.setAutoCommit(false);
          stmt = conn.createStatement();
          stmt.execute("insert into KUMAR(DETAILS) values ('"DETAILS"')");
          //System.out.println ('"DETAILS"');
          conn.commit();
          stmt.close();   
          conn.close();
        } catch (Exception e) {
          System.err.println("Error: " + e.getMessage());
          e.printStackTrace();
      public Connection getConnection() throws Exception {
        String driver = "com.ibm.db2.jcc.DB2Driver";
        String url = "jdbc:db2://172.17.4.24:50000/SAMPLE";
        String username = "miracle";
        String password = "sairam";
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, username, password);
        return conn;
    but we are getting the following error:Linkage error occurred when loading class JavaDatabaseApp/XiMappingDB2/com/xi/test/NameMerge (http://FILE2JDBC_US, 7d7b3141-f4d1-11dc-b25e-d5d5c0a80198, -1)
    Start of test
    LinkageError at JavaMapping.load(): Could not load class: JavaDatabaseApp/XiMappingDB2/com/xi/test/NameMerge
    java.lang.NoClassDefFoundError: JavaDatabaseApp/XiMappingDB2/com/xi/test/NameMerge (wrong name: XiMappingDB2/com/xi/test/NameMerge) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:539) at java.lang.ClassLoader.defineClass(ClassLoader.java:448) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingLoader.findClass(RepMappingLoader.java:175) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping.load(RepJavaMapping.java:136) at com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping.execute(RepJavaMapping.java:50) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170).
    please solve this issue.

    Uday,
    May be you have uploaded class file into external definitions.
    You need to Zip the class file into .jar  and then upload into external definitions of integration repository
    Regards,
    Kiran Bobbala

  • Java mapping for Remove and Add of  DOCTYPE Tag

    HI All,
    i have one issue while the Java mapping for Remove and Add of  DOCTYPE Tag   in Operation Mapping .
    it says that , while am testing in Configuration Test "  Problem while determining receivers using interface mapping: Error while determining root tag of XML"
    Receiver Determination...
    error in SXMB MOni
    " SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="RCVR_DETERMINATION">CX_RD_PLSRV</SAP:Code>
      <SAP:P1>Problem while determining receivers using interface mapping: Error while determining root tag of XML: '<!--' or '<![CDATA[' expected</SAP:P1>
    plz provide solutions
    Thanks in advance.

    Hi Mahesh,
    I understand, you are using extended Receiver Determination using Operational Mapping (which has Java Mapping). And, there is an error message u201CError while determining root tag of XMLu201D, when you are doing configuration test.
    Can you please test, the Operational Mapping (which has Java Mapping) separately in ESR, with payload which is coming now. It should produce a XML something like this [Link1|http://help.sap.com/saphelp_nwpi711/helpdata/en/48/ce53aea0d7154ee10000000a421937/frameset.htm]
    <Receivers>
    <Receiver>
      <Party agency="016" scheme="DUNS">123456789</Party>
      <Service>MyService</Service>
    </Receiver>
    <Receiver>
      <Party agency="http://sap.com/xi/XI" scheme="XIParty"></Party>
      <Service>ABC_200</Service>
    </Receiver>
    </Receivers>
    If it is not (I Think it will not), then there is some problem in Java Mapping coding. Please correct it. Last option, if your Java code is small in length; you may paste it here, so that we can have a look at the cause of issue.
    Regards,
    Raghu_Vamsee

  • How  to config receiver http adapter for HTTP POST without XML tags ??

    Hi All,
    Can you please provide some infornation on How  to config receiver http adapter for HTTP POST (Request) without XML tags ?? Our receiving product doesn't support XML formats.
    Is there any option to bypass server authentication on the XI?
    If anybody has the same experience or know how to please provide inputs.
    Thanx
    Navin

    Hi,
    you can use xsl mapping for this in which u xtract
    the contents only but not the xml tag.
    Ranjit

  • Http_utl.text_write for http 'POST" does not work

    i have a proc that uses utl_http code I have seen all over on web sites for 'POST'ing to a REST web service ..... i use utl_http.write_text to write data to the request body but no data gets written ...... below are the code segments I use
    url entered directly into browser that **works fine**: http://www.media.com/admintool/Services.aspx?par_string=[{ "PAR_Transaction_Id" : 5566338, "MRI_Title_Name" : "4 Wheel & Off Road"}]
    calling routine:
    declare
    l_url varchar2 (300) := 'http://www.media.com/admintool/Services.aspx';
    l_data clob;
    l_query varchar2(32767);
    begin
    dbms_output.enable(3000000);
    l_data := '[{
    "PAR_Transaction_Id" : 5566338,
    "MRI_Title_Name" : "4 Wheel & Off Road"}]
    http_util_pkg.http_post(
    p_url_in => l_url, p_data_in => l_data);
    end;
    called routine segment:
    l_http_req := utl_http.begin_request (p_url_in, 'POST');
    -- Set the HTTP request headers
    utl_http.set_header(l_http_req, 'User-Agent', 'Mozilla/4.0');
    utl_http.set_header(l_http_req, 'content-type', p_data_type);
    utl_http.set_header(l_http_req, 'content-length', v_length);
    -- Write the data to the body of the HTTP request
    utl_http.write_text(l_http_req, 'par_string=');
    while v_index <= v_length
    loop
    utl_http.write_text(l_http_req, substr(p_data_in, v_index, 4000));
    dbms_output.put_line ('data = ' || substr(p_data_in, v_index, 4000));
    v_index := v_index + 4000;
    end loop;
    results .... you can see below that the header content length is non-zero but the response header says there is no content, so something is haywire with the write_text method
    url = http://www.media.com/admintool/Services.aspx
    length in data = 1271
    http package; url = http://www.media.com/admintool/Services.aspx
    after set authentication
    after write headers
    data = [{
    "PAR_Transaction_Id" : 5566338,
    "MRI_Title_Name" : "4 Wheel & Off Road"}]
    after write text
    status code: 200
    reason phrase: OK
    Connection: close
    Date: Tue, 06 Apr 2010 03:59:27 GMT
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    Cache-Control: private
    Content-Length: 0 *************** response header says no content !!!
    can you help me figure out what is wrong with the utl_http.write_text method ???
    thank you

    Please do not resurrect old threads - rather ask your question in a new thread. If need be, add a URL in your new thread posting that refers to the old thread. Also add as much relevant details as possible. Your Oracle version (all 4 digits). Your o/s. If possible, sample code and data that can be used as a test case. Complete error details. And what the intent of the code is (i.e. what the actual problem is that you're trying to solve).
    As for HTTP post - works just fine as far as I've used it.

  • Executing Java mapping for SAP XI using eclipse.

    Hi Experts,
    I want to create a java mapping for XI scenario in Eclipse IDE.
    Actually I need to import some jar files to get the following packages
    import com.sap.aii.mapping.api.*;
    import com.sap.engine.lib.xml.util.*;
    Can anybody tell me, where can I get these packages so that I can test my java mapping.
    Regards,
    Shri

    Hi Shripad,
    for location of jar files:->
               Ref : michal weblogs Frequently asked question.
    How to write java mapping and test->
               Ref:  Stefan weblog  How test simple java mapping.
    Before putting a forum, first go for search.
    Regards,
    Deviprasad.

  • HTTP authentication key for hand shake at receiver side for HTTP POST

    Hi All,
    HTTP post receiver system is expecting an authentication key to be send by PI HTTP_AAE adapter while posting XML message to them.
    The receiver system has a utility program in JAVA to validate this key. Has anyone done this kind of scenario in PI 7.31/7.4
    How does this simple authentication mechanism works? If this doesn't work, we have to rely on just uname/pwd but that is not really recommended for our landscape because of security concerns. So the key is the only better option as of now. Please help!!
    thx
    mike
    Attached some import packages used in the java util program in the receiver system. for  validating the authentication key send by PI
    import java.security.MessageDigest;
    import java.util.Calendar;
    import java.security.NoSuchAlgorithmException;
    import java.io.UnsupportedEncodingException;
    import java.io.IOException;
    import sun.misc.BASE64Encoder;
    import sun.misc.BASE64Decoder;
    I am not pasting the java program utility here due to proprietary reasons. thx for understanding

    Hi Michael
    You can construct the target URL to include the query parameter/value using Dynamic Configuration in Message Mapping.
    This previously worked on the ABAP HTTP adapter, but from the thread below it seems it is not supported on the HTTP_AAE. Not sure what version you are on, and if SAP has provided support for this in the latest SPs.
    HTTP_AAE Adapater - using of dynamic url parame... | SCN
    If HTTP_AAE approach can't work for you, you can use the SOAP adapter - check ASMA and "Do not use SOAP envelope"
    Here is a snippet of the code you can use in a UDF for your message mapping
       //write your code here
      DynamicConfiguration conf = (DynamicConfiguration)container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/SOAP", "TServerLocation");
    String url = "http://local.yahooapis.com/MapsService/V1/mapImage?appid=" + appid + "--&amp;street=" + street + "&city=" + city + "&zip=" + zip;
    conf.put(key, url);
    return appid;
    Rgds
    Eng Swee

  • Error in Java Mapping for Single XML conversion

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

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

  • Java mapping for EDI order document

    hi,
    My project is to convert a EDI-850 Purchase Order Document using XI into an R/3 system.I planned t use java mapping So,I had got the java code necessary for the mapping from a tool called ALTOVA XML MAPRFORCE.
    I have converted the code into a .jar file and put into the XI server.The mapping is working fine now. If i give an EDI order document as input to the mapping and test the mapping the out put is coming correctly.
    Now i dont know what I should do in the Integration directory.
    As I have to convert this document and post it in a R/3 system.I have found the function module to create a Purchase Order also "BAPI_PO_CREATE".
    What should I do next ?

    Hi Mithun,
    Follow the steps below:
    1. BAPI is a RFC function module. So you import into Integration Repository. Then map your output to the structure of RFC.
    2. In the integration Directory,
    a. Create a business service representing your source.
    b. Create a business system representing your R/3 system.
        Before creating business sytem, first you need to register it as a techincal system and business system in sld.
    c. Create a Sender Agreement to pick the message from source system. Depending upon the type of source system, you need to configure the sender adapter.
    d. Create Receiver determination to route the message to the target system
    e. Create interface determination to pick the current Interface mapping to convert source message to target message
    f. Create Receiver Agreement to send the message to R/3 System. This should encapsulate Receiver Communication channel which is using IDoc adapter.
    Reward if helpful.
    Regards,
    Suraj Kumar.

  • JAVA Mapping for SFDC integration

    Hello Friends,
    I am working on a R/3-SFDC integration.While pushing data from PI to SFDC it expects session ID and traget url and through java mapping we can acchive it.
    I have got Uarunas blog for java mapping which is very gud.
    http://wiki.sdn.sap.com/wiki/display/XI/SFDCIntegrationusingPI7.1-HowtoaddSOAPEnvelopeinJava+Mapping
    I have tried that code but it is not working, it is bulding the soap envelope but not fetching the session id from SFDC(might be it is not able to login to SFDC). Can anybody tell me how to pass the user id and password for this code.
    Regards,
    Jayesh.

    Check 2 things in your code?
    a) Are you passing your communication component name and receiver comm channel name in the code...?
    i.e  here..
    Channel channel = LookupService.getChannel("BC_SFDC","CC_Login");
    b) Check what namespace you use in loginxml  String.... use the one that is required for the target system?
    String loginxml = "<login xmlns=\"urn:enterprise.soap.sforce.com\"> <username>"

  • Java mapping for fixed length file in XI

    Can Anyone help me On this?

    Hi,
    This may Help you
    Check these for JAVA Mapping
    Java Mapping (Part I)
    Java Mapping (Part II)
    Java Mapping (Part III)
    Testing and debugging
    Testing and Debugging Java Mapping in Developer Studio
    Implermenting JAVA Mapping in PI
    Implementing a Java Mapping in SAP PI
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/400ee77e-f9d6-2a10-2b8c-99281a4dcf6b
    REgards
    Seshagiri

  • Java mapping for Dynamic File name: stuctures?

    Hi,
    Scenario:  Sender AS2 adapter --> PI --> Receiver File (NFS) Adapter. Just a file pass through, no mapping
    Requirement: Want to have the receiver file name as C1.yymmdd.C2 where C1 and C2 are contants and yymmdd is current date.
    I was told in sdn forum that I have to write java mapping and provided the sample code also. However, I am not sure how and where to use that sample code. Could you please help on following questions:
    1) What is the source and target data type structures for mapping?
    2) Where do I develop java mapping? How do I import to PI?
    3) How do I get access to SAP Netweaver Developer Studio? Can I download it to my laptop? or if I dont have access, can I use any other tool to develop? ( NetBeans, Eclipse ??) and how?
    4) what are the files and libraries that we need to import to java mapping? (e.g.,  Import aii_map_api.jar library)
    5) How to generate .jar file?
    If someone has already developed java mapping (.jar file) ready to import into PI, please provide the same.
    Thanks in advance
    - Riya Patil

    Hi Sarvesh,
    Is this UDF work if I dont select ASMP on sender side? (We tested selecting ASMP on both sender & receiver file adapters, it works fine and it works without UDF also).
    In my requirement I have to use sender AS2 adpter, please confirm if I can use this UDF without selecting ASMP on sender side.
    I have done the following tests:
    Test-1) Select ASMP with 'File Name' on both sender and receiver file adapters without any mapping (UDF)
    It works great. No UDF or mapping required. It is just pass through of file having the receiver file name same as in sender channel.
    Test-2) Select ASMP with 'File Name', only on receiver file adapter without any mapping (UDF)
    It is obvious, it doesn't work. I am getting the following error:
    Could not process due to error: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header
    Test-3) Select ASMP with 'File Name', only on receiver file adapter with mapping (using DynamicConfiguratio UDF)
    We are getting the following error message in SXMB_MONI:
    Fatal Error: com.sap.engine.lib.xml.parser.Parser~
    <SAP:Stack>com.sap.aii.utilxi.misc.api.BaseRuntimeException thrown during application mapping com/sap/xi/tf/_MM_Filename_: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack>
    Here is the code we have in UDF:
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String SourceFileName = "C1." + a + ".C2";
    conf.put(key, SourceFileName);
    return " ";
    So looks like UDF is not working and it is failing in mapping. If I could make it work, I think there is good chance that I can see DynamicConfiguration under SOAP Header, which what required for the error we see in out test-2.
    Can someone please help me to straighten this UDF and make it work.
    Thanks in advance.
    - Riya Patil

  • Java Mapping for attributes

    Hi experts
    I want to create a java map. My requirement is given below.
    I/P xml>>
    <?xml version="1.0" encoding="UTF-8"?>
    <TradeplaceMessage productionMode="production" xmlns="http://zhm.....">
    <TransportEnvelope>
    <Routing><To>abcd</To><From>
    I want to rename attribute value xmlns to a new name XSX
    Thanks in advance
    Dhanish Joseph

    Dhanish,
    Please check htis thread:
    How to add xmlns attributes in main node
    This should solve your query.
    Refer contribution from  "Fariha Ali ", where you have to implement java mapping and apply the code suggested in the thread.
    Let us know if issue still persists.
    Divyesh

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

Maybe you are looking for

  • SQL Query in Custom Security when creating Security Profile

    Hello all, I've created a security profile with Custom security and provided a simple query in Custom Security tab- PERSON.PERSON_ID = FND_GLOBAL.EMPLOYEE_ID Custom security option is "Restrict the people visible to each user using this profile" I am

  • MBP LED LCD Gradient Test - Software or Hardware issue?

    Hello! I've noticed some of the discussions around the new MBP's LED displays, and some people having issues with not-so-smooth gradients in LCDTest 1.1 or 2.0. My current, new, SR 15" MBP sports a darkish bar in the green area of the gradient, and a

  • Mac Book Pro-- no content in half of sent e-mails?

    Mac Book Pro--why do half of my recipients receive no content in my e-mails?

  • Acrobat and SEHOP Problem

    I've discovered a bug with Adobe Acrobat X on Windows 7: if SEHOP (http://support.microsoft.com/kb/956607) is enable, and Acrobat X is then installed, it will not successfully start.  Adding the "EULA" and "Launched" keys in HKCU allows the program t

  • SET mode processing versus ROW for Dimension targets

    Hi all, In OWB 10.2.0.2 I am using a relational implementation of a Dimension with 9 levels (and 2 hierarchies). I selected target load order and have run the mapping with SET processing and ROW based (target only). The problem is that the results ar