cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding summing of a source field in Graphical mapping

former_member192238
Participant
0 Kudos

Hello Experts,

I had a requirement under record there are 2 fields A ,B and C where occurence of Record is 0 to Unbounded and for A and B it is optional.

When i get some X value in B I need to sum all the values coming in A, in else case i need to pass directly pass C to the target.

All the values in the sense the if i get 6 Records in that for 3 records i have value X in the B then i nees to add the values in that 3 records only.

Can we acheive the above with graphical mapping or do we need to go with UDF plase suggest any help is highly apprecaited.

Regards

Praveen Reddy

Accepted Solutions (0)

Answers (4)

Answers (4)

ambrish_mishra
Active Contributor
0 Kudos

Praveen,

You can work with standard functions and a UDF to achieve the requirement as below:

you can use split by Value (for each) instead of removeContext() while mapping at field level.

Code of the UDF is simple.

former_member192238
Participant
0 Kudos

Hi Mishra,

Thanks for solution.

Let us assume as below:

A,B,C comes in Record

D is in Header -->is our Target

Now, let me explain you other requirement,now  A and B values comes in Record and i require C which is also in Record but carries a Sign(+ or -),Now,If A=X then B should sum all the entries of A considering the Sign of C.The output should replicate in D which is in Header giving the sum of Filed B replicating the sum of C.

Please also give the code of UDF if you are sorting this out using UDF.

Thanks in Advance.

former_member192238
Participant
0 Kudos

Sorry it is replicating the sign of C along with Sum of B.

ambrish_mishra
Active Contributor
0 Kudos

Hi Praveen,

for this you can simply append the value of C and B and send it as input to the same UDF, instead of value of B. in mapwithDefault for B, put 0.

the same code should cater to this requirement as well.

Ambrish

ambrish_mishra
Active Contributor
0 Kudos

Curious, were you able to work this out!

Ambrish

ambrish_mishra
Active Contributor
0 Kudos

Hi Praveen,

with the above example you gave, I guess you need to create 4 records in the target with one record having summation of 3 values where B = X and other 3 records with values of C.

Is this understanding correct ?

Ambrish

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Praveen,

Try using standard fucntions like below and set A context to root node.

Thank you

allamudi_loordh
Active Participant
0 Kudos

Hi Reddy,

what is mapping of Header you have given?

what about if B is not coming A & C comes..did you check the queue's ..

Regards,

Loordh.

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Loordh,

Just i gave idea how to handle his requirement , i hope he can alter logic to meet requirement(all possible cases)..

Cheers,

Raj

Former Member
0 Kudos

Hi, message mapping should be suitable, have a look at or .

Be cautious when using the sum() function in message mapping, please refer to .

Regards, Martin