You are on page 1of 23

BPC 10.

0 NW
Script Logics

Author: Surya Padhi
Mail : SuryaPadhi@Gmail.Com.
SAP Certified Application Associate - Financial Accounting
SAP Certified Application Associate - SAP BusinessObjects Planning and Consolidation 10.0
Disclaimer: This document contains only intended strategies, developments, and functionalities of the SAP product and is not intended to be binding
upon SAP to any particular course of business, product strategy, and/or development. SAP and author assume no responsibility for errors or
omissions in this document. This preview is provided without a warranty of any kind, either express or implied, including but not limited to the
implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP and author have no liability for damages of any kind
including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials.

In SAP BPC, we use script logics to copy, calculate and write data based in selection. On
several occasions I have seen, functional consultants find it difficult to understand. In this
presentation I will cover following topics relating to BPC 10.0 NW script logic for
simplification and easy understanding.
1) Definition;
2) Functionalities
3) Syntax
4) Testing of script logics.

these are (1) SQL based syntax and (2) MDX based syntax . SAP has provided two types of scrip logics syntax .Definition Script Logic – enables calculations on base-level cells that result in data stored within an . I will cover in detail above syntax in more details in the next few slides. www.suryapadhi. without being recalculated at upper suryapadhi@gmail. The results are aggregated up the dimensional hierarchy.

2) After Journal data send using either Default. 2) Applies to it a set of user-defined formulas (stored in a logic file). Results are written directly to the model as base data. or if present. 3) Derives the values.Functionalities: The script logic. 4) Writes those values back to the application.suryapadhi. Script logic can be run in any of three ways: 1) Automatically after data is sent to the database from BPC for Excel using the Default. 2) This process allows you to perform calculations. 1) All dimension logic formulas are applied to these results.LGF file. Journal. www. 3) Through Data Manager as a batch processing event to call Script Logic .com suryapadhi@gmail. LGF. and are aggregated up the dimensional hierarchy as they are. 1) Reads a specific data selection from the model. without being recalculated at upper levels. LGF files.

data manager package etc.Functionalities: Advantages of BPC script logics 1) Model dependent calculation. 3) With the help BPC logics. we can choose desired dimensions with the help of dimension properties. we can perform different type of calculation with or without calling business rules. not at a member level of the dimensions.suryapadhi. 2) BPC scripts can be called from different places. 4) In SAP BPC script logics. suryapadhi@gmail. for example default logic. Disadvantages of BPC script logics 1) BPC script can’t handle very complex calculation processing or bigger data volume. ABAP-BADI comes into the picture. We can call ABAP-BADI codes within the script . In case of a complex calculation.

These are: 1) SQL based syntax: SQL syntax gives better performance. While developing complex calculation. MDX syntax causes performance issues. Use fewer commits statements. While choosing script logics. Scoping uses memory. www. 2. choose surya@suryapadhi. 5. 3. hence scoping should be precise. 2) MDX based syntax. Use limited looping to improve performance. 1.Syntax There are two Syntax options in SAP BPC Script Logic. 4. we need to consider following points for performance consideration.suryapadhi. so use SQL logics as far as possible. Multidimensional expressions abbreviated as . MDX syntax is used in record level specific calculations). .com surya@suryapadhi. 2) BODY – In this section.suryapadhi. *XDIM_MEMBERSET Category = PLAN *XDIM_MEMBERSET Entity = C3000 *XDIM_MEMBERSET P_DataSrc = MANUAL *XDIM_MEMBERSET RptCurrency = LC SCOPING *XDIM_MEMBERSET P_Activity = EMPL1 *XDIM_MEMBERSET P_ACCT = CE0004220 *XDIM_MEMBERSET TIME = 2007. we tell to the system what to be done I. perform calculation. 1) SCOPING – In this section we define the scope of data to which calculation will be applied.JAN *WHEN P_ACCT *IS CE0004220 *REC (EXPRESSION = 901) BODY *ENDWHEN *COMMIT COMMIT www. 3) COMMIT – In this section we tell to section to save the calculated result to the database.Syntax STRUCTURE OF SCRIPT LOGIC: Script logic structure is divided in three parts.e. Aggregation etc.

Syntax Script Logic can be broken down into 3 components: • .suryapadhi.What am I running the data on? • Data manager scoping • Input schedule scoping • Scope control • Body / Code .What do I want to do with the scoped record? • *IIf Statements • *REC • [#] based MDX statements • *WHEN / *IS / *ENDWHEN • Allocation Logic • Writing the records • *COMMIT surya@suryapadhi.

com suryapadhi@gmail.Syntax Due to performance issue MDX syntaxes are less favorite among BPC developers.9. Example: -*REC (FACTOR = 0. *REC = This statement generates a record / modifies a record that to be posted in the database. 1.e. account). there can be a separate XDIM statement. *XDIM_MEMBERSET = It restricts the data. 3. *ADD / *ENDADD = Add set of values members (i. 2. 4. www. accounts) to another set of values ( i.suryapadhi. Even if it is for the same destination cell. During LGX . intended in the script logic. Which means multiply by 0.ACCOUNT="DISCOUNT_EXTSALES"). Included scripts carry different calculation once you execute the main script. In this section l will cover commonly used SQL based syntax. *INCLUDE = With this syntax. a source record can generate as many destination cell records. all codes are combined into one big piece of code and executed during runtime. For each restriction using a dimension.9 to current scoped record and replace account with DISCOUNT_EXTSALES write values to DISCOUNT_EXTSALES. filters the source dataset to the required dataset for specific calculation.e. Generally it is followed by the Dimension name & Member value/value set. Multiple REC statements possible between *END/*ENDWHEN statement. you can include multiple Script Logic files in a script.

*XDIM_FILTER = Filters the members of the scope of that dimension.suryapadhi. Generally better to write in the beginning of the logic structure. *SELECT / *ENDSELECT = Like any other SQL statement. XDIM_MAXMEMBERS = Specifies the maximum number of members that should be included in one query. It works as a loop statement. rather filters from available scope. 10. In this case system will select account members which contains ACCTTYPE property value as “AST” 7. but this it used when different transformation is needed for different type of field values in a record. Same as SELECT/ENDSELECT statement. *XDIM_ADDMEMEBERSET = This statement is used to add more member values to the scope of member value already defined with the XDIM statement for conditional calculations. 6. It does not filter the scope of data. *WHEN / *ENDWHEN = *WHEN/*ENDWHEN can be used with property values of the dimension.'AST').*XDIM_FILTER ACCOUNT = [account]. configuration needs to be done in SPRO need to be done before using this.Syntax 5. XDIM_PACKAGEBY = This syntax is used for parallel processing. Hence multiple *WHEN/*ENDWHEN statements possible within a script logic. to further create conditions for data processing / transformation / modification / manipulation. . www. 9. Can be written in any part of the logic and the resultant value can be used in any part of the logic as well. Ex: *WHEN ACCOUNT *IS “XY00001234”. for the REC suryapadhi@gmail. this syntax helps to retrieve a list of values from the master data table (Dimension) and store them in a defined variable. Example .

Apr + 12 months = 2007. . Between Dimension “Category” suryapadhi@gmail.suryapadhi. *DESTINATION_APP = Use to make the datasets of one model available for other. In this case the time value is 2006. www. It is acts like a “READ” statement in traditional ABAP. before its value is used in another calculation formula within the script logic.APR)). *LOOKUP / *ENDLOOKUP = Similar to “*DESTINATION_APP” but this does not transfer the data between the model. it will be required to look into the EXCHANGERATES model. 14. TIME=TMVL(12. resulting value of the first calculation must be saved into the database with a “*COMMIT” statement. rather looks up for the required calculation. It transfers the data from one model to another. *TMVL = This is used to retrieve a time value after taking into consideration an offset value from a given time period.1.Syntax 11. Example: While doing currency translation of a value. In case of two dependent calculations. REC(FACTOR=1.2006. *COMMIT = Saves/stores the calculated values in the database. 12.

Possible to use this for multiple dimensions in one statement. if the destination model does not contain all the dimensions as the source model. *RUNALLOCATION = This syntax help execute SAP delivered allocation logic. 17. if source model does not contain all the dimensions as the destination model. *ADD_DIM = While copying data between two models. *RENAME_DIM = While copying data between two models. Possible to use this for multiple dimensions in one statement. missing dimensions in the source model can be created/added using this syntax before data copy. *START_BADI / *ENDBADI = This script helps in calling BAdIs within the script logic to perform an endless variety of functions.Syntax 15.suryapadhi. Works as IF. Possible to use this for multiple dimensions in one statement. 18. if dimension names between the models do not match. 16. some of the destination models can be skipped from copying process using this . *SKIP_DIM = While copying data between two models. ELSEIF & ENDIF statement in traditional ABAP. 19. 20. suryapadhi@gmail. *SELECTCASE / *ENDSELETC = This is a select statement with a CASE together to encourage conditions within. then mismatching dimension names can be renamed to be the same before copy process.

*GET = Retrieves the value from the memory 25. it loops through all the master data values of the dimension. If the condition is true. as may have seen in BW-BEX formulas. which uses the dimension/values in its scope. *WHEN _REF_DATA = It sets the focus to either master data or transactional data. www. 22. just as IF. The individual conditions will be enclosed in parenthesis. Similar . It works like FOR EACH statement in FOX formula. 23. This syntax then helps to process individual variable values. ENDIF statements in traditional ABAP. one by one. Function is used in BPC to enhance readability. *FUNCTION / *ENDFUNCTION = This syntax is very often used in MDX. the return value will be 1. the transactional data mode is selected by default. 26. it loops through all transactional data. And when set to transactional data. When is set to master data. If the condition satisfies. then it directs the record to undergo a calculation. 24. which returns/contains multiple suryapadhi@gmail. *IIF = These syntaxes work. *FOR / *NEXT = This syntax is used with a variable. *BEGIN / *END = These syntaxes are used with Boolean Expressions (YES / NO). ELSEIF. else 0.Syntax 21.suryapadhi. Without an explicit definition.

Variables Variable allows to enter values in runtime. for example $PERCENT$ • Then we define variable for prompt in the data manager package. %YEAR% . %APPSET% .com suryapadhi@gmail.Q1). 1. Mar of 2009 System defined variables are. for example %PERCENT%. In BPC we use two types of variables (1) user defined variables and (2) system variables. If the user enters 2009. In case of user defined variables. • We will have variables in script.Returns current calendar year. For example *XDIM_MEMBERSET TIME = $DIM_INP$ in script logic and a prompt %DIM_INP% in DM package will prompt the user to enter a time dimension member while running that script logic.Returns current Planning and Consolidation User 2. %APPLICATION% .com . %USER% .Returns current Planning and Consolidation AppSet 3. If he/she enters BAS(2009. www.Returns current Planning and Consolidation Application 4. the package will run for Jan. Feb.suryapadhi.JAN. • In run time system will replace $PERCENT$ with values we are passing via %PERCENT%. the package will run only for January 2009.

There are two methods to call the allocation engine: *RUNALLOCATION . In the following example.lgf . FX_Trans.Allocation executes a distribution of values based upon a defined basis. COPYOPENING must be executed with the appropriate Balance Carry Forward business rules. Currency Conversion must be executed with the appropriate Currency Conversion business rules.SAP Delivered Logics Allocation. and then the allocation is called multiple times later in the code by the RUN_ALLOCATION command Calcaccount.suryapadhi.lgf . Copy_Opening.lgf . Consolidation. the allocation called DIST2 is first defined.Consolidation is used to perform legal consolidation and must be executed along with appropriately defined Legal Consolidation Business suryapadhi@gmail.The *RUNALLOCATION format is commonly used when an allocation is to be performed once in the script logic file *RUN_ALLOCATION . This functionality does not require any additional business rules to function.COPYOPENING is used to transfer ending balances from one time period to starting periods in a subsequent time .lgf .Calcaccount is used to prepare Cash Flow and must be executed along with appropriately defined Account Calculation Business Rules.Currency Conversion is used to translate existing records into alternative currency views.lgf . www.The *RUN_ALLOCATION format can be used when an allocation is to be performed multiple times in the same script logic file.

com suryapadhi@gmail.lgf .lgf .ICDATA is used to perform intercompany reconciliation activities. ICElim must be executed with the appropriate ICElim business rules. . www.LGF .ICElim is used to perform intercompany reconciliation.ICBooking is used to perform intercompany reconciliation activities with difference postings. System_Library.The system constants file is the logic file that maps your dimension names for an application to the standard (delivered) BPC logic. For example.SAP Delivered Logics ICDATA.lgf .The System Library includes basic examples of delivered keywords and functions. System_Constants.Validation is used to perform validation activities define within the validation business rules. ICDATA must be executed with the appropriate ICBOOKING business rules.suryapadhi.lgf .The MDXlib file provides examples of pre-delivered MDX financial functions. the file maps the name of the category dimension to the dimension to be used as the category. ICBooking must be executed with the appropriate ICBOOKING business rules.lgf . MDXlib. ICElim.lgf . ICBooking.

com suryapadhi@gmail.Testing and Debugging To test and debug script . we can use program UJK_SCRIPT_LOGIC_TESTER or Transaction Code: UJKT 1 2 3 4 .

model and user 3 4 suryapadhi@gmail.Testing and Debugging 1 2 The SETTING region for the definition of the environment.

1 2 4 3 suryapadhi@gmail. for example: CATEGORY=ACTUAL. Use the format .Testing and Debugging The DATA REGION section allows definition of the initial scope.

3 4 suryapadhi@gmail.Testing and Debugging 1 2 The prototyped script logic code is entered into the lower left hand .suryapadhi.

Testing and Debugging 1 Any errors that are discovered will be presented on the lower right hand . 2 3 4 suryapadhi@gmail.suryapadhi.

Testing and Debugging The script can be executed. The resulting system log will display the compiled code. .com suryapadhi@gmail. the number of records processed and the time to execute. by clicking on the EXECUTE button. and all results saved to the database.

Com • Mail: SuryaPadhi@Gmail.Com. My Publications SAP Press Publications • Explore the Payment Currency Option in Accounts Payable Other White Papers • Lock Box • Credit Card functionality in SAP Contact information: • www.SuryaPadhi.Few of My Contributions. .