cancel
Showing results for 
Search instead for 
Did you mean: 

Node function exists - Behaviour

Former Member
0 Kudos

Hi ,

I want to use the simple function "exists" for checking if the Node exists. But when input is null the output is also null.. My expectation would have been that if the input is null output of the function would be false...

What am i missing ?

-Mahesh

Accepted Solutions (1)

Accepted Solutions (1)

Harish
Active Contributor
0 Kudos

Hi,

Exists function only return false when the source segment or filed does not exist (having suppress at source side). If the source segment or field having null value (I suppose you are referring to u201Cu201D u2013 Blank) then Exists function does not return false.

You can use the following logic for that:

Source -> mapWithDefault(Blank) -> Equals (Blank) -> Not (Boolean function)

The output of above logic to your map.

Regards,

Harish

Answers (7)

Answers (7)

Former Member

But when input is null the output is also null.. My expectation would have been that if the input is null output of the function would be false...

No, what you are expecting from the function is not correct. The "Exist" function checks the node availability and not the node value. But you are trying to pass a blank value to your existing node and then expecting from function to reurn the "false"..

In order to fulfill your requirement, you have to use IfElse or IfWithoutEsle along with equals & constant function to check if node doesn't contain blank value.

Former Member
0 Kudos

Hi All,

Thanks for directions.

The thing is my source structure has following

Parent Node 1 ( 1..N)

Parent Node 2 ( 0.. N)

Field (1..1)

Child Node ( 0..N )

I was directly checking for Child presence where the Exists function gives null as input and null as ouput..

Where as if i check for Parent 2 it works fine. I have checked for Parent 2 ..

Its good having so many quick response.

-Mahesh

Former Member
0 Kudos

Hi Mahesh,

If i understand you correctly. if the input is null for the node then you want output should be false.

*Answer:-*

you need to use mapwith default node function and press double click on mapwith default node and write false.

you said parent-2 is working fine . its becaue the cardinality for the parent-2 is 0..N

Note: mapwithdefault works only if the node doesn't come in the payload . you can see grey SUPPRESS in the display queue

I hope this clarifies. if you still have doubt then i think you need to expalin once again about your query.

Cheers

Hidayat

Former Member
0 Kudos

Hi Mahesh,

As many of our friends said, your expectation out of "exists" function is not correct.

It will pass true as long as the input field node exists in the structure and gives false if it doesnt.

If your requirement is to check if a field is blank or not then you can use boolean If or ifwithoutelse for the same.

stefan_grube
Active Contributor
0 Kudos

> I want to use the simple function "exists" for checking if the Node exists. But when input is null the output is also null.. My expectation would have been that if the input is null output of the function would be false...

I have tested this in PI 7.11. It works as expected.

false when the source node missing, true when source node available.

ignore the "null", this is not a value in the queue. Check only values which are not gray.

justin_santhanam
Active Contributor
0 Kudos

What do you mean by null?

Thanks!

Former Member
0 Kudos

Thanks Mark for the suggestion. Tough i need to check existance of entire node on the source not just a field.

Also do i get maptodefault to return a boolean and check for it in a IF statement ?

Also if its a bug then is there a known SAP note ? ( I am on SAP pi 7.1 EHP1)

-Mahesh

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

You can also use that logic in checking for a node.

Also do i get maptodefault to return a boolean and check for it in an IF statement ?

Yes, you can use it to automatically set a value to false if the node is not existing, however, the other values will not be of boolean. A complete mapping could be like this


node --> mapWithDefault: false --> fixValues --> your if logic

fix values should be:

Default value: true

key: false

value: false

Also if its a bug then is there a known SAP note ? ( I am on SAP pi 7.1 EHP1)

I just tested it, it is not a bug. example,


Root
Parent (0..unbounded)
--> child (0..1)

If you use mapWithDefault to the child, but the parent is not existing. It will return a null. But if you use mapWithDefault to the parent, it will return a false if the parent is not existing. This is, of course, using normal contexts.

Hope this helps,

Mark

Edited by: Mark Dihiansan on Mar 2, 2011 3:18 AM

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Probably a bug... You can try using this logic though


Source --> mapWithDefault: notExisting --> your logic here

If the value in the queue is notExisting, then you would know that the node did not exist.

Hope this helps,

Mark