Skip to Content
0

Can we use IF condition for calling a logic script?

Sep 22, 2017 at 01:28 PM

66

avatar image

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.

10 |10000 characters needed characters left 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)

0

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

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Pratyush Panda 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

Show 1 Share
10 |10000 characters needed characters left 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!

0
Vadim Kalinin Sep 22, 2017 at 03:15 PM
0

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!

Share
10 |10000 characters needed characters left characters exceeded
Vadim Kalinin Sep 27, 2017 at 11:02 AM
0

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

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

Thanks Vadim for reply.

We tried the suggested code, but even if TECH_INT_TOTAL is > 0, system is not considering [C_ACCOUNT].[TECH_INT_04]+[C_ACCOUNT].[TECH_INT_16], rather putting value as 0 for INT_04. That means, it is always considering the code after ":" i.e. "0". Is it?

Also, since we are already putting C_ACCOUNT=INT_04 in our expression, what should we put in

*When C_ACCOUNT

*IS ?????

Thanks.

0

Sorry, but you are not providing full info about your case - I am unable to help you!

Please read: https://blogs.sap.com/2014/01/31/how-to-ask-questions-about-script-logic-issues/

And provide required info and sample test case!

"system is not considering ..." scope may be incorrect!

"what should we put in

*When C_ACCOUNT

*IS ?????" - explain the data you have!

0