Skip to Content

Can we use IF condition for calling a logic script?

We have a requirement, where we have to call business rules through logic script based on some condition. For example, if ACCOUNT VALUE > 0 then *INCLUDE ABC.LGF, else PQR.LGF.

Can we achieve this? Happy to elaborate further if required.

Add comment
10|10000 characters needed characters exceeded

  • Thanks for reply Vadim and Pratyush. We have tried to put a logic in logic script for below requirement. Can anybody check if it is correct w.r.t. syntax?

    Requirement is -

    If TECH_INT_TOTAL on C_ACCOUNT_ORIG - DEFAULT > 0 then

    1) INT_04 = TECH_INT_04 + TECH_INT_16

    2) INT_05 = TECH_INT_05 + TECH_INT_17

    3) INT_06 = TECH_INT_06 + TECH_INT_18

    4) INT_07 = TECH_INT_07 + TECH_INT_19

    5) INT_16 = 0

    6) INT_17 = 0

    7) INT_18 = 0

    8) INT_19 = 0

    If TECH_INT_TOTAL on C_ACCOUNT_ORIG - DEFAULT <= 0 then

    1) INT_04 = 0

    2) INT_05 = 0

    3) INT_06 = 0

    4) INT_07 = 0

    5) INT_16 = TECH_INT_04 + TECH_INT_16

    6) INT_17 = TECH_INT_05 + TECH_INT_17

    7) INT_18 = TECH_INT_06 + TECH_INT_18

    8) INT_19 = TECH_INT_07 + TECH_INT_19

    Logic script:

    *WHEN C_ACCOUNT *IS TECH_INT_TOTAL

    *REC(C_ACCOUNT=INT_04,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])>0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_04]+[C_ACCOUNT].[TECH_INT_16]):0)

    *REC(C_ACCOUNT=INT_16,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])==0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_04]+[C_ACCOUNT].[TECH_INT_16]):EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])<0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_04]+[C_ACCOUNT].[TECH_INT_16]):0)

    *REC(C_ACCOUNT=INT_05,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])>0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_05]+[C_ACCOUNT].[TECH_INT_17]):0)

    *REC(C_ACCOUNT=INT_17,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])==0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_05]+[C_ACCOUNT].[TECH_INT_17]):EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])<0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_05]+[C_ACCOUNT].[TECH_INT_17]):0)

    *REC(C_ACCOUNT=INT_06,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])>0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_06]+[C_ACCOUNT].[TECH_INT_18]):0)

    *REC(C_ACCOUNT=INT_18,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])==0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_06]+[C_ACCOUNT].[TECH_INT_18]):EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])<0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_06]+[C_ACCOUNT].[TECH_INT_18]):0)

    *REC(C_ACCOUNT=INT_07,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])>0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_07]+[C_ACCOUNT].[TECH_INT_19]):0)

    *REC(C_ACCOUNT=INT_19,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])==0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_07]+[C_ACCOUNT].[TECH_INT_19]):EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])<0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_07]+[C_ACCOUNT].[TECH_INT_19]):0)

  • P.S. Please comment on the answer, not on the question!

  • Get RSS Feed

3 Answers

  • Sep 25, 2017 at 12:26 PM
    -1

    Hi Sameer,

    I'm not sure which SP you are in but you can explore the keyword

    *XDIM_SKIPNULLCHECK-

    As Vadim suggested, script is not designed to put conditional statement on transaction data and the conditional statement is very native. You have to play around with 'When" condition or skipnull to achieve your desired results.

    Expand further on the requirement and there can be a way around.

    https://www.column5.com/blog/how-to-create-conditional-logic-in-sap-business-objects-planning-consolidation-version-for-netweaver

    Add comment
    10|10000 characters needed characters exceeded

    • Sorry, but *XDIM_SKIPNULLCHECK has ABSOLUTELY no relation to conditions on transaction data values. It's related to master data checks and in most cases can be replaced by SELECT/FOR/NEXT.

      "You have to play around with 'When" condition or skipnull to achieve your desired results." - incorrect!

  • Sep 22, 2017 at 03:15 PM

    No, we can't!

    Script logic is not a real language and there is no IF THEN in it.

    Even more you can't change the script execution based on transactional data value.

    The only supported thing is ternary operator in WHEN/ENDWHEN loop:

    *WHEN ACCOUNT

    *IS A1

    *REC(EXPRESSION=%VALUE%>0 ? %VALUE% : 0, ACCOUNT=A2)

    *ENDWHEN

    If you are able to use WHEN/REC/ENDWHEN instead of your rules you can do something!

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 27, 2017 at 11:02 AM

    Sorry, but looks like you are not reading my answer!

    "*REC(C_ACCOUNT=INT_04,EXPRESSION=(([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])>0)?EXPRESSION=([C_ACCOUNT].[TECH_INT_04]+[C_ACCOUNT].[TECH_INT_16]):0)" - incorrect syntax!

    Syntax from my post:

    *REC(EXPRESSION=%VALUE%>0 ? %VALUE% : 0, ACCOUNT=A2)

    Your REC has to be:

    *REC(EXPRESSION=([C_ACCOUNT].[TECH_INT_TOTAL],[C_ACCOUNT_ORIG].[DEFAULT])>0 ? [C_ACCOUNT].[TECH_INT_04]+[C_ACCOUNT].[TECH_INT_16] : 0, C_ACCOUNT=INT_04)

    For the rest you have to explain the scoping logic...

    Add comment
    10|10000 characters needed characters exceeded