cancel
Showing results for 
Search instead for 
Did you mean: 

XPATH condition in receiver determination.. Sum one of the filed

Former Member
0 Kudos

Hi,

This is my input payload.

segment "Record" will be coming multiple times.

<ns:MT_Account xmlns:ns="urn:com.statement">

-<BalanceRecs>

- --<Record>

-


<field1>CUA</field1>

-


<field2>0.00</field2>

-


<field3>324612.28</field3>

-


<field4> LTD</field4>

-----<numRecs>0</numRecs>

</Record>

--- <Record>

-


<field1>CUb</field1>

-


<field2>0.00</field2>

-


<field3>324612.28</field3>

-


<field4> LTD</field4>

-


<numRecs>2</numRecs>

</Record>

--- <Record>

-


<field1>CUc</field1>

-


<field2>0.00</field2>

-


<field3>324612.28</field3>

-


<field4> LTD</field4>

-


<numRecs>0</numRecs>

</Record>

</BalanceRecs>

Requirement:

I need to calculate the sum of field "numrecs".

If the sum is 0, then pass to BPM(IP_BPM)

If the sum is > 0 then pass to System B.

I tried using the below blog from shabarish..

/people/shabarish.vijayakumar/blog/2006/06/07/customise-your-xpath-expressions-in-receiver-determination

/p1:MT_ActBalance/BalanceRecs/BalanceRecord[sum(numRecs) = 0] EX        --> BPM
 /p1:MT_ActBalance/BalanceRecs/BalanceRecord[sum(numRecs) > 0] EX        --> SystemB

Is there anything im missing .. kindly suggest.

Thanks

Deepthi.

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

/p1:MT_ActBalance/BalanceRecs/BalanceRecord[sum(numRecs) = 0] EX --> BPM

/p1:MT_ActBalance/BalanceRecs/BalanceRecord[sum(numRecs) > 0] EX --> SystemB

The conditions look okay. If you are using PI 7.1 with interface pattern as stateless, use // in your xPath e.g

//p1:MT_ActBalance/BalanceRecs/BalanceRecord[sum(numRecs) = 0, otherwise retain as is.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark,

It is working only for one receiver.

i mean

-


<numRecs>0</numRecs>

-


<numRecs>0</numRecs>

-


<numRecs>0</numRecs>

The message is going correctly when the sum value is 0. ie to BPM.

-


<numRecs>0</numRecs>

-


<numRecs>2</numRecs>

-


<numRecs>0</numRecs>

OR

-


<numRecs>2</numRecs>

-


<numRecs>0</numRecs>

-


<numRecs>0</numRecs>

When I pass the above payloads, it is going to both the receivers.

Since the total is 2, it should go only to systemB

Any idea?

This is working perfectly for enhanced receiver determination. I dont want to use enhance version for this simple case.

Former Member
0 Kudos

Hi Deepthi,

Can you try this?. Add // before numRecs

/p1:MT_ActBalance/BalanceRecs/BalanceRecord[sum(//numRecs) = 0] EX        --> BPM
/p1:MT_ActBalance/BalanceRecs/BalanceRecord[sum(//numRecs) > 0] EX        --> SystemB

Regards

Ramesh

Former Member
0 Kudos

Hi Ramesh,

Thank you. It works.

Is it something to do with 7.1 version?

Any idea why this is been handled in a complicated way?

Thanks

Deepthi

Former Member
0 Kudos

Hi,

It is nothing to do with PI version. It is the right syntax to sum all the value of given node.

You are welcome.

Ramesh

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Perhaps this page might help:

http://www.w3schools.com/xpath/xpath_syntax.asp

Regards,

Mark

Answers (1)

Answers (1)

Former Member
0 Kudos

The message is going to both the receivers.