Skip to Content
avatar image
Former Member

Script Logic - Divide by zero

Hello,

I'm currently working with SAP BPC NW 10.1 SP5.

I'm trying to create a script logic to determine the value of an account based on a sum and a division of another accounts. When I test this, if the denominator of the division is 0 or non-existing, the whole result is 0, despite the value of the account I'm using in the sum.

Only for testing purposes, I tried to use values instead of accounts, for example:

*REC(ACCOUNT=PESO_PRODUCAO_DIST_M, EXPRESSION=1 + (2/0)  )

If I use this, I expected the result to be 1, but it is zero.

*REC(ACCOUNT=PESO_PRODUCAO_DIST_M, EXPRESSION=1 + 2 )

If I use this, the result is 3 as expected.

Is this any special behavior regarding division by zero? Are there any workaround, without having to use the conditional logic?

Thanks!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 27, 2015 at 05:43 PM

    Hi Lara,

    Yes, with script logic the division by zero in some record (or with missing record) produce zero!

    But why you want to have "despite the value of the account I'm using in the sum"? Division by zero produce infinite value 😊

    You have to use conditional operator - ternary operator in REC:

    *REC(EXPRESSION=(%VALUE%==0) ? VALUEIFZERO : 1/%VALUE%,ACCOUNT=PESO_PRODUCAO_DIST_M)

    Please explain the logic you want to achieve!

    Vadim

    Add comment
    10|10000 characters needed characters exceeded

    • "Account 1 represents the weight of production of the Entity specified on the total of entities. Account 2 represents the production of the Entity specified in the previous year and Account3 the production of all entities in the previous year." - not clear and not related to the script presented...

      I think that the complete logic has to be redeveloped!

      Just for test you can use the following REC:

      *RECEXPRESSION=([ACCOUNT].[Account3]==0) ? [ACCOUNT].[Account1] : [ACCOUNT].[Account1] + [ACCOUNT].[Account2]/[ACCOUNT].[Account3],ACCOUNT=Account4)


      but the described logic is done by dimension member formulas etc...


      Vadim