cancel
Showing results for 
Search instead for 
Did you mean: 

XPath Expression at Condition Editor in Receiver Determination

Former Member
0 Kudos

Hi,

  I have a fixed length flat file coming in into which I have to look at the first line's 4th to 7th positions. Based on that if it is "1234" then I need to route it to the receiver else I will ignore in the receiver determination.

Example input file -

M 0123456789ABCDEFGHIJKL

PR0123456789JIDFJDIFJD0244

PA0123456789JFDJF9384384K

We have module configuration where we are converting this to a line value pair something like this -

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

<ns:GMTLog xmlns:ns="http://sap.com/xi/GMStoreConnectivity">

    <Line>

        <Value>M 0123456789ABCDEFGHIJKL

        </Value>

     </Line>

      <Line>

        <Value>PR0123456789JIDFJDIFJD0244

        </Value>

      </Line>

       <Line>

        <Value>PA0123456789JFDJF9384384K

        </Value>

      </Line>

</ns:GMTLog>

When I tried to test my xpath in xpath tester it is working fine with the below xpath expressions -

1. /ns:GMTLog/Line[Value][1] --> This returned the first record completely

2. substring(/ns:GMTLog/Line[Value][1], 4, 4) --> This returned exactly what I am expecting "1234"

But the above 2 are not working in condition editor.

May I know the exact xpath expression to be used in this case to route the message to receiver when 4th to 7th position is "1234".

Thanks a lot in advance.

Regards,

Sarat

Accepted Solutions (1)

Accepted Solutions (1)

udo_martens
Active Contributor
0 Kudos

Hi Sarat,

that should look like:

substring(/ns:GMTLog/Line[1]/Value[1],4,4)

/Udo

Former Member
0 Kudos

Hi Udo, Adarsh,

  I tried both of your options and they yielded the below error -

Error: com.sap.aii.adapter.xi.routing.RoutingException: Can't determine receivers because condition evaluation failedcom.sap.aii.adapter.xi.routing.condition.ConditionException: Could not resolve needed Extractors for ConditionFragment

Thanks,

Sarat

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might want to use EX operator and try the below link

http://wiki.sdn.sap.com/wiki/display/XI/Xpath+Condition+in+Receiver+Determination

Former Member
0 Kudos

Hi Baskar,

  Tried it with EX operator too but still the same error.

This is how I gave it in condition editor -

/ns:GMTLog/Line[1]/substring(Value,4,4)='1234'

Former Member
0 Kudos

Hi Sarat,

try Replace '1234' with 1234 only.

regards,

Akshay

former_member184789
Active Contributor
0 Kudos

Oh sorry,

It should be

/p1:Segment/Field[substring(4,7) = '1234']  then EX

This should work. BTW this thread  exactly matches ur requirement. Go through

http://wiki.sdn.sap.com/wiki/display/XI/Xpath+Condition+in+Receiver+Determination

Former Member
0 Kudos

Hi Adarsh,

  Thanks for bringing this close. It finally worked with the below expression with "MultiLine removed".

/ns:GMTLog/Line[1]/Value[substring(4,7)='1234'] then EX

Thanks once again Adarsh, Udo and Baskar for your ideas.

Regards,

Sarat

Former Member
0 Kudos

Hi Adarsh,

  The issue is not resolved. Now when I am using /ns:GMTLog/Line[1]/Value[substring(4,7)='1234'] then EX it is routing for all cases. Even though substring(4,7) is not equal to 1234 it is routing it to receiver.

Could you please help me.

Thanks,

Sarat

Former Member
0 Kudos

Hi Sarat,

try Replace '1234' with 1234 only.

regards,

Akshay

former_member184789
Active Contributor
0 Kudos

It will work. Do one thing, in receiver determination, for this condition add the receiver system. In other words, when it is 1234 ( Use it as '1234' only) then route it to receiver.Add another condition and another receiver system. Type in a dummy business system name for second condition & don't forget to select condition 'If no receiver is determined proceed as follows: Select Ignore'. For the second condition, type in as ns:GMTLog/Line[1]/Value[not(substring(4,7)='1234')]

Reward points if helpful.

Former Member
0 Kudos

Hi Adarsh,

  PI instantiates 2 flows for every message i.e. both the conditions are being met and the message is being sent to both the receivers.

Is there anyway of doing it correctly. Also I might have 5 more conditions like "2222" or "3333" or "4444" or "5555" I have to send it to receiver system. In all other cases I should not send it to any receiver. Message needs to be suppressed in PI(which can be achieved by selecting the option " Ignore" in ICO.

Thanks,

Sarat

former_member184789
Active Contributor
0 Kudos

Hi,

Can you please click on the picture which I had uploaded in my last post. In that one, I had considered a condition that if field is '1234' then it will go to the receiver system.If not then I am routing it to a dummy non existing business system, I typed in the name of the business system & to ensure that this dummy system does not give error, I selected, ignore in case of no receiver is found. As far as the issue of having multiple conditions is concerned, you can have multiple conditions as well as shown in the blog below:

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

Hope this helps..Reward points if useful.

Former Member
0 Kudos

Hi Adarsh,

  Thanks for your reply but when I save the ICO its obviously throwing error that the business system doesn't exist. Also even if I create one and assign it with some channel (say File channel) I dont want all other messages (where condition is failing)to be processed through this dummy business system.

The issue is still open.

Thanks,

Sarat

former_member184789
Active Contributor
0 Kudos

Hi Sarat,

Can you do try one more thing pls. In the receiver configuration, you give conditions for sending to receiver like if substring is '1234' then send to receiver1 if '4567'then receiver 2. And select ignore if no receiver is determined, without giving a dummy business system name. Can you show me the screenshot of the receiver configuration step. Here is what should it be like:

Former Member
0 Kudos

Hi Adarsh,

The issue is now resolved. Below is the correct XPath expression to be given -

Left operand --> contains(substring(/ns:GMTLog/Line[1]/Value,4,4),'1234')

Operator --> =

Right Operand --> true

Thanks,

Sarat

Answers (2)

Answers (2)

0 Kudos

Good day. Can I please have some clarity on what I need to correct on my Receiver expression test.

For the number of instances of the Summary segment, I am required to identify and test the Summary amount of SUMME if this is more than 5.00 (a currency amount). SUMME is a string so I thought I should convert this to a "number" value to test it.

Also ensuring that SUMME is checked when the SUMID is equal to 011.

Now I hope part of my solution below is correct, but the test of the field value is not being done.

Please help.

azharshaikh
Active Contributor
0 Kudos

Hi,

AFAIK this condition check will happen only for the 1st occurrence of the Node...If its repeating then it will not check for each of the Node values...

Can you try to test this condition with just single occurrence of Node E1EDS01 with correct values..

(You sud have opened a new thread instead of posting in an Answered one)

Regards,

Azhar

Former Member
0 Kudos

Darren,

  This cannot be achieved at Receiver Determination's Condition Editor because the segment occurs more than once and hence after your SUMID condition check you cannot do a condition check on the "corresponding" SUMME's value (where SUMMID = 011).

You can achieve this requirement at Message Mapping level. Do this condition check at the root node and create this root node only when condition check is success.

If you have opened a new thread for this issue by now, please provide the link here so for quick reference.

Thanks,

Sarat

0 Kudos

Hi.

Post opened and answered here - >

Sorry about the incorrect Post.

Thanks guys.

former_member184789
Active Contributor
0 Kudos

Try substring as :

/p1:Segment/Field(substring(4,7) = '1234')

Also check

https://scn.sap.com/thread/1642318