Skip to Content
avatar image
Former Member

Repeat Target Segment based on multiple source fields

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Aug 21, 2015 at 06:38 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 21, 2015 at 03:20 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 21, 2015 at 03:18 PM

    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

    Add comment
    10|10000 characters needed characters exceeded