cancel
Showing results for 
Search instead for 
Did you mean: 

Failed Substring in XPATH Receiver Determination

markbernabe
Active Participant
0 Kudos

Hi,

I have this payload.

<ns:request>

     <in>

          <materialno>AU1234</materialno>

     </in>

<ns:/request>

I'm using xpath in receiver determination and I have to check the country code prefix in the material number. I need to use Substring function and not ContainsPattern (double ~) because I will create a longer expression later on.

I'm using this condition but it doesn't work:

/ns:request/in[substring(materialno,1,2)='AU'] EX

Any idea? Appreciate your inputs!

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi Mark,

Your xpath looks right for me, have you defined the ns namespace correctly in the table with prefix and namespace columns?

Regards,

markbernabe
Active Participant
0 Kudos

Hi Inaki,

I just realized it's working if it's the only condition. But when I add another expression using AND, to check the another field, it's failing. The thing is, the 2nd expression also works if it's the only condition. So basically, problem happens when I combine both expressions with AND.

<ns:request>

     <in>

        <materialno>AU1234</materialno>

        <country/>

     </in>

</ns:request>

Here is my condition:

/ns:request/In[substring(materialno,1,2)='AU'] EX

AND

/ns:request/In[string-length(country) = 0] EX

Since both are satisfied, it should be routed to ReceiverA. However, it's getting moved to ReceiverB via the 'No receiver is found option, process as follows: Select the following receiver: ReceiverB'.

Former Member
0 Kudos

Hello,

Your XPATH seems OK to me. In fact i have tested it and it's working fine...

Just a quick observation, instead of In use "in"in ur xpath...

Thanks

Amit Srivastava

former_member184789
Active Contributor
0 Kudos

Hi,

Refer to this blog & notice how the 'AND' condition is provided:

http://scn.sap.com/community/pi-and-soa-middleware/blog/2006/06/07/customise-your-xpath-expressions-...

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Mark,

Have you tried unchecking the multiline option? If this is checked, it causes both conditions to be evaluated independently and the results for both conditions joined e.g it checks for condition 1 (all nodes for condition 1) first and if true, then checks for condition 2 (all nodes for condition 2).

Regards,

Mark

Former Member
0 Kudos

<?xml version="1.0" encoding="utf-8" ?> 

- <nm:TransportationOrderRequest xmlns:nm="http://sap.com/xi/SAPGlobal20/Global" xmlns:prx="urn:sap.com:proxy:DT2:/1SAI/TAS8101A6A7B75DF25B6836:702">
- <MessageHeader>
     <CreationDateTime>2013-12-05T14:11:00.546Z</CreationDateTime>
     <SenderBusinessSystemID>com_rexam_dev_TM_DT2</SenderBusinessSystemID>
   <RecipientParty>
        <InternalID>GRTG</InternalID>
   </RecipientParty>
  </MessageHeader>
Amit, how do I write xpath expression to say when internalid = GRTG assign to a receiver determination?
markbernabe
Active Participant
0 Kudos

Hi Vimal,

Have you tried this in the expression editor?

Left Operand: /nm:TransportationOrderRequest/MessageHeader/RecipientParty/InternalID

Operator: =

Right Operand: GRTG

Former Member
0 Kudos

Hi Mark,

I did and still the same error. No Receiver Determination  I got the payload from the sxmb_moni.  Is this correct?

alejandro_mejias
Active Participant
0 Kudos

If the payload only contains a single InternalId, try using //InternalID in the left operand

Former Member
0 Kudos

Hi Alejandro,

It worked.  Thanks!.  It would be great if you could shed some light on referencing the xml payload

Sorry, the issue is that I have multi-mapping going, meaning 2 interfaces.

So, when the //InternalID = GRTG  pickup target 1

and when the //InternalID = PLCY pickup target 2

Currently, it picksup target 1 for all.

Thanks!

Vimal

Answers (3)

Answers (3)

Former Member
0 Kudos

You could try using *AU* to check for ContainsPattern instead of using Substring.

Please let me know if it works.

If we dont use * on both Sides, what I have seen is that PI pops up Error for not being able to find the Receiver.

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

try this

substring(/ns:request/in/materialno,1,2)='AU'

alejandro_mejias
Active Participant
0 Kudos

substring(/ns:request/in/materialno,1,2)='AU'

or if you have a single material

substring(//materialno,1,2)='AU'

http://www.worldofintegration.com/content/xpath-string-functions-examples