Skip to Content
0

Account based caclculation time dependent

Jul 24, 2017 at 12:25 PM

50

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Vadim Kalinin Jul 24, 2017 at 05:07 PM
0

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
Share
10 |10000 characters needed characters left characters exceeded
Vadim Kalinin Jul 24, 2017 at 04:17 PM
0

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...

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jul 25, 2017 at 08:11 AM
0

Thanks Vadim, I will test it.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
avatar image
Former Member Jul 28, 2017 at 10:08 AM
0
Show 1 Share
10 |10000 characters needed characters left characters exceeded

*XDIM_SKIPNULLCHECK can be also used in the recent BPC SP's, but FOR/NEXT will also do the job without issues!

0