cancel
Showing results for 
Search instead for 
Did you mean: 

Need Mapping Help

0 Kudos

Hi Experts

My source structure is

<Message>         1-1

    <METER>       0-unbounded

          <a1>         0-1

          <a2>         0-1

     <CT>             0-unbounded

         <a1>          0-1

          <a2>         0-1

    <PT>              0-unbounded

         <a1>          0-1

         <a2>          0-1

    <CU>              0-unbounded

         <a1>          0-1

         <a2>          0-1

</Message>

My Target Structure is

<Message>         1-1

           <MTR>    1-unbounded

                <METER>       0-unbounded

                      <a1>         0-1

                      <a2>         0-1

                <CT>             0-unbounded

                      <a1>          0-1

                      <a2>         0-1

                 <PT>              0-unbounded

                      <a1>          0-1

                      <a2>          0-1

                 <CU>              0-unbounded

                      <a1>          0-1

                      <a2>          0-1

            </MTR>

</Message>

Actually Requirement is Whenever METER or CT or PT or CU repeted that time MTR is to repeat in the Target structure.


Can any body help please


Thanks,

Raghava.

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Hi Raja,

Give me an example of what the output should look like for the below source.

Example1:

<Message>       

    <METER>    

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

    <METER>    

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

     <CT>        

          <a1>value1</a1>

          <a2>value2</a2>

     </CT>  

    <PT>

          <a1>value1</a1>

          <a2>value2</a2>

     </PT>

    <CU>

          <a1>value1</a1>

          <a2>value2</a2>

     </CU>

</Message>

Example2:

<Message>       

    <METER>    

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

    <METER>    

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

     <CT>        

          <a1>value1</a1>

          <a2>value2</a2>

     </CT>  

      <CT>        

          <a1>value1</a1>

          <a2>value2</a2>

     </CT> 

   <PT>

          <a1>value1</a1>

          <a2>value2</a2>

     </PT>

    <CU>

          <a1>value1</a1>

          <a2>value2</a2>

     </CU>

</Message>

Give the output of what would you like to see. It will be more helpful!

Thanks,

Justin.

0 Kudos

Hi Justin

Thanks for your reply

Here is output for

Example1

<Message>      

<MTR>

    <METER>   

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

     <CT>       

          <a1>value1</a1>

          <a2>value2</a2>

     </CT> 

    <PT>

          <a1>value1</a1>

          <a2>value2</a2>

     </PT>

    <CU>

          <a1>value1</a1>

          <a2>value2</a2>

     </CU>

</MTR>

<MTR>

<METER>   

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

</MTR>

</Message>

Example2:

<Message>      

<MTR>   

<METER>   

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

      <CT>       

          <a1>value1</a1>

          <a2>value2</a2>

     </CT> 

   <PT>

          <a1>value1</a1>

          <a2>value2</a2>

     </PT>

    <CU>

          <a1>value1</a1>

          <a2>value2</a2>

     </CU>

</MTR>

<MTR>

   <METER>   

          <a1>value1</a1>

          <a2>value2</a2>

     </METER>

  <CT>       

          <a1>value1</a1>

          <a2>value2</a2>

     </CT>

</MTR>

</Message>

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

You can use this mapping. For MTR

createMTR UDF

For METER, CT, PT and CU

a1 and a2 are direct mappings.

Test:

Regards,

Mark

Answers (6)

Answers (6)

0 Kudos

Hi Mark and Justin

Now i am in Big confusion to select which is right answer. here solutions you both provided are perfectly working.


Here SCN not provided option to mark both answers as correct. what will i do now?


I thanking both of you for nice explanation with screenshots


Thanks,

Raghava

0 Kudos

Hi Mark and Justin

Thank you for your extream help.

<Message>        1-1

          <MTR>    1-unbounded

                <METER>      0-1

                      <a1>        0-1

                      <a2>        0-1

                <CT>            0-1

                      <a1>          0-1

                      <a2>        0-1

                <PT>              0-1

                      <a1>          0-1

                      <a2>          0-1

                <CU>              0-1

                      <a1>          0-1

                      <a2>          0-1

            </MTR>

</Message>

Firstly I followed

I will try as you both mentioned in screenshots.

Thank you,

Raghava.

justin_santhanam
Active Contributor
0 Kudos

@

What a timing ... We both posted the same solution at the exact same time. Like the SCN spirit

Thnx

markangelo_dihiansan
Active Contributor
0 Kudos

Yeah, I noticed that too

Thanks.

justin_santhanam
Active Contributor
0 Kudos

Hi Raja,

Try this.

Mapping for MTR Node (use the count function under statistic)

Mapping for METER, CT, PT, CU (use the same logic as below)

Mapping for a1 & a2, Just map directly from the source.

UDF - To generate no.of MTR nodes based on source node's repetition.

Code:


int [] arr = new int[4];

arr[0] = var1[0];

arr[1] = var2[0];

arr[2] = var3[0];

arr[3] = var4[0];

//Get the MaxRowCount

int maxRowCount = 0;

for (int i=0; i<4; i++){

    if ( maxRowCount < arr[i] ) {

        maxRowCount = arr[i];

    }

}

//Generate the MTR Node

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

{

result.addValue("");

}

Hope it helps! Please do the testing and let us know if it helps!

Thank you,

Justin.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,


Actually Requirement is Whenever METER or CT or PT or CU repeted that time MTR is to repeat in the Target structure.

I'm not sure if I've understood you completely. If you want to repeat MTR based on the number of occurrences of METER, CT, PT or CU; then all you have to do is right-click on MTR and then select duplicate subtree. Do this three more times and then map them individually.

Regards,

Mark

former_member186851
Active Contributor
0 Kudos

will the repeation of METER ,CT,PT,CU will be same?

if ,yes then you can map METER to MTR.

0 Kudos

Hi Raghuraman

Thanks for your quick reply

Q. will the repeation of METER ,CT,PT,CU will be same?


Ans: No, different tags.