Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

I  write this short blog just to share how to use an XPath expression in the expression editor to check a message in receiver determination, if a leaf node exists in every repeated parent structure node. This is not so trivial at first thought.

The inbound message contains a structure DELVRY03/IDOC/E1EDL20/E1EDL24/KDMAT, where KDMAT is a leaf node which doesn't contain any sub structure more. Only messages, where KDMAT exists in every E1EDL24 node, are passed by to defined receiver, otherwise it will be ignored.

For this requirement we can't simply use a expression like DELVRY03/IDOC/E1EDL20/E1EDL24[KDMAT] with operator "EX" and the option Multiline checked. Because if a message has multi E1EDL24, and some E1EDl24 has KDMAT, some doesn't have KDMAT. It still will be processed. And expression like:

DELVRY03/IDOC/E1EDL20/E1EDL24/KDMAT != '' or

DELVRY03/IDOC/E1EDL20/E1EDL24/KDMAT CP * (KDMAT contains pattern of any string)

will also not work, because if one E1EDL24 doesn't have  KDMAT, then the message will also be processed.

According to the SAP help documentation for expression editor:


Note that XPath expressions created with the expression editor can only return items of type node (node, node set). For technical reasons, other types (such as Boolean value) are not permitted.


So we can't use a XPath expression which return a boolean value like:

count(DELVRY03/IDOC/E1EDL20/E1EDL24) = count(DELVRY03/IDOC/E1EDL20/E1EDL24[KDMAT])


After some thought I came to this expression, which solved my problem:

left operand: DELVRY03/IDOC/E1EDL20[not(E1EDL24[not(KDMAT)])]

operator: EX

Multilin option: enabled


It means there is no E1EDL24 without KDMAT. The trick part is, it has double negations. In other word it means, every E1EDL24 has child node KDMAT, and that is exactly what I want.

I hope someone else can also find this helpful for similar case.

1 Comment
Labels in this area