BPC Script Logic For Dummies - MS PDF
BPC Script Logic For Dummies - MS PDF
It means the Records value will be calculated as a product of current record value and scale property value of
entity
member in the current record.
Let's assume fact table has below current records.
ACCOUNT, ENTITY, CURRENCY, SIGNEDDATA
Revenue, CT, USD, 100
Revenue, CA, USD, 200
Revenue, NJ, USD, 300
Revenue, NY, USD, 400
Here is an example logic script.
*WHEN ENTITY.SCALE
*IS <>
*REC(EXPRESSION=%VALUE%*FLD(ENTITY.TAXRATE)/100, ACCOUNT="TAX")
*ENDWHEN
and let's say ENTITY dimension member worksheet looks like below.
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
Note: if ACCOUNT.MYPROPERTY has "TAX" value, it will get the value of TAX account record
value.
GET(ACCOUNT=ACCOUNT.ELIMACC,ENTITY=INTCO.ENTITY)
Note: User can specify multiple dimension names to select record.
All missing dimension will be same as source record.
Let's use the same example that we used above.
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
// 300 - 21
There are two things you keep in mind to use this GET function.
First, GET function will not search from database but search from 'SELECTED REGION'.
Therefore, you should specify members in the *XDIM_MEMBERSET before use GET function.
That's why we specified *XDIM_MEMBERSET ACCOUNT = REVENUE, TAX in the example.
Second, the Script engine can't use the results of a previously calculated value without *COMMIT
statement.
*WHEN ACCOUNT
*IS UNITS
*REC(ACCOUNT=REVENUE, FACTOR=GET(ACCOUNT=PRICE))
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
*IS REVENUE
*REC(ACCOUNT=TAXES, FACTOR=.5)
*ENDWHEN
So we need to separate two calculations using Commit statement to make it work.
*WHEN ACCOUNT
*IS UNITS
*REC(ACCOUNT=REVENUE, FACTOR=GET(ACCOUNT=PRICE))
*ENDWHEN
*COMMIT
*WHEN ACCOUNT
*IS REVENUE
*REC(ACCOUNT=TAXES, FACTOR=.5)
*ENDWHEN
Usually, *COMMIT statement will post records into the database but what if the customer wants to calculate
without
posting data?
This member can be used as temporary records to store intermediate results that can be used as inputs for
subsequent
calculations. These temporary records will be automatically skipped during the commit time.
Dummy members must be identified with a leading pound (#) sign.
For example:
*REC(ACCOUNT=#TEMP_ACC)
Even though #TEMP_ACC member does not exist in the account dimension, the generated record can be
used anywhere in the logic
as below example, but its value will not be stored in the database.
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
*WHEN ACCOUNT.FLAG
*IS = Y
*REC(ACCOUNT=#TEMP_ACC)
*ENDWHEN
*GO
*WHEN ACCOUNT
*IS #TEMP_ACC
*REC(FACTOR=GET(ACCOUNT=MULTIPLIER),ACCOUNT=FINAL)
*ENDWHEN
This is useful to calculate a complex calculation like allocation.
Let's assume you want to allocate some expense based on the each store's area.
You must have a total area value of each store because the formula will be
Each Store's Expense = Total Expense amount * Each Store's area / Total area
Even though each store's area is saved in the database as an account member, you need to have the total
value. Of
course, it is easy to get the total value using MDX script statement but we need to do it using the SQL script
statement
for better performance.
Finally, I finished the BPC Script logic for dummies(?) series.
Well, it might not be enough for using it right now but as I addressed in the first post,
I hope you get the basic concepts of BPC script logic so that you can understand and read what it means.
Thank you for reading this series.
James Lim
11763 Views Tags: sap_business_planning_and_consolidation
Kati Hornung
Jul 11, 2015 5:31 AM
Hi James Your blog postings were incredibly helpful and as a result I was able to script a somewhat complicated account
reclassification. I had seen elsewhere on the boards that doing a scripted account balance reclassification
evaluation (if sum of X > 0, do this - if X < 0, do that) was not possible in the NetWeaver version, although
perhaps I misunderstood that.
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
However, with your assistance I discovered a way to make it work. I have posted my solution (SAP-BPC
Netweaver Scripting for Account Reclassification | Kati Hornung | LinkedIn) for anyone else wanting to script
account reclassification in NW. I'm paying it forward with a resounding thank you to you at the top!
Thanks again - this was invaluable!
- Kati
Derk Winkelmann
Apr 14, 2015 11:39 AM
Hi James, the Script Logic for dummies Blogs were very helpful. Made it much easier to understand the basics.
Thanks.
Takato Nagashima
Mar 16, 2015 7:50 AM
Hello James
Thank you so much for your helpful blogs.
I and our team do appreciate them.
There is a question that we would like your advice to solve.
About "WHEN_REF_DATA" statement.
Though , "WHEN_REF_DATA" statement allows us to filter data by data types; transaction data or masterdata,
in our understanding, the basic function of logic script is for scoping transaction. So there should be no
situation to process master data in logic script.
We will appreciate it if you provide us some advice to understand the real function of this statement.
Thank you.
Mitch Lim
Jan 21, 2014 8:16 AM
Thanks James for these blogs
James Lim in response to David Jorjani on page 6
Dec 5, 2013 4:56 PM
Thank you for comment . It was updated with latest service pack.
As I addressed, BPC NW is still improving
David Jorjani in response to Victor Figueroa on page 7
Nov 21, 2013 7:37 PM
BAS works in BPC 10. An example would be:
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
*REC(EXPRESSION=%VALUE%*LOOKUP(NEWRATE),CATEGORY=%CATEGORY_SET
%,FS_ITEM=SELLEXP.NRATE,RPTCURRENCY="USD")
*ENDWHEN
*ENDWHEN
*ENDWHEN
*COMMIT
Thanks
Sharif
James Lim in response to sharif shaik on page 8
May 23, 2012 8:43 PM
Sharif,
Basically, if your logic script tries to post same data, it will be posted difference between existing value and
posting value.
Therefore, if there is no difference, it will not post any data.
There is an option to change this behavior in BPC MS only.
*Calcuate_difference = 0 (default is 1)
Thanks,
James Lim
sharif shaik in response to James Lim on page 8
May 23, 2012 8:20 PM
James,
Thanks for sharing BPC Script logic basics in your blog. It is very useful for people new to BPC.
I do have question on *REC statement. what makes *REC statement writing a record verses updating existing
record. What happened if the record already exists and *REC stement try to add. will simply add another
record?. We are using BPC 7.5 NW.
Thanks
Sharif
James Lim in response to Nathan Arbeau on page 9
Apr 26, 2012 11:15 PM
Nathan,
I am sorry for late reply, I was on vacation and am travelling now for customer.
Basically, All dynamic variable can't be used in the same block because it is not in the table that will be read by
GET function.
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)
James.
Nathan Arbeau
Apr 19, 2012 2:56 PM
Hi James:
I am wondering if there is a way to pickup dynamic temp variables in GET statement. For example:
// Do Calculation within WHEN
*REC(EXPRESSION=%VALUE%,ACCOUNT=#%ACCOUNT%)
// Now if I try to pickup those dynamic temp account with GET it doesn't work
*REC(EXPRESSION = GET(ACCOUNT = "#%ACCOUNT%")
I have tried various methods to get this to work but it continues to bring back 0
Is there a way to do this?
James Lim in response to Pankaj Patil on page 9
Nov 8, 2011 6:30 AM
Hi PanKaj,
I have never tried it that case before :)
Please try it but I guess it might not WORK because all temp variable will be cleared after COMMIT.
Why do you want to use COMMIT between them?
If the number of records are not too big, it will be ok to use GO.
James.
Pankaj Patil
Nov 7, 2011 10:38 PM
Hi James,
Can the intermediate # values generated before GO be used after the commit as well ?
Example:
Logic...(#A1 is generated)
GO
Logic...(#A1 can be used)
COMMIT (Write to DB)
Logic... (Can #A1 values be used in this block ?)
COMMIT
Regards,
Pankaj
Ethan Jewett
SAP Planning and Consolidation, version for SAP NetWeaver: BPC Script logic for Dummies? (Final)