I have a requirement which I'm not quite sure how to get around.
I'm writing a query based on Sales Documents and Delivery Documents.
I am using table joins between VBAK, VBAP, VBFA, LIKP, LIPS, and VBUP.
The output I want is to display the shortage on deliveries compared to sales orders where applicable. I calculate this by Sales Order Quantity - Delivery Quantity.
I have nearly been able to get the output I want, however consider this scenario:
A customer orders 20 of a particular item.
10 of these are packed and delivered. Then, in the same night, the rest of the items are packed and delivered.
This means there is one item on the Sales Order with quantity 20, and two items on the delivery notes of 10 and 10.
The output I receive in this instance is as such:
Depot | Material | Description | Short or Over | Sales Order Qty | Delivery Qty | Sales Order No | Sales order Item |
FAVERSHAM | 111111 | Material 1 | 1 | 33 | 32 | 443011 | 60 |
FAVERSHAM | 111111 | Material 1 | 32 | 33 | 1 | 443011 | 60 |
CREWE | 111112 | Material 2 | 1 | 10 | 9 | 443020 | 50 |
CREWE | 111112 | Material 3 | 4 | 15 | 11 | 443020 | 10 |
Material 1 hasn't had a shortage...it's just been delivered in two separate packs of 1 and 32 to add up to the order quantity of 33, so it shouldn't be displayed at all.
Materials 2 and 3 are displaying fine because there's only one delivery note assigned to them thus far.
How can I get around this issue?
Thanks in advance.