Delete using aggregated quantity in end routine
Is it possible to delete data out in an end routine by aggregated quantity? Or do I need to code it?
I have a DSO being loaded with forecast data. However I dont want to keep any data where there is a quantity less than 200 for any particular material in any given period. However data comes through in lines that are less than two hundred but when aggregated together may be greater than 200.
I tried a simple delete result package statement but due to the fact they are not aggregated at this point it delete out all the lines which add up to be greater than 200.
It is possible, assuming that all the data for a given period and material combination is being loaded with the same DTP request.
If that is the case, then apply a Sem. Grouping for Period and Material in the transformation. Then, write an end routine based on the below pseudocode.
DATA: ls_summary --- a work area containing matl, plant and qty.
DATA: lt_summary --- a HASHED table with line like ls_summary and default key
LOOP AT RESULT_PACKAGE ASSIGNING <RP>.
Copy Material, Plant and Qty from <RP> to ls_summary.
COLLECT ls_summary into lt_summary.
LOOP AT lt_summary into ls_summary where qty < 200.
DELETE from result_package where matl = ls_summary-matl and plant = ls_summary-plant.