Anda di halaman 1dari 4

22.7.

2014

Using Javascript to enhance Script Logic | SCN


Getting Started New sletters

Hi, Guest

Log On

Store

Search the Community

Join Us

Products

Services & Support

About SCN

Downloads

Industries

Training & Education

Partnership

Developer Center

Lines of Business

University Alliances

Events & Webinars

Innovation

Activity

Communications

Actions

Brow se

Enterprise Performance Management (SAP EPM)

Using Javascript to enhance Script Logic


Posted by Samuel Henrique Matioli in Enterprise Performance Management (SAP EPM) on Jan 2, 2013
Previous
Next
1:01:07 PM
Share

Tw eet

Like

Using Javascript to enhance Script Logic


Applies to SAP Business Planning & Consolidation 7.5 NW and SAP Business Planning & Consolidation 10
NW
Sometimes, when we are developing some script logic, we face a lot of limitations.
Suppose you need to calculate a standart deviation. The formula contains a square root. But how calculate the square
root of some number with Script Logic? The answer is not well documented in the BPC manuals: JavaScript.
postpost
The engine that process script logic uses javascript classes to solve the EXPRESSION part of a REC sentence.
For this example, I created 4 accounts just to test this feature.
In account VL001, I inserted the value that I want to use in calculation:

After saving data, I executed the following Script Logic:


*XDIM_MEMBERSET ACCOUNT = VL001
*XDIM_MEMBERSET CATEGORY = %CATEGORY_SET%
*XDIM_MEMBERSET TIME = BAS( %TIME_SET% )
*WHEN ACCOUNT
*IS VL001
*REC(EXPRESSION=javascript:Math.sqrt(%VALUE%), ACCOUNT="VL004")
*ENDWHEN

http://scn.sap.com/community/epm/blog/2013/01/02/using-javascript-to-enhance-script-logic

1/4

22.7.2014

Using Javascript to enhance Script Logic | SCN

After the refresh, the account VL004 now have the value 10, which is the square root of 100:

Extending this example, we can use other mathematical functions of java script:
*XDIM_MEMBERSET ACCOUNT = VL001
*XDIM_MEMBERSET CATEGORY = %CATEGORY_SET%
*XDIM_MEMBERSET TIME = BAS( %TIME_SET% )
*WHEN ACCOUNT
*IS VL001
*REC(EXPRESSION=javascript:Math.abs(%VALUE%), ACCOUNT="VL002")
*REC(ACCOUNT="VL005", EXPRESSION=javascript:Math.ceil(%VALUE% ) )
*REC(ACCOUNT="VL006", EXPRESSION=javascript:Math.floor(%VALUE% ) )
*REC(ACCOUNT="VL007", EXPRESSION=javascript:Math.round(%VALUE% ) )
*REC(ACCOUNT="VL008", EXPRESSION=javascript:Math.random( ) )
*ENDWHEN

http://scn.sap.com/community/epm/blog/2013/01/02/using-javascript-to-enhance-script-logic

2/4

22.7.2014

Using Javascript to enhance Script Logic | SCN

But there is a problem. If the function requires more than one parameter, the script returns a error. For example, it
is not possible to use the function Math.pow, because it requires two parameters.
This happens when engine that processes script logic breaks the *REC expression in commas, and then it breaks the
expression.

I hope it helps.
Samuel Matioli

925 View s

Tasks: development Tags: javascript, bpc, script_logic, bpc_nw , math_calc

Average User Rating


(3 ratings)

Share

Tw eet

Like

4 Comments
Arun Kumar Suryanarayana Rao Jan 3, 2013 7:25 AM

Hi Samuel,
Thanks for sharing the information.
Arun

http://scn.sap.com/community/epm/blog/2013/01/02/using-javascript-to-enhance-script-logic

3/4

22.7.2014

Using Javascript to enhance Script Logic | SCN


Like (0)

John Leggio Jan 4, 2013 4:55 AM

Hi Samuel,
Interesting article. As of BPC 10 SP07 the calculation engine was switched from JavaScript to ABAP
(see note 1691570). You can still still use the JavaScript engine in later versions if needed (see note
1748676)
Thanks,
John
Like (0)

Samuel Henrique Matioli Jan 4, 2013 1:18 PM (in response to John Leggio)

Thank you,
It's true.
I run my test on 7.5 SP12 and 10.0 SP06.
The SP07 has a lot of improvements in script logic engine - which in fact needs all of that
improvement.
I did not read all the notes, but BPC would can still use the javascript engine when its would
be explicitly declared, like this examples. So many customers does not need to change
their scripts.
Like (0)

Karsten Wenzel Sep 3, 2013 2:30 PM

Hi Samuel,
Thanks so much for the information.
Best Regards,
Karsten
Like (0)

Site Index
Privacy

Contact Us
Terms of Use

SAP Help Portal


Legal Disclosure

Copyright

http://scn.sap.com/community/epm/blog/2013/01/02/using-javascript-to-enhance-script-logic

Follow SCN

4/4