cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Conditional *REC Statement

Former Member
0 Likes
720

Hello Everyone,

Ran across a piece of script logic I have never seen before:

*WHEN RPTCURRENCY

*IS USD

*WHEN ACCOUNT

*IS ACCOUNT1

*REC(EXPRESSION = %VALUE% * -1 * (([ACCOUNT].[ACCOUNT2],[RPTCURRENCY].[LC])>-1) * (([ACCOUNT].[ACCOUNT2],[RPTCURRENCY].[LC])<1),ACCOUNT="ACCOUNT3")

*ENDWHEN

*ENDWHEN

Upon execution, the behavior of the *REC statement appears to be as follows:

If the value of ACCOUNT2 is greater than -1 and less than 1 (or said another way...if the value of ACCOUNT2 is between -1 and 1)
, then multiply the value of ACCOUNT1 by -1, and write result to ACCOUNT3.

Can anyone confirm this is in fact the correct behavior of the logic?

Best regards,

-Matt

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Likes

The behavior of this code depends on the calculation engine used by BPC. It will run on JavaScript engine and as far as I remember will not run on ABAP calculation engine:

The logical expression will result in 1 if true and 0 if false.

Vadim

former_member186338
Active Contributor
0 Likes

P.S. Yes, just tested - will work only in case of JavaScript calculation engine.

P.P.S. Using the note http://service.sap.com/sap/support/notes/2228643

you can use multiple conditions in ternary operator with ABAP engine!

SP:

800

SAPK-80020INCPMBPC

801

SAPK-80113INCPMBPC

810

SAPK-81009INCPMBPC

Former Member
0 Likes

Thank you for the feedback, Vadim!  Very interesting.

Per your blog post, I tested the script logic code you provided to determine whether the K2 calculation engine is ABAP or Javascript:

*WHEN ACCOUNT

*IS *

*REC(EXPRESSION=Math.round(%VALUE%))

*ENDWHEN

It does validate in UJKT, so K2 calculation engine is Javascript.

FYI...BPC Version and SP Level:

Reviewed the following SAP Notes:

2010964 - BPC parameters list and how they impact system behavior - BPC NW 10.0/10.1

1691570 - K2: Replace Javascript with ABAP calculation engine

K2_CALC_ENGINE global parameter not specified.  Assuming that means the default is JavaScript?

Looked at the pros and cons listed in 1691570.  Since I'm still getting familiar with the implemented solution, will need to review all script logic to determine the magnitude of what would have to be re-written if we were to switch the K2 calculation engine to ABAP.

Thanks again, Vadim.  This was very helpful.

Best regards,

-Matt

former_member186338
Active Contributor
0 Likes

"K2_CALC_ENGINE global parameter not specified.  Assuming that means the default is JavaScript?" - Yes!

In general ABAP engine is significantly faster, but a lot of scripts can be incompatible! You have to test. String in SPRO for ABAP is ABAP, for JavaScript is JS. If you switch to ABAP all scripts will be validated and in case of error - JS will remain.

For AND condition in ternary operator you will need SP 20

Vadim

Answers (0)