I want to make a calculation view in hana studio where I have to maintain ageing of product which is pending in Inventory.
It will subtract on first come first basis...I mean in case of Product P001 then 5500 will subtract 1000 first then balance quantity will subtract 2000 and so on until it will be zero.. Below is the transaction table..
Department |Product | Date | Quantity |Indicator
------------+---------+--------------------+-----------+---------
D001 |P001 | 01-Jul-2017 | 1000 |ADD
D001 |P001 | 10-Jul-2017 | 2000 |ADD
D001 |P001 | 15-Jul-2017 | 3000 |ADD
D001 |P001 | 16-Jul-2017 | 2000 |ADD
D001 |P001 | 18-Jul-2017 | 5500 |SUBTRACT
D001 |P002 | 12-Jul-2017 | 3000 |ADD
D001 |P002 | 14-Jul-2017 | 2000 |ADD
D001 |P002 | 15-Jul-2017 | 4000 |SUBTRACT
And the final output should be something like. if today's date is 31-Jul-2017
Department |Product | Date | Quantity |AgeinginDays
------------+---------+--------------------+-----------+---------
D001 |P001 | 15-Jul-2017 | 500 |16
D001 |P001 | 16-Jul-2017 | 2000 |15
D001 |P002 | 14-Jul-2017 | 1000 |17