Search code examples
xmlxpathsap-pisap-xi

XPATH Expression to determine the receiver in SAP PI


I have a requirement where i need to determine the receiver based on condition in SAP PI XPATH expression. Can someone help please.

  • condition 2:

    <bizTransactionList><bizTransaction type> contains the value "urn:epcglobal:cbv:btt:resadv” , this is also true but need to validate two more conditions as mentioned below in "Excep't

except : - when the last segment of the value contains the string “.008” in <Biztransaction> and that the <bizStep> contains the word “commissioning “ - or

when the last segment of the value contains the string “.008” in <Biztransaction> and that the <bizStep> contains the word “receiving “


Solution

  • Strictly speaking, the following XPath should work :

    //bizTransaction[@type="urn:epcglobal:cbv:btt:prodorder"]|//bizTransaction[@type="urn:epcglobal:cbv:btt:resadv"][contains(.,".008")][preceding::bizStep[1][not(contains(text(),"commissioning") or contains(text(),"receiving"))]]
    

    Output : 2 nodes

    We use | operator to "join" 2 expressions. The first part will select "bizTransaction" element regarding 1 condition ("urn:epcglobal:cbv:btt:prodorder"). The second part will select "bizTransaction" element regarding 3 conditions : "urn:epcglobal:cbv:btt:resadv", ".008" and with "bizStep" element which not contains 2 specific keywords ("commissioning" or "receiving").