cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat Target Segment based on multiple source fields

nitinlpatil12
Participant
0 Kudos

Hi Experts,

I have following scenario of mapping,

Source Structure (Customized structure from legacy system):

<PO>

.....multiple fields

<Tax1>

<Tax2>

<Tax3>

<Tax4>

<Tax5>

.....multiple fields (same parent)

</PO>

Target Structure (Standard structure):

<Purchase Order>

.....multiple fields

<Tax Detail> (0 to unbounded)

     <fields>...

</Tax Detail>

</Purchase Order>

I need to repeat Tax Detail segment in Target structure based on how many Tax field comes in Source structure (same level)...as of now it is 5. is it possible using standard functions or do I need to write UDF...if yes please provide details on how should I proceed.

Please help.

Thanks and Regards,

Nitin Patil

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Nitin,

If input elements are Tax, Tax, Tax, Tax, Tax then map one-to-one Tax to target TaxDetail.

If Input elements are Tax1,Tax2,Tax3,Tax4, Tax5 then duplicate target TaxDetail 5 times in target structure in message mapping and map one-to-one.

Answers (2)

Answers (2)

apu_das2
Active Contributor
0 Kudos

Hi Nitin,

You can handle this easily just adding an simple UDF in between.

Mapping will be like -

Tax1 -> remove context

Tax2 -> remove context   ->   UDF     ->   Purchase Order

Tax3 -> remove context                     ->  split by value(each value)  -> Tax Detail

Tax4 -> remove context



Use the following code in the UDF as per your requirement -


int b=Integer.parseInt(a[0]);  --> a[0] will be the sum of count of Tax

for (int i=0;i<b;i++)

{

String s=String.valueOf(i);

result.addValue(s); -> This resultList will be mapped to PO

r1.addValue(arr[i]);  -> This resultList will be mapped to tax Detail

}


Try this ... If helpful don't forget to help me to gain point.


Thanks,

Apu

ernesto_cruz
Participant
0 Kudos

Hi Nitin, to proceed with your problem, I suggest the following:

* Creates a complete xml source that reflects a particular case

* Creates a complete destination xml that reflect the particular specific output.

Do you work with SAP PI 7.1?

Regards