I have made a query and created a new field related to the invoice qty. All at item level and referenced to the sales order.
This new field is configured to pull the invoice qty from the document flow:
FACPOS = ' '.
select RFMNG into FACPOS
where vbelv = vbap-vbeln
and posnn = vbap-posnr
and vbtyp_n = 'M'.
Then the report shows the sales order qty and the invoice qty per item. Everything looks perfect at this time. The problem starts when the invoice is partially created from partial deliveries (which is very often) and then a partially invoice is made. Due to the fact that the data is generated from the VBFA table, it will always going to bring the latest invoice qty and not the sum of all the invoices.
Order for 6 pcs of product A
Delivery for 4 pcs and Invoice for 4 pcs
Pending 2 pcs
Report shows: Invoice qty 4 pcs
Then another invoice is created for 2 pcs
Nothing left from the sales order
Report shows: Invoice qty 2 pcs <----
PROBLEM: The report only shows as a total of the invoice qty just the 2 pcs from the last invoice. I actually want to add up all the invoice qty's generated per line item in the document flow.
1. Any idea on how to configure the code so that I can have the sum of all the invoices in the document flow per item?
2. Is there a special function that can do this?
Pls let me know