The cumulative stock scrap quantity is the sum of Stores to Scrap movements less the scrap reversals that fall within the specified view horizon.
The cumulative stock scrap quantity is calculated as follows:
Select Stores to Scrap movements where the part number equals the supply demand part number and the movement date/time is between the view horizon from and view horizon to dates to get the total scrapped quantity.
Do the same calculation for the Scrap to Stores movement to get the returned quantity.
Subtract the returned quantity from the scrapped quantity to get the cumulative stock scrap quantity.