cancel
Showing results for 
Search instead for 
Did you mean: 

Add Function.

Former Member
0 Kudos

Hi folks here i am having a requirement as that.... I will be gettind a file as

Node Line

-


Sum

Node Item

-


SUT

-


10

Node Item

-


DAT

-


20

Node Item

-


SUT

-


30

.

.

.

.

.

.

So iN the above case IF I need to add all the values of all the instances of the field SUT. i need to sum all the values when the above field gets the value SUT. but we dont know the exact number of instances of SUT.

Do we have any option in XI message mapping or we need to go for UDF. if we need to go for UDF please let me know the code, as I am not familiar with JAVA it will be helpful for me . Thanking you all..

Ramana

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

can u show the XML structure of the message? That would be helpful to understand the nodes and the elements.

regards

rajeev

Former Member
0 Kudos

Hi ,

PLease find my requirement a bit clear below.

Source structure::::::

<CRMLINE>

<CRMSL>

<AMT>233.0</AMT>

<QL>DAT</QL>

</CRMSL>

- <CRMSL>

<AMT>97500.0</AMT>

<QL>SQL</QL>

</CRMSL>

- <CRMSL>

<AMT>344.0</AMT>

<QL>DAT</QL>

</CRMSL>

Targer Structure:::::::

<CRMLINE>

<Total>

Here in the above Stucture i just need to add all the amounts in the CRMSL only when the Ql in CRMSL is DAT....and i need to pass the result to TOTAL in the CRMLINE tag. Let me know any inputs.

Former Member
0 Kudos

create the following UDF with 2 arguments..

1)

sum(String[] a, String[] b, ResultList result)

{

int totalDAT = 0;

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

{

if ( "DAT".equals(a<i>) )

{

totalDAT += Interget.parseInt(b<i>);

}

}

result.addValue( ""+totalDAT );

}

Save & Close the uDF

2) Go the mapping editor....Drag and drop the UDF. It expects 2 arguments.

Pass QL, AMT in the same order to the function and map the target to ur target element.

3) Change the context of AMT and QL to CRMLINE instead of CRMSL

AMT

QL

Answers (0)