Skip to Content
avatar image
Former Member

Account based caclculation time dependent

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jul 24, 2017 at 05:07 PM

    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
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 24, 2017 at 04:17 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 25, 2017 at 08:11 AM

    Thanks Vadim, I will test it.

    Add comment
    10|10000 characters needed 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

  • avatar image
    Former Member
    Jul 28, 2017 at 10:08 AM
    Add comment
    10|10000 characters needed characters exceeded