Java Mapping - add DOCTYPE

Hello all -
I am getting the output in this format:
<xml version="1.0" encoding="UTF-8"?>
<Root>
<SubElement>Test</SubElement>
</Root>
How can i achieve the output in this format:
<xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE XYZ SYSTEM "http://xml.org/xyz.dtd">
<Root>
<SubElement>Test</SubElement>
</Root>
Please let me know how we can achieve this using Java Mapping and not XSLT.
Thanks,
Tirumal

Prateek -
Thanks for the response.
Do we have a step by step approach to how we have to use JAVA mapping?
My scenario is:
1. I am able to generate a cXML file from an IDOC ORDERS message type.
2. I am able to get the <!DOCTYPE ..> line added in the cXML file using the XSLT mapping but there appears to be two extra characters added at the end of the line with '[]'. Read related blogs, bloggers suggsted to use Java mapping as there appears to be a bug in SAP XSLT processor.
3. Since i am new to JAVA mapping, are there any blogs out there which gives us step by step approach to using JAva mapping for IDOC(s)/ORDERS message typ.
Thanks,
Tirumal

Similar Messages

  • Java Mapping - add external jar for runtime use

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

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

  • 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

  • JAVA mapping using SAX parser adds extra tags

    Hi,
      We are using  java mapping using a SAX parser.It works well in standalone application ie it parses correctly and gets our desired xml structure and the xml is well formed too but when we import it in XI as a jar file it does not throw any errors but adds extra start tags, as a result the output xml is not well formed.XI is adding extra start tags.
    If any one else has faced a similar situation please help.
    Regards,
    Anirban.

    Hi Roberto,
    Thank you for the response.
    As I said, it doesnt throw any error. It is working perfectly in standalone application. But when we deploy it to XI Server, it is not forming the well formed XML. We too are puzzled by this situation.
    Okay, i will explain my scenario here.
    The following is my input XML to the java pgm..
    <Header>
    </Header>
    <Body>
    </Body>
    <SubBody1>
    </SubBody1>
    <SubBody2>
    </SubBody2>
    <SubBody3>
    </SubBody3>
    <SubBody4>
    </SubBody4>
    <Trail>
    </Trail>
    The desired output is
    <Header>
      <Body>
         <NameChanged1>
            <NameChanged2>
    <SubBody3>
    <SubBody4>
    </SubBody4>
    </SubBody3>
    </NameChanged2>
    </NameChanged1>
    <Trail>
    </Trail>
    Just look at the SubBody2 and SubBody1 node, its tag name has been changed in the output XML. Thats y i have decided to use java mapping instead of message mapping.
    I have developed the code for everything, i.e for changing the tag name and for forming the nested xml and it is working fine as a standalone application. But while deploying it to XI, the output is not well formed. I dont know the reason for it. Even I have checked the cardinality of the output Data types, that I have created. Its perfectly okay with all.
    Any Ideas???
    Regards,
    Anirban

  • Add 1 single element in Java Mapping

    I have quite a simple requirement for my Java Mapping, however as I have done just message mappings and XSLT mappings maybe you could help how to achieve the following:
    I have an input message with attachment, what I want to do now is to read a string out of the attachment (this is already what I have done) and append a single element to the input message. No other elements should be changed.
    What would be a simple way to do this?
    Thank you very much
    Edited by: Florian G. on Nov 12, 2009 9:02 PM
    Edited by: Florian G. on Nov 12, 2009 9:03 PM

    Hi,
    You can access your attachements in:
    1. UDFs (by using package com.sap.aii.mappingtool.tf7.rt interface GlobalContainer method getInputAttachments())
    2. Java mappings (by using package com.sap.aii.mapping.api class TransformationInput method getInputAttachments())
    3. Adapter Modules
    For each area, you can find how to acccess the payloads by referring to the javadocs:
    http://help.sap.com/javadocs/pi/SP3/xpi/index.html?index-all.html
    They will all give you your attachment as text or binary data, but you will need to parse the data yourself. If your attachment itself is an XML as well, you might use DOM, SAX, stAX or other parsers if the structure is complex. Otherwise, a simple Java regex or  any simple String parsing will do as well for simple cases.
    Regards,
    S. Gökhan TOPÇ

  • Message and Java Mapping

    Hello -
    I have a java mapping and a message mapping implemented in one interface.
    Java mapping basically adds a header and does nothing else.
    Message mapping has all the mapping. Its not complex but straight.
    I have the Message mapping first and then the Java mapping in the Interface Mapping.
    what happens is i could see the headers written through Java mapping in my output xml file which is good but i cannot view the message mapping output in the file.
    Any ideas.
    Thanks,
    Tirumal

    Hi
    I am generating the headers in the java mapping using this:
    public void startDocument ()
    throws SAXException {               
    write("<?xml version='1.0' encoding='UTF-8'?>");
    write("<!DOCTYPE cXML SYSTEM 'http://xml.cxml.org/schemas/cXML/1.1.008/cXML.dtd'>");
    Maintain Order at Runtime is checked in the Interface Determination.
    Ok, in the interface Mapping Editor i get 2 messages:
    1.
    11:09:48 Start of test
    Call method execute of the application Java mapping com.sap.xi.tf._Orders_MM_
    Java mapping com/sap/xi/tf/_Orders_MM_ completed. (execute() of com.sap.xi.tf._Orders_MM_
    Call method execute of the application Java mapping com.sap.aii.mapping.api.SampleWithSaxParser
    Java mapping com/sap/aii/mapping/api/SampleWithSaxParser completed. (execute() of com.sap.aii.mapping.api.SampleWithSaxParser
    Executed successfully
    11:09:48 End of test
    2. XML not well formed
    None of the above messages seem to be of Message Mapping don't know why its not getting written in the output.
    Thanks,
    Tirumal

  • Java mapping help pls

    hi all,
    I've a source structure like this below in PI.
    <MAT>
    <doc type>pdf</doc type
    <subnumber>1234</subnumber>
    <id>45ABC<id>
    <matno>ABCD</matno>
    <filename>transaction1.pdf</filename>
    </MAT>
    target structure would be the same but one more field <filecontent> which is bytearray content such as content=[101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10]
    <MAT>
    <doc type>pdf</doc type
    <subnumber>1234</subnumber>
    <id>45ABC<id>
    <matno>ABCD</matno>
    <filename>transaction1.pdf</filename>
    <filecontent>bytearraycontent</filecontent
    </MAT>
    And target is HTTP post for posting the above attribute names and values in the body of HTML
    I am writing a java mapping program because I have to read the <filename> tag value from the incoming xml and read the file from PI server location and convert the file content to bytearray and also to map it to target structure for HTTP post. I am requesting help from java experts here in modifying the program according to this requirement. pls help
    package com.usahealth.mapping;
    import java.io.InputStream;
    import java.net.URL;
    import java.net.URLConnection;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    public class ReadAttrMap extends AbstractTransformation {
      @Override
      public void transform(TransformationInput in, TransformationOutput out)
      throws StreamTransformationException {
      AbstractTrace trace = null;
      try {
      // Initialize Trace
      trace = getTrace();
      // Get Input Message as DOM
      DocumentBuilderFactory docBFactory = DocumentBuilderFactory
      .newInstance();
      docBFactory.setNamespaceAware(true);
      DocumentBuilder docBuilder = docBFactory.newDocumentBuilder();
      Document inDoc = docBuilder.parse(in.getInputPayload()
      .getInputStream());
      inDoc.getDocumentElement().normalize();
      // Read from PayLoad  - here is where I need help to read the filename - convert it to byte array and read other xml tag values and pass  to target structure for HTTP post. I am using HTTP receiver adapter for posting
      } catch (Exception e) {
      trace.addInfo(e.getMessage());
      throw new StreamTransformationException("Mapping Exception: "
      + e.getMessage(), e);
    thx
    mike

    Indrajit, thx again
    So I believe, the java mapping has to be changed to not pass MAT for create element
    // building the target structure   Element target = newdoc.createElement("MAT");  - I have to remove this
    newdoc.appendChild(target);  - have to remove this.   Element doctype = newdoc.createElement(root.getChildNodes().item(1)  will be changed to item(0)
      .getNodeName()); 
    And also to add the logic for  [    ]
    String data = "["; 
    if (fileArray != null) { 
    for (int i = 0; i < fileArray.length; i++) { 
    if data = "[";
    data = data + fileArray[i]; 
    else
    if (i < fileArray.length - 1) { 
    data = data + ","; 
    endif.
    data = data + "]";
    is this right?
    thx indrajit
    -mike

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

  • 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

  • Add Doctype to the XML File

    Experts,
    My Scenario is JDBC to File
    For the resultant xml file i have to include a <DOCTYPE> after
    <?xml version="1.0" encoding="UTF-8" ?> while passing it to legacy system ?
    I had written an XSLT Code to acheive this, i checked in XML spy and it is working.
    but in moni iam getting an error in message mapping
    my XSLT Code is
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- Add the Doctype declaration -->
    <xsl:output method="xml" indent="no" doctype-system="http://integratex.quality.techdata.de:8080/ix/dtd/ixOrder.dtd"/>
    <!-- Identity Transform - copy the source XML to the output without any changes -->
    <xsl:template match="node() | @*">
                <ns0:MT_ASNDATAOUT xmlns:ns0="http://aaaaa/sd/SD152.25">
                <xsl:copy>
                                                    <xsl:apply-templates select="node() | @*"/>
                </xsl:copy>
                </ns0:MT_ASNDATAOUT>
    </xsl:template>
    </xsl:stylesheet>
    and the error in moni is
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <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">GENERIC</SAP:Code>
      <SAP:P1>Parsing error after multi mapping.</SAP:P1>
      <SAP:P2>Expected Message<i> instead of Messages</SAP:P2>
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Parsing error after multi mapping.Expected Message<i> instead of Messages</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Iam doing multi mapping between source and target, is m ulti mapping causing the issue?
    and also check my xslt code,it is working in xml spy as desired.
    Please help me on this
    Appreciate your help.
    Thanks
    Srinivas

    Hi,
    Yes you have to chnage the DTD structure to add DOCTYPE Value,one morething when you executing XSLT mapping Multi Mapping scenario it shouls also supports multi mapping feature.Fisrt execute XSLT Mapping program without multi mapping,let me know how its behaving.
    Regards,
    Raj

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

  • Problem with Java Mapping

    Hello experts,
    I developed a Java Mapping Programm for reading filename of a pdf file and giving filename to a rfc structure for calling a rfc module. Thus, I test it via testing interface method and implementing a main method in my mapping class, which works, but if I run it in the integration server  I get the following exception:
    MP: Exception caused of com.sap.aii.af.ra.ms.api.RecoverableException: java.lang.StringIndexOutOfBoundsException: String index out of range: -7: com.sap.aii.af.rfc.afcommunication.RfcAFWException: java.lang.StringIndexOutOfBoundsException: String index out of range: -7
    That is the execute method of my class:
         public void execute(InputStream inputStream, OutputStream outputStream)
              throws StreamTransformationException {
              // TODO Auto-generated method stub
              try { //The following is for the FileName in the File Adapter
                   DynamicConfiguration dynamicconfiguration =
                        (DynamicConfiguration) map.get("DynamicConfiguration");
                   DynamicConfigurationKey key =
                        DynamicConfigurationKey.create(
                             "http://sap.com/xi/XI/System/File",
                             "FileName");
                   String myFileName = dynamicconfiguration.get(key);
                   MappingTrace trace = null;
                   trace.addInfo(myFileName);
                   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   TransformerFactory tf = TransformerFactory.newInstance();
                   Transformer transform = tf.newTransformer();
                   Document docout = db.newDocument();
                   Element root = docout.createElement("Z_SD_WEB_HP_INVOICE_STATUS");
                   root.setAttribute(
                        "xmlns:ns1",
                        "urn:sap-com:document:sap:rfc:functions");
                   docout.appendChild(root);
                   Element docName = docout.createElement("IM_DOCNAME");
                   root.appendChild(docName);
                   Text srcxml = docout.createTextNode(myFileName);
                   docName.appendChild(srcxml);
                   DOMSource domS = new DOMSource(docout);
                   transform.transform((domS), new StreamResult(outputStream));
              } catch (Throwable throwable) {
                   throwable.printStackTrace();
    If I test via main method and testing interface mapping  the generated xml is like:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?><Z_SD_WEB_HP_INVOICE_STATUS xmlns:ns1="urn:sap-com:document:sap:rfc:functions"><IM_DOCNAME>232132.pdf</IM_DOCNAME></Z_SD_WEB_HP_INVOICE_STATUS>
    I do not understand why I get this error in real environment.
    Kind regards,
    Erkan

    Hello experts,
    I found the solution. I will also publish this solution, this is also a point which I sometimes missing here in this forum:
    In creating the rfc-xml with java mapping, so a prefix should be add to the name of the rfc-structure e.g.
    ns1:Z_RFC_CALL. If this prefix is missing, then you get this error:
    com.sap.aii.af.ra.ms.api.RecoverableException: java.lang.StringIndexOutOfBoundsException: String index out of range: -7: com.sap.aii.af.rfc.afcommunication.RfcAFWException: java.lang.StringIndexOutOfBoundsException: String index out of range: -7
    To find this I create a grafical test mapping and I check the test rfc-xml with the java created xml.
    Anyway thanks all for the published recommendations.
    Kind regards,
    Erkan

  • 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

  • Why doesn't the scatter graph display properly??

    Hi, I've already posted a thread regarding scatter graph but nobody (not even from Macromedia!) has been able to give me an answer and I've been trying on my own since then, but to no avail! I refer to WhazzInAName said on Dec 31, 2004 at 9:51 AM on

  • PS CC "Could not complete Video Frames to Layers command because DynamicLink is not available" help?

    I'm running Windows 8.1 64-bit, AMD fx-6300, geforce gtx-760, 8gb RAM. All legitimately obtained, before you ask! Really bothered by this, when trying to make a gif, apparently "DynamicLink" is not available. Damn.

  • Logic crashes when loading preferences

    hi! can anyone please help? for some reason logic has started crashing when loading the preferences. i noticed for some reason it was playing through the built in audio rather than my motu interface, so i tried loading the preferences to change it an

  • How many disks?

    I have recently purchased Adobe Premiere Pro CS3 and did not make progress about how many HD are preferable to speed up this application and specially the rendering + export to DVD : the Help pages are still very vague...like in my old version 1.0 !

  • App Error on 8350i

    Hi, I installed a memory card a few days ago on my BB 8350i and it was working fine, then yesterday the phone restarted a couple of times non-stop, i removed battery and removed memory card, then inserted the batter back to the phone and now it says