Hello,
I need to calculate in script logic the values of the closing value of the month based on the opening value and the purchases and sales of the month, for all the months of the 6 years in the budget process. The opening value of the month is the closing value of the previous month.
Example:
2015.Jan 2015.Feb 2015.Mar
OpeningValue 1000 950 1100
Purchases 50 200 50
Sales 100 50 250
ClosingValue 950 1100 900
I've achieved this with the following script:
*SELECT(%FIRST_YEAR%, YEAR, CATEGORY,ORC_ACTIVE=1)
*SELECT(%LAST_YEAR%, LAST_YEAR, CATEGORY,ORC_ACTIVE=1)
*SELECT(%T_BUDGET%, ID, PERIOD, "YEAR>='%FIRST_YEAR%' And YEAR<=%LAST_YEAR% And LEVEL='MONTH'")
*XDIM_MEMBERSET PERIOD = %T_BUDGET%
*XDIM_MEMBERSET RUBRICA_INV_DIV = OpeningValue,Purchases,Sales
*WHEN_REF_DATA=TRANS_DATA
*FOR %PER% = %T_BUDGET%
*WHEN PERIOD
*IS %PER%
*REC(RUBRICA_INV_DIV=ClosingValue)
*REC(RUBRICA_INV_DIV=OpeningValue,PERIOD=PERIOD.NEXT)
*ENDWHEN
*NEXT
The NW version doesn't allow the use of CALC_EACH_PERIOD, so the only solution I found so far was the use of *FOR/*NEXT, but because I have to run this for 72 months the performance is really bad.
Is there any way to increase the execution speed of this script?
Thanks!