Hi Experts ,
I need to add this extra 2nd line in my generated xml output of graphical mapping.
<?xml version="1.0" encoding="UTF-8"?>
<?Siebel-Property-Set EscapeNames="false"?>
Is there any smart way to add this 2nd line? I have already created a graphical mapping for the message with complex lookups and do not wish change it much.
Thanks
Shamly.
Hi Shamly,
you can achieve that very smart with a second, non parsing ABAP mapping:
-use fm ECATT_CONV_XSTRING_TO_STRING to convert the source to string,
- search for "<?Siebel-Property-Set EscapeNames="false"?>"
- concatenate the both header and the xml payload
- use fm ECATT_CONV_STRING_TO_XSTRING to convert the string to result (XSTRING)
just a view lines,
Regards,
Udo
my suggestion is a simple java mapping and use normal string functions to achieve the result
Hi ,
I am tryin to achieve it with java mapping.
With what ext do you save the java code? I am trying to upload it to the operation mapping as the second mapping, but it is giving the error that the file does not contain a java program.
Thanks,
Shamly
You first write the java logic and store it in a .java file, then you compile this .java fiel and on proper compilation you get a .class file.......you can include this .class file into IR .... NWDS can be used in this case.
Regards,
Abhishek.
Hi experts,
I am using the shabarish' blog
/people/shabarish.vijayakumar/blog/2009/12/07/parametrized-java-mapping-in-pi-71-plus-some-other-delicacies
i am using the reference java code given within
http://wiki.sdn.sap.com/wiki/display/XI/ParametrizedJavaMappinginPI+7.1
I have copied the code and trying to compile it in eclipse.
This is giving me lot of error messages in eclipse - like- import com.sap cannot be resolved.
and it is generating a number of class files.
Can these errors be ignored?
Do i need to import all the class files created?
Thanks,
Shamly
Hi,
Those errors are cannot be ignored.
For java mapping, you have to import the jars below..
com.sap.aii.af.cpa.svc.api
com.sap.aii.af.lib.mod
com.sap.aii.af.ms.ifc_api
com.sap.aii.af.svc_api
com.sap.xpi.ib.mapping.lib
sap.comtcloggingjavaimpl
Regards,
Swetha.
Edited by: Swetha Reddy on Jan 13, 2010 10:17 AM
Check if the java mapping thing works (when the xml has completed its java mapping part , the next steps may enforce the tag to be ignored ).
This happened to me when i tried inserting < ! -- /> tag.
So finally I was required to create an adapter module (which is the last phase of processing ) for inserting the tag.
Hi Shamly,
You are on right path.
Use your graphical mapping (for complex lookup and other logic) after that use another Java Mapping ( to add <? ?> line) in Operational Mapping.
Use this bolg to develop Java Mapping /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
Hope this code will help you
import java.io.*;
import java.util.*;
import com.sap.aii.mapping.api.*;
public class DynamicMapping implements StreamTransformation {
private Map param;
public void setParameter(Map param) {
this.param = param;
}
public void execute(InputStream in, OutputStream out) throws StreamTransformationException {
try {
byte[] b = new byte [in. available ()]; // in.available() is in square brackets
in.read(b);
StringBuffer input = new StringBuffer( new String(b));
/*note " ' ' " in double Quotes we can have single Quotes.
/Here we are inserting <?Siebel-Property-Set EscapeNames='false'?> after <?xml version="1.0" encoding="UTF-8"?> i.e after ?> */
input.insert(input.indexOf("?>")+2, "<?Siebel-Property-Set EscapeNames='false'?>");
out.write(b.toString().getBytes());
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Edited by: Raghu Vamsee on Jan 13, 2010 7:22 PM
Hi,
I am trying to compile the code , it gives me the error
package com.sap.aii.mapping.api does not exist
what is the jar file required for this?
Thanks,
Shamly
aii_map_api.jar
"Where to get the libraries for XI development '
https://wiki.sdn.sap.com/wiki/display/XI/Where%20to%20get%20the%20libraries%20for%20XI%20development
![]()
The jar files required will be in your XI server (the wiki mentioned above will guide you through).....you need to have access to the folder/ machine where XI/ PI is installed.
Once you have the required jar file import it into the java compiler that you are using....in NWDS it can be done as follows:
NWDS --> Open your java mapping --> right-click on the mapping name in Project Explorer --> Properties --> JAVA Build Path --> Libraries --> Add External JAR --> select the jar and click OK......then compile....if there is no other error (syntax) then you will get the .class file.
Regards,
Abhsihek.
Hi,
I guess you can also do this by using a simple XSLT mapping after your grphical in the operation mapping. The cod efor the same is as given below:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Add the your desired field -->
<xsl:output method="xml" indent="no" omit-xml-declaration="no"
Siebel-Property-Set EscapeNames="false"/>
<!-- Identity Transform - copy the source XML to the output without any changes -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Warm Regards,
Anshul
Thank you very much for your answers and suggestions following which i got the desired result.
I used , second java mapping and compiled the code with NWDS.