cancel
Showing results for 
Search instead for 
Did you mean: 

Creating UDF

Former Member
0 Kudos

Hi everybody,

There are 3 cargo rates 8,18,18 for cargo and their vaues will come .Also a flag will come for other rate 18. and Just one of them can come or 3 of them can come. But I have to create a node for nonexisting cargo rate . for example,

Source:                                                       

   <root>                                                        

<cargorate>8</cargorate>                                        

<value>120.0</value>                                     

                                                                                      

</root>

Target

  <root>                                                        

<cargorate>8</cargorate>                                        

<value>120.0</value>                                     

                                                                                      

</root>

  <root>                                                        

<cargorate>18</cargorate>                                        

<value>0</value>                                     

                                                                                      

</root>

  <root>                                                        

<cargorate>18</cargorate>                                        

<value>0</value>                                     

                                                                                      

</root>

I tried to do with graphical mapping but it is not worked.

How can I write a UDF for this problem or can it do with graphical mapping ?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

How does the Graphical Mapping look like that you tried to get it working?

Will quickly try and do it in a Graphical Mapping.

Regards,

Jannus Botha

Former Member
0 Kudos

Hi,

I dublicate the subtree in target message. I gave the constant values to rate and I used if conditions for amount of rates. In here, If two of recors come it creates 4 nodes.

The graphical mapping and its testing are in attachement.

RaghuVamseedhar
Active Contributor
0 Kudos

Ceren,

If you can edit target structure. Make InvoiceTaxLine occurrence as 3. Then map all fields with mapWithDefault.

If it does not work, please try below UDF. Screenshots attached.


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

  if(tax[i].equals(ResultList.CC)){

  InvoiceTaxLine.addValue("");  InvoiceTaxLine.addValue("");  InvoiceTaxLine.addValue("");

  InvoiceTaxLine.addValue(ResultList.CC);

}

}

  InvoiceTaxLine.addValue("");  InvoiceTaxLine.addValue("");  InvoiceTaxLine.addValue("");

  InvoiceTaxLine.addValue(ResultList.CC);