cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with nil=true in message nodes

Former Member
0 Kudos

Hello,

issue is about an external definition that gives this structure....

node1 (nilllable = true)

-> node2 (occurence 1..1)

-> field1 (occurence 1..1)

node3

-> field2

So the node2 and field1 under the nillable node1 are mandatory.

The message has to be used for a receiver.

The bad situation is, the incoming message from the sender looks identical for this segment including the nil definition

and has to be mapped 1:1 !!!!!

A test message from the sender looks like this for this message segment.....

....

<node1 nil="true"/>

<node3/>

<field2>value</field2>

....

So PI comes up with an error as it is not able to create the field (field1) under the second node (node2).

Using "exists" I can create the node2, but how to create the field1 with graphical mapping?

Your help is really appreciated!

Best regards

Dirk

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dirk

Since those nodes have 1:1 occurrence, you have to create them with map with default, or mapping will fail.

If target system wants an empty node1 when the nil attribute is true, then the external definition should be changed so that node2 and field1 are optional.

Regards,

Giuseppe

Answers (5)

Answers (5)

Former Member
0 Kudos

If source reference field -> "isNil

source field -> map with Default

else

source field -> map with Default

Unbelievable and simple but it works!

For "else" the mapping provides the value of the element, for "if" it will create the target field with [] value.

If "nilable" is provided with a main node with a segment inlcuding element

for the element the mapping requires the context reference to the main node.

stefan_grube
Active Contributor
0 Kudos

A nil value can only apply for elements, not for nodes (complex types)

So your XML definition is not correct according to the XML specification.

Ask for a correct XML specification.

See details here:

http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/#Nils

Former Member
0 Kudos

Hi,

maybe I am not clear enough.

The field is an element of the second node not of the first node.

node1 -> node 2 -> field1

So it is no issue to create node e.g. with "exists" function, but the field in sub level 2 cannot be created.

I tried to use isNil function (SAP PI 7.11) but this one seems to have an issue as I expect to have a result "true" for this situation as examples show "false" if the node1 is not nil= true.

But this one gives back "null" and so I cannot create any sub element.

Best regards

Dirk

tushar_saurabh2
Explorer
0 Kudos

In order to create the Field1 under Node2, you need to create Node2.

Put a conditional createIf for Node2 and then Field1(Source)->MapWithDefault->Filed1(Target).

createIf Node2(Target) if Node2(source) does not exist with Node1(Source) else create with Node2(Source)

Tushar

Former Member
0 Kudos

Hi Tushar,

Sorry, this is not really clear to me...

Try to describe the mapping: IF/THEN/ELSE/result are the connectors of the If function.

Node2 -> EXIST -> IF

Node2 -> THEN

Node1 -> ELSE

So these are the input param for the IF function

result -> NODE2

So where to place the createIf function

Best regards

Dirk

tushar_saurabh2
Explorer
0 Kudos

I suppose createIf is not required.

If Node2 Exists

Then Graphically Map Node2(S) to Node2(T)

Else

Graphically Map Node1(S) to Node2(T)

This will take care for creating the Node2 at target even if the source does not have the Node2 element but has Node1. You need to carefully handle the context.

Once the field's parent element is created, you can easily map the Field1. In order to take care of the non-occurence of

Field1(S), please use mapWithDefault.

Thanks

Tushar

Edited by: Tushar Saurabh on Jun 8, 2011 2:02 PM

former_member472138
Active Contributor
0 Kudos

map source field with mapWithDefault function to field1.

Regards

Pothana

tushar_saurabh2
Explorer
0 Kudos

Hi Dirk,

Nillable specifies whether an explicit null value can be assigned to the element. It does not mean the mandatory child elements and fields will not occur. As per you example the child elements and fields are mandatory and they are missing while forming the target structure.

Is the external definition for source or target?

Thanks

Tushar