Missing method in XI java mapping
I am developing a java mapping in XI and experiencing a strange problem.
The java code I am writing works fine with oracle Jdeveloper, but when I copy it to the XI java editor - I recieve an error message indicating that the method I am using (getTextContent of the Element class) is missing.
the Jdeveloper and XI are using the same jre (1.5.0_06).
what could be the problem?
what version of pi system?
if using pi 7.0 ,you should use the jdk 1.4 complie your java class.
in jdk 1.4 get the text should use the following method :
element.getFirstChild.getNodeValue();
the method getTextContent is avaiable since jdk1.5
Regards zhang peng
Similar Messages
-
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 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
ChristianHi 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 -
Call ABAP FM from XI Java mapping
Can you please provide me some documentation on how to make a call to ABAP function module from Java mapping.
Basically this would be a RFC lookup from Java mapping.
Any recomendations on which one is a standard approach among ABAP Mapping vs JAVA mapping within XI.
Your responses are appreciated.
TNVHi TNV,
<i>I am more looking into using RFC call from java mapping.</i>
The article by Michal can be used to make the RFC lookup not only from an User Defined Function but also from a java mapping.
You can write any piece of java code inside the EXECUTE() method of your Java Mapping including the RFC Lookup API code in michal's article.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-code-samples/xi%20mapping%20lookups%20rfc%20api.pdf
Regards.
Bhavesh -
Java Mapping (Validation)
Hi Guys
Validations using Java for those not having PI7.1
I followed this blog for validation of XML.
I have coded the JAVA Program in NWDS as per the blog, all fine but am not sure about the schema step.
What i did was:
1) Exported the .xsd of the Message type.
2) Then Schema.xml file creation i am not sure of it
Do any one know how to do that , and what is the purpouse of the Schema method in the Java Mapping.
Is this blog does a input initerface format check and write in to a log.
But cannot we do this with the help of Alert by triggering mails ??
Can we achieve element level vaslidation (to all element of the XML) using this method.
Kindly share u r views
SriniHi Santosh,
Thx for u r reply.
I understood what u r saying .
One more question :
See u r Doc is validating particular element , date and time using api.All good, what if i need to validate entire XML Elements , should i repeat the same for entire element.
i was so curious with his blog because , it was generic and moreover i thought i can validate entire XML , by not sticking to particular element.
What is IA ?? U Memtioned ??
Could above requirment can be achieverd r else i should get each element and validate , no other go
based upon on the outbound interface
regards
srini -
Java.lang.RuntimeException: Uncompilable source code - missing method body
Hi,
I am getting the following error at runtime
java.lang.RuntimeException: Uncompilable source code - missing method body, or declare abstractwhen I try to instantiate a class using reflexion as following:
MyInstance = MyClass.newInstance(); I have tried to find some explanation using Google, but could not find any that fit my case. MyClass's implementation has a public constructor with no parameter. There is no error at compile time when cleaning and building all code.
Anyone has tips about what could cause this error?
Thanks.Jrm wrote:
It is not my code originally... You are making far too many unchecked assumptions about the reality of this situation to even get close to what that reality it is... Get over patronizing, it would improve your social/people skills... Thanks !It is your own problem that you perceive something as patronizing, while in fact it was only an honest and straight to the point attempt to help you. This forum does not deal in sensitivity, it gets in the way of helping people to see the error of their ways. -
Namespace missing in java mapping DOM ?
Hi,
I am creating java mapping using DOM, but why i cannot create a namespace using this code ?
Document targetDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// create source and result wrappers and perform transformation
DOMSource source = new DOMSource(targetDoc);
StreamResult result = new StreamResult(outputStream);
transformer.transform(source, result);
expected result in xml :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Vendor_SQL xmlns:ns0="urn:sap-com:atp:ABC40:base">
</ns0:Vendor_SQL>
result :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Vendor_SQL>
</ns0:Vendor_SQL>
Please advise whether i was missing any other required step ?
Note : testing using NWDS 7.0 SP 17
Thank You and Best Regards
FernandHi Lesmana,
Can you change the second line in the code like below and give a try::
Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("ns1:urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));
Regards,
---Saish -
Problems with loading native library/missing methods:no ttJdbcCS in java.li
Iam facing one problem while connecting the timesten client to the server The SQL Exception which Iam getting is pasted below:-
Problems with loading native library/missing methods: no ttJdbcCS in java.library.path
I am working with MAC OS X 10.7.2 and my timesten client version is 11.2.1.0
I have also changed the Java Preferences from 64-bit to 32-bit but still whenever i tried to connect with the SQL Developer it gives me the above error.I just tried this out. My environment is OS X 10.7.4, Timesten (32-bit) client 11.2.1.9.0, SQL Developer 3.1.07, Oracle Java 1.7.0_04.
The key things you need to be sure to do (in a terminal window) are:
1. Be sure to . in the TimesTen environment script <tt_install_dir>/bin/ttenv.sh to set the full TT environment.
2. Change directory to SQLDeveloper.app/Contents/Resources/sqldeveloper
3. Run 'sh sqldeveloper.sh -J-d32'
and all should be fine.
Note that if you are using Java7 as I am then there is a step 1a. Change the CLASSPATH environment variable to specify ttjdbc6.jar not ttjdbc5.jar. For some reason running the app directly from Finder does not work even if you add -J-d32 into the sqldeveloper launch script. I'm still looking into that.
Chris -
Call method execute of the application Java mapping
Hi,
I'm using a RFC Lookup in a Java Mapping. In PI 7.0 it was working fine. Now we use the Mapping in our PI 7.30 Testsystem and I get following LookupException:
Error when calling an adapter by using the communication channel CC_Receiver_RFC_XXXXX (Party: , Service: BS_ERP_XXX_400, Object ID: 445eef339f2039b0856093c54c3656dd) The channel with object ID 445eef339f2039b0856093c54c3656dd could not be found in the Integration Server Java Cache. Check if the channel exists in the Integration Builder Directory and execute a refresh of the Java Cache
The Channel name and Business Service Name are correct. If I look in the Integration Builder, my Communication Channel is working fine.
I did a complete restart, the error afterwards was all the same. How can I refresh the cache for the ID's?.
I checked the party name it's having the space value not with *.
Thanks
Naresh N
Edited by: Naresh Nelapatla on Feb 25, 2012 5:46 AMHello,
Error when calling an adapter by using the communication channel CC_Receiver_RFC_XXXXX (Party: , Service: BS_ERP_XXX_400, Object ID: 445eef339f2039b0856093c54c3656dd) The channel with object ID 445eef339f2039b0856093c54c3656dd could not be found in the Integration Server Java Cache. Check if the channel exists in the Integration Builder Directory and execute a refresh of the Java Cache
This error usually happens when you have created the RFC Receiver that has an entry of * in the Party. What you can do is to recreate the CC and remove the entry in the party. Save and activate.
Hope this helps,
Mark -
Passing Parameters via Post Method from Webdynpro Java to a web application
Hello Experts,
I want to pass few parameters from a web dynpro application to an external web application.
In order to achieve this, I am referring to the below thread:
HTTP Post
As mentioned in the thread, I am trying to create an additional Suspend Plug parameter (besides 'Url' of type String) with name 'postParams' and of type Map.
But when I build my DC, I am getting the same error which most of the people in the thread have mentioned:
Controller XXXCompInterfaceView [Suspend]: Outbound plug (of type 'Suspend') 'Suspend' may have at most two parameters: 'Url' of type 'string' and 'postParams' of type 'Map'.
I am using SAP NetWeaver Developer Studio Version: 7.01.00
Kindly suggest if this is the NWDS version issue or is it something else that I am missing out.
Also, if it is the NWDS version issue please let me know the NWDS version that I can use to avoid this error.
Any other suggestion/alternative approach to pass the parameters via POST method from webdynpro java to an external web application apart from the one which is mentioned in the above thread is most welcome.
Thanks & Regards,
AnuragHi,
This is purely a java approach, even you can try this for your requirement.
There are two types of http calls synchronous call or Asynchronous call. So you have to choose the way to pass parameters in post method based on the http call.
if it is synchronous means, collect all the values from users/parameters using UI element eg: form and pass all the values via form to the next page is nothing but your web application url.
If it is Asynchronous means, write a http client in java and integrate the same with your custom code and you can find an option for sending parameters in post method.
here you go and find the way to implement Asynchronous scenario,
http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload
http://download.oracle.com/javase/tutorial/networking/urls/readingWriting.html
http://digiassn.blogspot.com/2008/10/java-simple-httpurlconnection-example.html
Thanks & Regards
Rajesh A -
Hi friends,
I am tryin java mapping for first time.. and created one java program using link https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/wholePayloadtoaXML+field
But when I am compiling it using JAVAC, I am getting following error message that
package com.sap.aii.mapping.api does not exist . How can I solve this error.
Complete error is as follows:
C:j2sdk1.4.2_16-x64 in>javac PayloadToXMLField.java
PayloadToXMLField.java:1: package com.sap.aii.mapping.api does not exist
import com.sap.aii.mapping.api.StreamTransformation;
^
PayloadToXMLField.java:2: package com.sap.aii.mapping.api does not exist
import com.sap.aii.mapping.api.AbstractTrace;
^
PayloadToXMLField.java:3: package com.sap.aii.mapping.api does not exist
import com.sap.aii.mapping.api.StreamTransformationConstants;
^
PayloadToXMLField.java:8: cannot resolve symbol
symbol : class StreamTransformation
location: class PayloadToXMLField
public class PayloadToXMLField implements StreamTransformation {
^
PayloadToXMLField.java:16: cannot resolve symbol
symbol : class AbstractTrace
location: class PayloadToXMLField
AbstractTrace trace;
^
PayloadToXMLField.java:27: cannot resolve symbol
symbol : class AbstractTrace
location: class PayloadToXMLField
(AbstractTrace) param.get(
^
PayloadToXMLField.java:28: cannot resolve symbol
symbol : variable StreamTransformationConstants
location: class PayloadToXMLField
StreamTransformationConstants.MAPPING_TRACE);
^
PayloadToXMLField.java:43: cannot resolve symbol
symbol : variable outputPayload
location: class PayloadToXMLField
outputPayload =
^
PayloadToXMLField.java:50: cannot resolve symbol
symbol : variable outputPayload
location: class PayloadToXMLField
out.write(outputPayload.getBytes());
^
9 errors
Thanks,
Brijesh Sonithanks , it is done now..
the program is compiled properly and class file is generated.
but m gettin error in mapping.
in IR i created two message type with data type as string.
and i had imported the class file and java program using Imported archives.
now in interface mapping mapping program i had selected type as Java Class.and name of java program.
but when i tested it, it is giving error as Linkage error occurred when loading class zip/PayloadToXMLField
Please suggest, M i doing some thing wrong?is any thing missing?
Program tht i had used in java
from link (https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/wholePayloadtoaXML+field):
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import java.util.Map;
import java.io.*;
public class PayloadToXMLField implements StreamTransformation {
String strXML = new String();
String outputPayload = new String();
//Declare the XML tag for your XML message
String StartXMLTag = "<Payload>";
String EndXMLTag = "</Payload>";
AbstractTrace trace;
private Map param = null;
public void setParameter(Map param) {
this.param = param;
public void execute(InputStream in, OutputStream out) {
trace =
(AbstractTrace) param.get(
StreamTransformationConstants.MAPPING_TRACE);
trace.addInfo("Process Started");
try {
StringBuffer strbuffer = new StringBuffer();
byte[] b = new byte[4096];
for (int n;(n = in.read(b)) != -1;) {
strbuffer.append(new String(b, 0, n));
strXML = strbuffer.toString();
} catch (Exception e) {
System.out.println("Exception Occurred");
outputPayload =
"<?xml version="1.0" encoding="UTF-8"?>"
+ StartXMLTag
+ strXML
+ EndXMLTag;
try {
out.write(outputPayload.getBytes());
trace.addInfo("Process Completed");;
} catch (Exception e) {
trace.addInfo("Process Terminated: Error in writing out payload");;
and detailed trace of error is:
11:34:21 Start of test
LinkageError at JavaMapping.load(): Could not load class: zip/PayloadToXMLField
java.lang.NoClassDefFoundError: zip/PayloadToXMLField (wrong name: PayloadToXMLField) 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_0.transform(MapServiceRemoteObjectImpl0_0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:319) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:200) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:136) 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:102) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)
11:34:21 End of test -
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,
ErkanHello 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 -
Hi,
I have currently created a java mapping which unzips files and transforms plain text/falt files to xml according to a specific structure... So far so good. This stuff works perfectly when testing interface mapping in the repository. However at runtime it does not work, and this is where you clever guys come into the picture:-)
It should be mentioned that the zip-file is dropped on a MQ-queue and picked up in XI and passed on to a BPM - the only thing the BPM does is to perform the java mapping and afterwards send one of the messages to R/3 and the other to CRM.
The concrete error given at runtime in the PE is:
Error handling for work item 000000718016
Work item 000000718016: Object CL_SWF_XI_MSG_BROKER method CALL_TRANSFORMATION cannot be executed
Parsing error before mapping: unexpected end-of-file (line 1, column 1)
Hope somone can help me on this matter,
Best regards,
Daniel
PS: In case it is of interest/use the java code used is this:
package dk.post.xi.unzipAndConvert;
import java.io.*;
import java.util.Map;
import java.util.HashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
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;
public class UnzipMain implements StreamTransformation {
private MappingTrace mappingTrace = null;
private Map param = null;
private StringBuffer currentXmlRecord = new StringBuffer();
private StringBuffer currentPlainRecord = new StringBuffer();
private int[][] dataRanges = null;
private char[] charsInCurrentRange = new char[650];
private String[] xmlTagNames = null;
/* (non-Javadoc)
@see com.sap.aii.mapping.api.StreamTransformation#setParameter(java.util.Map)
Method must be implemented when class is implementing streamTransformation
public void setParameter(Map param) {
this.param = param;
if (param == null) {
this.param = new HashMap();
(non-Javadoc)
@see com.sap.aii.mapping.api.StreamTransformation#execute(java.io.InputStream, java.io.OutputStream)
Main function -- called by XI to start execution of java mapping
public final void execute(InputStream in, OutputStream out)
throws StreamTransformationException
//if no input, then cancel program execution
if (in == null) {
throw new RuntimeException("Something wrong with input zip file - is null");
//input <> null. Begin upzip operation
try {
//test is only relevant outside of XI
if (param != null) {
mappingTrace = (MappingTrace) param.get(StreamTransformationConstants.MAPPING_TRACE );
ZipInputStream zip = null;
try {
zip = new ZipInputStream(in);
ZipEntry ze = null;
out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><ns0:Messages xmlns:ns0=\"http://sap.com/xi/XI/SplitAndMerge\">".getBytes());
while ((ze = zip.getNextEntry()) != null) {
writeDebugInfo("File: " + ze.getName() + " with compressed size: " + ze.getCompressedSize());
scrutinize(zip,(ZipEntry) ze, out);
out.write("</ns0:Messages>".getBytes());
finally {
if (zip != null)
zip.close();
out.flush();
out.close();
} catch (Exception e) {
throw new RuntimeException(e + "\nSomething went wrong...");
//Unzip flat files and convert to xml
private void scrutinize(ZipInputStream inStream,ZipEntry zipEntry, OutputStream outstream) throws Exception {
long start = System.currentTimeMillis();
InputStreamReader inStreamReader = null;
BufferedReader buffReader = null;
byte[] xmlBytes = null;
try {
inStreamReader = new InputStreamReader(inStream);
buffReader = new BufferedReader(inStreamReader);
boolean masterData = zipEntry.getName().equals("PD-01-STAMDATA.DAT");
boolean creditData = zipEntry.getName().equals("PD-02-KREDITVURDERING.DAT");
String currentLine = null;
if (masterData) {
writeDebugInfo("- Begin reading and converting every line of MasterData..."); //out-comment this outside of XI, or compilation will fail (functionality is only available in XI)
outstream.write("<ns0:Message1><ns1:masterData_MT xmlns:ns1=\"http://pdk/xi/kob/importDataToSap\">".getBytes());
while ((currentLine = buffReader.readLine()) != null) {
//convert one line of credit data plain into an xml record structure
makeXmlRecord(currentLine,true);
//Write record XML to XI's outputstream (appends)
xmlBytes = currentXmlRecord.toString().getBytes();
outstream.write(xmlBytes);
outstream.write("</ns1:masterData_MT></ns0:Message1>".getBytes());
writeDebugInfo("- Finished reading and converting every line of MasterData..."); //out-comment this outside of XI, or compilation will fail (functionality is only available in XI)
if (creditData) {
writeDebugInfo("- Begin reading and converting every line of CreditData...");
outstream.write("<ns0:Message2><ns1:creditData_MT xmlns:ns1=\"http://pdk/xi/kob/importDataToSap\">".getBytes());
while ((currentLine = buffReader.readLine()) != null) {
//convert one line of credit data plain into an xml record structure
makeXmlRecord(currentLine,false);
//Write record XML to XI's outputstream (appends)
xmlBytes = currentXmlRecord.toString().getBytes();
outstream.write(xmlBytes);
outstream.write("</ns1:creditData_MT></ns0:Message2>".getBytes());
writeDebugInfo("- Finished reading and converting every line of CreditData...");
} finally {
long timeUsed = System.currentTimeMillis() - start;
writeDebugInfo(zipEntry.getName() + " - Write took: " + timeUsed + " ms");
writeDebugInfo("Final statement entered...\n");
//check for invalid xml chars (plus a few other strange chars) in a plain text record and if any are found update the ranges of so they correspond to the new length of a record
private int[][] checkRange(String currentPlainLine, boolean isMasterData) {
int counter = 0;
int beginRange = 0;
int endRange = 0;
//populate array with proper data ranges/intervals according to how data is to be split
dataRanges = isMasterData ? new int[][] {{0,2},{2,12},{12,44},{44,47},{47,50},{50,295},{295,298},{298,356},{356,426},{426,496},{496,499},{499,506},{506,510},{510,518},{518,540},{540,546},{546,552},{552,558},{558,564},{564,570},{570,576},{576,582},{582,588},{588,594},{594,604}} : new int[][] {{0,2},{2,12},{12,20},{20,23},{23,26},{26,29},{29,44}};
//ensure stringbuffer is empty
currentPlainRecord.delete(0,currentPlainRecord.length());
//insert the current plain text line into stringbuffer
currentPlainRecord.append(currentPlainLine);
//loop through outer array (array of ranges)
for (int i = 0; i <= (dataRanges.length-1); i++) {
beginRange = dataRanges<i>[0];
counter = beginRange;
endRange = dataRanges<i>[1];
//loop through stringbuffer, based on the value-pairs of ranges/intervals in array of arrays
while (counter < endRange) {
switch (currentPlainRecord.charAt(counter)) {
case '&':
currentPlainRecord.insert(counter+1,"amp;"); //insert 'amp;' after '&', so that syntax conforms to xml syntax requirements (&)
counter += 5; //increment counter so that it continues after insertet characters
updateRange(counter,4); //update the array of ranges so that is corresponds to the new range
break;
case '\'':
currentPlainRecord.replace(counter,counter+1,"&"); //replace '\'' with '&'
currentPlainRecord.insert(counter+1,"apos;"); //insert 'apos;' after '\'', so that syntax conforms to xml syntax requirements (')
counter += 6; //increment counter so that it continues after insertet characters
updateRange(counter,5); //update the array of ranges so that is corresponds to the new range
break;
case '"':
currentPlainRecord.replace(counter,counter+1,"&"); //replace '"' with '&'
currentPlainRecord.insert(counter+1,"quot;"); //insert 'quot;' after '"', so that syntax conforms to xml syntax requirements (")
counter += 6; //increment counter so that it continues after insertet characters
updateRange(counter,5); //update the array of ranges so that is corresponds to the new range
break;
case '<':
currentPlainRecord.replace(counter,counter+1,"&"); //replace '<' with '&'
currentPlainRecord.insert(counter+1,"lt;"); //insert 'lt;' after '&', so that syntax conforms to xml syntax requirements (<)
counter += 4; //increment counter so that it continues after insertet characters
updateRange(counter,3); //update the array of ranges so that is corresponds to the new range
break;
case '>':
currentPlainRecord.replace(counter,counter+1,"&"); //replace '>' with '&'
currentPlainRecord.insert(counter+1,"gt;"); //insert 'gt;' after '&', so that syntax conforms to xml syntax requirements (>)
counter += 4; //increment counter so that it continues after insertet characters
updateRange(counter,3); //update the array of ranges so that is corresponds to the new range
break;
case 0x7F:
currentPlainRecord.replace(counter,counter+1," "); //replace 0x7F with ' '
writeDebugInfo("-- Corrected the character 0x7F ('') to ' '");
counter++;
break;
case '':
currentPlainRecord.replace(counter,counter+1," "); //replace 0x91 ('') with ' '
writeDebugInfo("-- Corrected the character '' to ' '");
counter++;
break;
case '':
currentPlainRecord.replace(counter,counter+1," "); //replace 0x9B ('') with ' '
writeDebugInfo("-- Corrected the character 0x9B to ' '"); counter++;
break;
case '':
currentPlainRecord.replace(counter,counter+1," "); //replace '' with ' '
writeDebugInfo("-- Corrected the character '' to ' '");
counter++;
break;
default :
counter++;
break;
return dataRanges;
//update array of ranges so that is corresponds to the new range
private void updateRange(int currentRange, int updateRangeBy) {
for (int k = currentRange; k < dataRanges.length; k++) {
if (k != currentRange) { //never update begin interval for the current range - only for the remaining intervals
dataRanges[k][0] += updateRangeBy;
dataRanges[k][1] += updateRangeBy; //always update end intervals
//convert one flat record line to a xml record structure
private void makeXmlRecord(String currentPlainLine,boolean isMasterData) {
dataRanges = checkRange(currentPlainLine,isMasterData);
//clear StringBuffer
currentXmlRecord.delete(0,currentXmlRecord.length());
//get the correct set of xml tags to be used when performing mapping between plain text and xml
if (isMasterData) {
xmlTagNames = new String[] {"dum1","kob_no","dum2","corp_status","legal_form","dum3","pr_protec_code","dum4","uri","email","emp_no_grp_code","exact_no_emp","dum5","founding_date","dum6","main_industry_code","industry_code1","industry_code2","industry_code3","industry_code4","industry_code5","industry_code6","industry_code7","industry_code8","dum7"};
} else {
xmlTagNames = new String[] {"dum1","kob_no","rating_date","rating_value","risc_grp_code","currency","max_credit"};
//copy all chars in stringBuffer to the specified char[]
currentPlainRecord.getChars(0,currentPlainRecord.length(),charsInCurrentRange,0);
//populate XML record structure
currentXmlRecord.append("<record>");
for (int i = 0; i < xmlTagNames.length; i++) {
currentXmlRecord.append("<" + xmlTagNames<i> + ">");
currentXmlRecord.append(charsInCurrentRange,dataRanges<i>[0],(dataRanges<i>[1])-(dataRanges<i>[0]));
currentXmlRecord.append("</" + xmlTagNames<i> + ">");
currentXmlRecord.append("</record>");
//write debug information to correct "place"
private void writeDebugInfo(String debugInfo) {
if (mappingTrace == null) {
System.out.println("Debug: " + debugInfo);
} else {
mappingTrace.addInfo("Debug: " + debugInfo);Hi Alex,
Thanks for your reply. First of all I was wondering if I missed something somewhere in my generel understanding of XI and BPM's!? - I kind of sense some irony/sarkasm in beginning of your reply:-) As far as I know BPM should have no trouble receing non-xml (in my case zip-files)!?
Anyways here goes:
1. Yes, this is also my impression that is should be possible somehow (we do currently run sp14). However, I havent yet figured out how to do it in this case. When trying to create interface mapping between the three involved software components, I get a 'MESS_MULTI_MAP_IF_WRONG_SWCV' three times. I've searched around without being able to find any information on the error. I does seem, though, like the problem is that all objects aren't in the same software component!! But this approach is of course the prefered one...
2. Well - you got me there. Kind of expected someone to point that out:-) This is of course something to be looked into also in order to "improve"/"enhance" the program - though it, as already pointed out, works perfectly as is.
3. This part I have also thought about - though quickly moved away from the idea, but that is only due to lacking insight/knowhow on the subject. Interesting weblog you have written, something so I will investigate further when time allows for it:-)
Best regards,
Daniel -
Hello Gurus,
I'm performing a RFCLookUp in Java Mapping with PI 7.1 (I can't use a Message Mapping), the XML I use to do the request is:
<n:ZHRBAPINOMINA xmlns:n="urn:sap-com:document:sap:rfc:functions">
<PERNR>30</PERNR>
</n:ZHRBAPINOMINA>
The error i'm getting is:
error while processing the request to rfc-client: com.sap.aii.adapter.rfc.afcommunication.RfcAFWException:
error while processing message to remote system:com.sap.aii.adapter.rfc.core.client.RfcClientException: could not get functionname from XML requst:
com.sap.aii.adapter.rfc.RfcAdapterException: failed to read funtionname from XML document:
missing namespace declaration(2)
What could cause this error?
Thanks in advance.
Xavi.Hello Raj,
we are using a java mapping because we have to encript a pdf file with a password.
We are calling the adapter in the java mapping, see wha we are doing:
public static String RFCLookup( String sTabla , String sValue , String sName )
String sAux1;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
factory.setNamespaceAware( false );
factory.setValidating( false );
XmlUtil xuUtil = new XmlUtil();
try
builder = factory.newDocumentBuilder();
catch( Exception e )
return "1";
Document docReq;
try
// Building up RFC Request Document
docReq = builder.newDocument();
//Element eOutputRoot = xuUtil.createNode( docReq, "ZHRBAPINOMINA" );
Node eOutputRoot = docReq.createElementNS("urn:sap-com:document:sap:rfc:functions", "ns:ZHRBAPINOMINA");
//eOutputRoot.setAttribute( "xmlns:ns1" , "urn:sap-com:document:sap:rfc:functions" );
eOutputRoot.appendChild( xuUtil.createNode( docReq , sValue , sName ) );
//eOutputRoot.appendChild( xuUtil.createNode( docReq , "TABLE_NAME" , sTabla ) );
docReq.appendChild( eOutputRoot );
catch( Exception e )
return "2";
// Lookup the
Payload result;
try
InputStream is = new ByteArrayInputStream( docReq.toString().getBytes() );
XmlPayload payload = LookupService.getXmlPayload( is );
trace.addWarning("traza 1 ");
result = accessor.call( payload );
trace.addWarning("traza 2 ");
if (result == null)
trace.addWarning("result of RFC call is null");
return "2.5";
catch( LookupException e )
//Close accessor
if( accessor != null )
try
accessor.close();
catch( LookupException ex )
trace.addWarning("Error during lookup1 - " + e);
return "3";
trace.addWarning("Error during lookup2 - " + e);
return "4";
// Parsing RFC Response Document
Document docRsp;
try
docRsp = builder.parse( result.getContent() );
catch( Exception e )
return "5";
return "6";
//return docRsp;
In the execute method we are claling the RFC adapter:
Channel channel = LookupService.getChannel( service, channelName );
accessor = LookupService.getRfcAccessor( channel );
We don't know why we have these errors, with old versions like XI 3.0 we didn't have errors.
Do you know what could be?
Many thanks.
Xavi. -
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.
Maybe you are looking for
-
Question about comparing an array of names to a hash table
I'm still learning Powershell but feel like I have the basics now. I have a new project I'm working on and want some input as the best way to do this: The Problem: Let's say you have a list of several hundred video game titles and the dollar value of
-
Rebate Agreements - Free Goods payment
Hello, We're currently using SAP Standard Rebate Agreement process. Final Settellment is generating a credit memo request, then converted into a credit memo. We hava a user request to stop using credit memo and to deliver free goods instead. The only
-
Hi everyone, I need help for my problem. I want do display confirmation dialog with icon and i find that i must using method setIcon(WDURLGenerator.getSAPIconWebResourcePath("???")). I have read the help about WDURLGenerator but still i cannot unders
-
Error install trial version of Flash Builder 4 in WIN runs on VMWare
After the installation, I go the errors... please help! Thanks. In the Setup dialog, I chose c:\Program Files\Adobe as the install location. Why did it try to access vmware-host\Shared Folders? ERROR: 14921 Unable to create directory "\\vmware-host\S
-
How to add another drive to striped RAID
I have 2 1TB drives in a striped RAID. Now I would like to add a 3rd. Can I just drag it into the RAID array in Disk Utility?