on 04-15-2015 9:39 AM
Hi Expers,
I have a requirement,
for particular order no,,,there will be multiple line numbers, for each line item there will be cost. My requirement is I need to add all the line item values for each order no.
Example
Order1
line item 1 cost: 10
line item 2 cost: 20
Order2
line item 1 cost: 30
line item 2 cost: 40
I will be inserting the records to database depending on no. or order items, in this case two rows will be inserted for first order 30 to cost field, and second order 70 to cost field.
how to achieve this with message mapping? Quick response is appreciate.
Thanks,
Chandar
Hi,
If your structure is like this:
Order 1..1
-->line 0..unbounded
------>item 0..1
------>cost 0..1
In your message mapping, the default context of cost would be line, set it to Order and the
context change would be like this:
10
20
ContextChange
30
40
After that use the sum function, it should add 10+20 and 30+40 which would result to
30
ContextChange
70
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandar,
that's correct, if order1 and order2 are in-order then it will work. If order is something like this...Order3, Order1, Order2, then how to maintain the context?
The procedure is still the same, just after the sum function you will need to use remove context and sortByKey (Order is the key used to sort) to determine the correct ordering.
Regards,
Mark
Use a simple udf with all the values of the context and loop through the length of line items in the context to add the costs. I guess it should suffice.
Thanks,
Sanjeev.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.