on ‎2016 Dec 22 3:05 PM
Hello Experts,
I'm trying to use substring function in XPath Expression for pattern replacement.
As per the below wiki I we can use it in Receiver Determination condition editor
https://wiki.scn.sap.com/wiki/display/XI/Xpath+Condition+in+Receiver+Determination
But when I tried to apply the same in Receiver REST adapter for Pattern Replacement using XPath Expression it's not working please guide me on this.
I trying to add query string for my REST URL dynamically using Pattern Replacement using XPath Expression
Expected URL: http://host:port/service/path?sid={SID}&recipient={RCVPRN}&sender={SNDPRN}

I've tried couple of ways but none of the giving expected results.
/INVOIC02/IDOC/EDI_DC40[substring(SNDPRN,1,3)]
/INVOIC02/IDOC/EDI_DC40[substring(//SNDPRN,1,3)]
/INVOIC02/IDOC/EDI_DC40[substring(SNDPRN,1,3)]/SNDPRN
I tried giving 1 argument to the substring function to check whether we can apply the function in xpath or not then I got below exception.
XPath: /INVOIC02/IDOC/EDI_DC40[substring(SNDPRN)]
"/INVOIC02/IDOC/EDI_DC40[substring(SNDPRN)]"; Message: "javax.xml.transform.TransformerException: com.sun.org.apache.xpath.internal.functions.FuncSubstring only allows 2 or 3 arguments - com.sun.org.apache.xpath.internal.functions.FuncSubstring only allows 2 or 3 arguments"
Which means we can apply this substring function but not sure how to pass xpath as an arugument(SNDPRN in my case) to the substring function
Note: I cannot use mapping here
Please guide me on this.
As ever,
Nagesh
Request clarification before answering.
Hi Nageshwara,
if you want the first 3 characters of SNDPRN you can use the below expressions.
substring(//SNDPRN,1,3)
substring(/ZPM_ORDER02/IDOC/EDI_DC40/SNDPRN,1,3)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Navdeep,
Tried that as well when I'm using - substring(//SNDPRN,1,3) it's giving below exception
MP: exception caught with cause com.sap.aii.adapter.rest.ejb.parse.InvalidXPathExpression: Invalid XPath expression "substring(//SNDPRN,1,3)"; Message: "com.sun.org.apache.xpath.internal.XPathException: Can not convert #STRING to a NodeList! - Can not convert #STRING to a NodeList!"
I think XPath Expression always expects start char with / or //.
If I use - /INVOIC02/IDOC/EDI_DC40[substring(//SNDPRN,1,3)]
It's giving null result form the xpath expression
As ever,
Nagesh
try this note: 2793544 - REST Receiver cannot evaluate
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There is a strange thing about REST that in RECEIVER adapter it takes the receiver payload and not the sender payload so map the SNDPRN to one field in receiver structure and then do xpath. Or go For adapter specific attribute (ASMA).
https://blogs.sap.com/2014/12/18/pi-rest-adapter-using-dynamic-attributes/
Regards,
Vikas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any solution? I have the same problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi NageswaraRao!
Yes, it shouldn't work since you get NodeSet as result of your expression.
Try this:
substring(/INVOIC02[1]/IDOC[1]/EDI_DC40[1]/SNDPRN[1], 1, 3)
Another syntax (if you have only one INVOIC02 element in your message):
substring(/INVOIC02/IDOC/EDI_DC40/SNDPRN[1], 1, 3)
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.