on ‎2017 Jul 24 1:25 PM
Hi all,
I have two rules in my account based calculations, let's call them RULE_JAN and RULE_OTH. I am looking to create one script that will execute RULE_JAN when the user selects the January of any year as the period and RULE_OTH when the user selects a month that is not January.
So far I have tried to use a *WHEN TIME.PERIOD *IS JAN *ELSE version but since I have no *REC statement BPC does not accept this. I then tried to use this
*SELECT(%PERJAN%,[ID],TIME,ID=%TIME_SET% AND PERIOD=JAN)
*RUN_PROGRAM CALC_ACCOUNT
CATGEORY = %CATEGORY_SET%
CURRENCY = EUR
TID_RA = %PERJAN%
OTHER = [ENTITY = %ENTITY_SET%]
CALC = RULE_JAN
*ENDRUN_PROGRAM
*SELECT(%PER%,[ID],TIME,ID=%TIME_SET% AND PERIOD<>JAN)
*RUN_PROGRAM CALC_ACCOUNT
CATGEORY = %CATEGORY_SET%
CURRENCY = EUR
TID_RA = %PER%
OTHER = [ENTITY = %ENTITY_SET%]
CALC = RULE_OTH
*ENDRUN_PROGRAM
But that version always executes both, so I always end up with the result of the rule I call in second place.
Does anyone have any idea how I can solve this? I am running BPC 10.0.
Thank,
Arnold
Request clarification before answering.
Universal script with conditional execution of sections:
//%TIME_SET%=2016.01,2017.01,2016.03,2017.04 - some combination
*SELECT(%PERJAN%,[ID],TIME,ID=%TIME_SET% AND PERIOD=JAN) //%PERJAN%=2016.01,2017.01
*SELECT(%TESTJAN%,[CALC],TIME,ID=%PERJAN%) //%TESTJAN%=N,N or empty if %PERJAN% - empty
*SELECT(%SINGLEJAN%,[ID],TIME,ID=2017.01 AND CALC=%TESTJAN%) //%SINGLEJAN%=2017.01
*FOR %SJ%=%SINGLEJAN% //%SINGLEJAN% can be 2017.01 or empty if no JAN selected
*RUN_PROGRAM CALC_ACCOUNT
CATGEORY = %CATEGORY_SET%
CURRENCY = EUR
TID_RA = %PERJAN%
OTHER = [ENTITY = %ENTITY_SET%]
CALC = RULE_JAN
*ENDRUN_PROGRAM
*NEXT
*SELECT(%PER%,[ID],TIME,ID=%TIME_SET% AND PERIOD<>JAN AND CALC=N) //%PER%=2016.03,2017.04
*SELECT(%TESTOTH%,[CALC],TIME,ID=%PER%) //%TESTOTH%=N,N or empty if %PER% - empty
*SELECT(%SINGLEOTH%,[ID],TIME,ID=2017.01 AND CALC=%TESTOTH%) //%SINGLEOTH%=2017.01
*FOR %SO%=%SINGLEOTH% //%SINGLEOTH% can be 2017.01 or empty if no <>JAN selected
*RUN_PROGRAM CALC_ACCOUNT
CATGEORY = %CATEGORY_SET%
CURRENCY = EUR
TID_RA = %PER%
OTHER = [ENTITY = %ENTITY_SET%]
CALC = RULE_OTH
*ENDRUN_PROGRAM
*NEXT
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Arnold,
Check this blog.
I guess this could be relevant to you.
Regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Vadim, I will test it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To test it you can run the following code:
//%TIME_SET%=2016.01,2017.01,2016.03,2017.04-some combination
*SELECT(%PERJAN%,[ID],TIME,ID=%TIME_SET% AND PERIOD=JAN) //%PERJAN%=2016.01,2017.01
*SELECT(%TESTJAN%,[CALC],TIME,ID=%PERJAN%) //%TESTJAN%=N,N or empty if %PERJAN% - empty
*SELECT(%SINGLEJAN%,[ID],TIME,ID=2017.01 AND CALC=%TESTJAN%) //%SINGLEJAN%=2017.01
*FOR %SJ%=%SINGLEJAN% //%SINGLEJAN% can be 2017.01 or empty if no JAN selected
*XDIM_MEMBERSET TIME=%PERJAN%
*NEXT
*SELECT(%PER%,[ID],TIME,ID=%TIME_SET% AND PERIOD<>JAN AND CALC=N) //%PER%=2016.03,2017.04
*SELECT(%TESTOTH%,[CALC],TIME,ID=%PER%) //%TESTOTH%=N,N or empty if %PER% - empty
*SELECT(%SINGLEOTH%,[ID],TIME,ID=2017.01 AND CALC=%TESTOTH%) //%SINGLEOTH%=2017.01
*FOR %SO%=%SINGLEOTH% //%SINGLEOTH% can be 2017.01 or empty if no <>JAN selected
*XDIM_MEMBERSET TIME=%PER%
*NEXT
Look on results in UJKT for different TIME scope
If the user always select only single month, then there is a simple solution:
*SELECT(%PERJAN%,[ID],TIME,ID=%TIME_SET% AND PERIOD=JAN)
*FOR %PJ%=%PERJAN%
*RUN_PROGRAM CALC_ACCOUNT
CATGEORY = %CATEGORY_SET%
CURRENCY = EUR
TID_RA = %PJ%
OTHER = [ENTITY = %ENTITY_SET%]
CALC = RULE_JAN
*ENDRUN_PROGRAM
*NEXT
*SELECT(%PER%,[ID],TIME,ID=%TIME_SET% AND PERIOD<>JAN)
*FOR %P%=%PER%
*RUN_PROGRAM CALC_ACCOUNT
CATGEORY = %CATEGORY_SET%
CURRENCY = EUR
TID_RA = %P%
OTHER = [ENTITY = %ENTITY_SET%]
CALC = RULE_OTH
*ENDRUN_PROGRAM
*NEXT
It will also work for multiple selection, but for multiple selection you may need more complex coding to make script run faster...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 17 | |
| 11 | |
| 9 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.