cancel
Showing results for 
Search instead for 
Did you mean: 

Merge two different fields into single output field

Former Member
0 Kudos

Hi All,

Can you please help me to find whether is it possible to achieve in PI, to merge/append two input fields values into single one output field.

i.e; source field 1                                    target output                                            

      1                                                            1

      2                                                            2

      3                                                            3

                                                                    4

    source field 2                                             5

      4

      5

Regards,

Prasad K

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos
Former Member
0 Kudos

Standard Concat function wont work in this case. The standard concat function is for concatenating as below:


Source field 1                             Target field

Prasad                                        PrasadK


Source field 2

K

But this is not my requirement as mention in the question,It should be like this:


Target field

Prasad

K


Hope this clarifies.


Regards,

Prasad K

javier_alcubilla
Contributor
0 Kudos
iaki_vila
Active Contributor
0 Kudos

Hi Prasad,

I misunderstood your requirement. You would need an UDF that merge the input queues in one.


Regards.

iaki_vila
Active Contributor
0 Kudos

Hi,

You can use this UDF:


public void MergueQueues(String[] queue1, String[] queue2, ResultList result, Container container) throws StreamTransformationException{

for(int i =0; i<queue1.length;i++){

result.addValue(queue1[i]);

}

for(int i =0; i<queue2.length;i++){

result.addValue(queue2[i]);

}

}

You only need to repeat the udf for every source field.

Regards.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

Can you show how these values are coming in ur XML file??

What i can take from ur post is that u want to create 5 occ. of target_output field - 3 occ. for source field 1 values and next 2 for source field 2 values??

If yes, then just use duplicate subtree for target_output and then map both the source fields to target_output.

Thanks

Amit Srivastava

gagandeep_batra
Active Contributor
0 Kudos

Hi Prasad,

You can create one more target element with same name and map to second field as below using Duplicate Subtree:

Regards

Gagan