cancel
Showing results for 
Search instead for 
Did you mean: 

Using substring in the XPATH expression for Receiver Determination

matt_austin
Explorer
0 Kudos

Hello, I need a little help please. In my receiver determination, I have a condition and I need to do a "not like" check. Basically, if the first three positions of the source field does not start with a specific code, then I need to execute the condition. The condition editor does not support a "not like" operand, so I went to the XPATH expression editor. I tried to used the XPATH substring function to get the first three characters and then do a "not equal" operand, but it doesn't appear to work. There are not any runtime errors, but the condition is not executing. Any ideas on this? Does the XPATH expression support the substring function?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Matt,

You can use the following method:

1) Specify an XPath in the Condition Editor. For example if you want to check that there is not a Material that starts with 123.

/p1:PRODUCT/MATNR[not(starts-with(.,"123"))]

2) Choose EX (exists) for the Operator and then don't fill in anything for the Right Operand.

Thanks,

Jesse

matt_austin
Explorer
0 Kudos

That did the trick! Thanks so much for your help Jesse!!

Former Member
0 Kudos

Matt,

Good, I'm glad it worked. If you need to check the end of a string, there's not an ends-with function until XPath 2.0 (XI 3.0 only support XPath 1.0) so you can use a combination of the substring and string-length functions:

/p1:PRODUCT/MATNR[not(substring(.,string-length(.) - 2) = '123')]

Thanks,

Jesse

SudhirT
Active Contributor
0 Kudos

Hi Jesse,

Can you please explain what is the meaning of http:// in the statement

/p1:PRODUCT/MATNRhttp://not(substring(.,string-length(.) - 2) = '123')

Please explein, I am having same issue. It is not working here.In My case it is

/p1:ORDERS01/IDOC/E1EDP01/E1EDP19/IDTNR[http://not(starts-with(.,\"D\"))]

also tried with

/p1:ORDERS01/IDOC/E1EDP01/E1EDP19/IDTNR[http://not(starts-with(.,'D'))]

Thanks in advance!

Answers (1)

Answers (1)

Former Member
0 Kudos

Matt

First collect the first three characters into a variable using <xsl:i="substring(p2:MT_STUD_SORC/Records/Student/test,1,3)"/>. Now you give the value of i to if condition (after checking your characters)in mapping editor. You specify if it is true then go ahead else you dont pass it. For further info. go through the url:

/people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping

---Satish