cancel
Showing results for 
Search instead for 
Did you mean: 

how to add set of values depending on particular order nember

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thanks for reply.

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?

markangelo_dihiansan
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

former_member194786
Active Contributor
0 Kudos

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.