cancel
Showing results for 
Search instead for 
Did you mean: 

ConditionEditor: Check if element is empty

Former Member
0 Kudos

Hi everybody,

how can I check if an element in the payload is empty.

e.g. I got

<ELEMENT_TO_CHECK></ELEMENT_TO_CHECK>
or
<ELEMENT_TO_CHECK/>

I tested different variations of th XPATh-expression

string-length

. But found no solution.

Please post no assumptions. I would appreciate if you post answers which you have checked or already run.

Many thanks

Regards

Mario

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

thank you all for your replies. Due to the priority of the problem, I had to find a workaround. So I implemented the workaround and could'nt check you suggestions! Sorry!

Many Regards Mario

stefan_grube
Active Contributor
0 Kudos

See the use of string-length in this thread:

sunil_singh13
Active Contributor
0 Kudos

Hi Mario,

string-length

It did not work for you because it will return "1" as a string length if the value is empty ([]), unlike your assumption that it will return length as "0".

"exists" will not work for you because it does not check the value inside the node but it checks if the node is present. so it will return true is the node is present (even if there is no value inside the node) and false if node is not present.

Now you comapre the node <ELEMENT_TO_CHECK> with constant and inside constant you give "[]".

and give it to equlas(text function) and then to if or ifwithoutElse (as per your requirment) .

if the value is empty it will return true else false.

this logic works for

<ELEMENT_TO_CHECK></ELEMENT_TO_CHECK>

or

<ELEMENT_TO_CHECK/>

(I have assumed that you want to do this validation in Message mapping and not in BPM)

Thanks,

Sunil Singh

prateek
Active Contributor
0 Kudos

You may compare the xpath expression with the blank string ' '.

Now i guess you must have tried this. So next think would be instead of providing the exact xpath, try using double slash and don't provide the root node name.

I could not test it and therefore it would be part of an assumpltion only.

Regards,

Prateek

VijayKonam
Active Contributor
0 Kudos

Alternatively u can map this element to mapwithdefault and put the default value as blank and simply check for blank in an if condition or in a UDF.

VJ

Former Member
0 Kudos

Hi Prateek,

double slash is very very bad for the performance.

Regards Mario

prateek
Active Contributor
0 Kudos

Mario,

Anyway you are using xpath related expression, and therefore just additional double slash usage won't actually affect the performance much. Double slash simply means that it would take the first occurence of the specified field within the root node. It would hardly affect the performance by fraction of seconds.

Regards,

Prateek

MichalKrawczyk
Active Contributor
0 Kudos

hi,

did you try with EX (exists) ?

from help.sap.com

"Element exists in container or referenced element exists u2013 expression2 is not required."

Regards,

Michal Krawczyk

Former Member
0 Kudos

Hi Michal,,

exitst checks only the node-element not the text-element, taht is child element of the node-element.

But this is a goog hint: I should try

<element>/.

regards Mario

Former Member
0 Kudos

EX works with child-Element level

Conditional receiver determination -->

In condition editor, X-Path, select the desired element and then EX as operator