on 08-05-2009 6:42 PM
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
Hi Erkan,
Can you copy the xml from sxmb_moni and past it in interface mapping and test?
Please let me know the results
Regards
Sowmya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sowmya,
I hope you have read what I wrote first. I only try to read the filename from a pdf document via file adapter sender ( adapter specific attributes). After that the Java Mapping program will be called and then filename will be given as param to the rfc module, but this does not work. However I will try to use sxmb_moni and read the xml, but this would not work, because the pdf file will be open.
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
Hope you have tested the entire scenario rather than interface mapping ..
if not test entire scenario and check it out the same
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.