cancel
Showing results for 
Search instead for 
Did you mean: 

PI Message Mapping One Source to create two of the same Target Nodes.

former_member192375
Participant
0 Kudos

Hi,

I have a source node that contacts the following.

"1234-5678".

When there is a "-" in the source node then I need to create two target nodes.

When there is no "-" in the source node then only create one node.

Since the source structure is a flat structure by on the target side as you can see I am trying to achieve a diep structure.

Please can you assist in how to do this with PI message mapping.

Regards

Willie Hugo

Accepted Solutions (1)

Accepted Solutions (1)

former_member208856
Active Contributor

Goto Message Mapping.

Pick that node & use Duplicate Subtree.

Now you have 2 target nodes.

In mapping, now create 2 UDF

First for using this code :

int i = 0;

String temp = a[0].toString();

i = temp.indexOf('-');

result.addValue(temp.substring(0,i));

Second for using this code:

int i = 0;

String temp = a[0].toString();

int l = temp.length();

i = temp.indexOf('-');

result.addValue(temp.substring(i,l-1));

Now map Source using First UDF with First Target

& using Second UDF with Second Target.

Answers (5)

Answers (5)

former_member192375
Participant
0 Kudos

Thank all for your input. The duplicate sub tree function just escaped me as a solution there. Also true that UDF is required for variable substring functions, but that was not really my problem.

former_member192375
Participant
0 Kudos

Hi,

"1234-5678" only occurs once in the source. There is no source xml node that will occur more that once. The whole structure only occurs once. But on the target side I need one of the node to occur more than once if a hyphen is found in the source field.

Source Message - Always only one data node.

==============

<root>

<OnceOnlyNode>1234-5678</OnceOnlyNode> [1..1]

</root>

Target Message - Only two text node when "-" in source, else only one text node.

=============

<msg>

<text>1234</text>

<text>6789</text>

</msg>

How can this be done using standard PI message mapping functions. Can it be done?

Regards

Willie Hugo

stefan_grube
Active Contributor
0 Kudos

> How can this be done using standard PI message mapping functions. Can it be done?

This is not possible. This requires a substring function with variable parameters, which is not available in standard.

Besides it is way easier to use a UDF.

Shabarish_Nair
Active Contributor
0 Kudos

its a simple logic.

Use CreateIf and use indexOf function to help you

former_member187339
Active Contributor
0 Kudos

Hi Willem,

>>When there is a "-" in the source node then I need to create two target nodes.

Since in this example (which you provided) you have two values differentiated by a hyphen , you wan to have two target nodes. So what about this:

abcd-efgh-123

is it three target nodes? If yes then you need to write a udf which will read the input value and do a split on -. The resultant values will be placed in the output queue, using result.addValue();

Also make sure the output node have a max occurs of n or unbounded.

Regards

Suraj

former_member181985
Active Contributor
0 Kudos

try using CreateIf standard function