# ALV - Summing the Quantity field problem.

I have got an requirement to create an contract related sales order report in ALV.

In which i want to sum the quantity order(KWMENG- from SO) for each line item of contract and subtract it from

target quantity(ZMENG - contract). i am facing problem in summing the quantity order. I have given do sum in field catalog.

if each sales order has single delivery there is no issues in summing the quantity, but if each sales order has multiple delivery, then the quantity is displaying as many as delivery. for example. if contract (20000004) has 4 line items , and 4th line item has the target quantity is 70 and but sales order's quantity as per deliveries, 3072000014- 40th line item-2 times the quantity is printed 20.00 but only one 20.00 should be calculated,3072000013, has single delivery so no prbm,3072000012 has three deliveries so 20.00 is three times it should be calculated only one times, so summing is issue here ...

balanced quantity = target quantity - (sum of quantity orders)

BQ = 70 -(20+30+20) = 0.. This should be the case.

but BQ = 70 - ( 20+20+30+20+20+20) . This is happening..

10|10000 characters needed characters exceeded
• Try changing the sort and group from Contract - SO - QTY to SO - Contracy - QTY.

remaining target qty = target qty - quantity ==> for so line item 10 - 1st line,

for the next line, if the so line item is same then it should do, remaining target qty = remaining target qty - quantity, for the next it is repeating.. How i could achieve this in coding..please help.

cso.png

cso.png (268.3 kB)
• Maybe i dont have SD background so i dont get why you want to sum like that. if you have 1 SO with multiple deliveries, isnt it true that total quantity of each delivery must be equal to target quantity of SO? you may solve it by sum using abap code instead of ALV standard function (i think ALV cant do it), but still might be the logic you use to determine quantity of delivery is not correct.