Download - 04 - Logics Scripts

Transcript
Page 1: 04 - Logics Scripts

SAP BPC 7.0 NW SPBO TrainingLogic Scripts

Page 2: 04 - Logics Scripts

Introduction to different calculations methods

Page 3: 04 - Logics Scripts

Calculations in BPC

Logic allows you to define formulas that perform calculations on SAP BusinessPlanning and Consolidation members and data.You can have three different type of calculations:

Front-End– Worksheet logic (Excel & VBA)

On-the-Fly– Dimension Member Formulas (MDX)

Stored output– Script logic (SQL or MDX syntax)– Business Rules (Table Driven)– Badi (ABAP)– Allocation Engine

Each type has advantages and disadvantages.You typically use some combination of all four types to achieve the desired results.

Page 4: 04 - Logics Scripts

Logics

Page 5: 04 - Logics Scripts

Worksheet LogicOverview

Uses SAP Business Planning and Consolidation and standard Excelmathematical operators and functions to produce results.Is typically used for simple calculations and events, such as data retrievals(EvGTS), sends (EvSND), and variance calculations (EvBET).Produces calculated values that do not need to be stored in the database.Usage of standard Excel Formulas to perform calculationsCustom VBA code can be triggered for specific events (like refresh, expand,send)Custom VBA coding can also be created for custom selection boxes, validations,allocations, …

Page 6: 04 - Logics Scripts

Worksheet LogicsVBA Events

The following events cab be used to trigger custom VBA coding:

BEFORE_CHANGECVW

AFTER_CHANGECVW

BEFORE_REFRESH

AFTER_REFRESH

BEFORE_SEND

AFTER_SEND

BEFORE_EXPAND

AFTER_EXPANDSample code (need to be created in an “Application Module”)

Function BEFORE_CHANGECVW(Argument As String)

MsgBox Argument

BEFORE_CHANGECVW = True

End Function

Page 7: 04 - Logics Scripts

Worksheet LogicPros and Cons

ProsSpeed - the formulas reside in the worksheet, so calculations are fast and have minimalimpact on performance.Flexibility - you can define many formulas in the worksheet.No server load – worksheet logic uses the client machine to perform calculations, so itallows the server to run more efficiently.

ConsStatic - the formulas are only available in the worksheet in which they are written, and needto be rewritten for each worksheet.Cannot be applied as a process - worksheet formulas cannot be executed via the DataManager (i.e. the calculations are not performed until the sheet is opened and the datarefreshed).Not stored - results are not stored in the database.Risk of incompatibilities between different version of MS ExcelUsage of VBA can cause performance issues in Citrix environmentsUsage of VBA can increase maintenance work on reports / input schedules

Page 8: 04 - Logics Scripts

© SAP 2008 / Page 8

Dimension Member FormulasOverview

Dimension Member Formulas – are on-the-fly calculations defined on dimensionmembers based on other member values.

They are commonly used for calculated key figures, such as costs per unit, percent of sales,growth rates and other ratios.Dimension formulas should only be used for formulas that need to be calculated afteraggregations (e.g. ratios).Dimension formulas should not be used on members that need to aggregate. We recommendthat you use hierarchies, rather than formulas, to define aggregate (or sub-total) dimensionmember levels.Familiarity with the Multidimensional Expressions (MDX) language may be helpful whencreating more complex dimension member formulas.However, fewer MDX keywords are supported in SAP NetWeaver Business Intelligence (BI)than were available in SAP Business Planning and Consolidation 5.x using SQL Server.

Page 9: 04 - Logics Scripts

© SAP 2008 / Page 9

Dimension Member FormulasPrerequisites

In order to use formulas in a dimension you must add a property called 'Formula' to themember sheet using the Manage Dimensions task in the SAP Business Planning andConsolidation Admin module.'Formula' is a user-defined property, so you must define the length of the field. Enter a fieldlength that is greater than 60 characters, and at least equal to the length of the longestexpected formula.

Page 10: 04 - Logics Scripts

© SAP 2008 / Page 10

Dimension Member FormulasMaintaining

Accessed from SAP Business Planning and Consolidation Administration in theDimension Library subdirectory in the hierarchy of a particular Application SetMaintain Dimension Members.

Page 11: 04 - Logics Scripts

© SAP 2008 / Page 11

Dimension Member FormulasSyntax

Except for the Account dimension, the dimension name must always be specified.

Correct formulas:

[ACCOUNT].[Account1] / [ACCOUNT].[Account2]

Or

Account1 / Account2

And

[PRODUCT].[Product1] + [PRODUCT].[Product2]

Or (with use of optional Solve_Order property)

[PRODUCT].[Product1] + [PRODUCT].[Product2];Solve_Order=100

Tip Make sure the dimension and dimension member case are correct!

Page 12: 04 - Logics Scripts

© SAP 2008 / Page 12

Dimension Member FormulasSolve_Order

Use this property to define the order in which calculated members are solved in thecase of intersection with other calculated members. Zero is the highest priority

In the event of a formula collision between the above members, the Account3 formulashould take precedence over the Product3 formula because solve_order = 5 hashigher priority than solve_order = 100.

Page 13: 04 - Logics Scripts

© SAP 2008 / Page 13

Dimension Member FormulasSolve_Order Example

When Solve_Order is not used or is defined incorrectly:

When Solve_Order is used correctly:

24 + 26 = 50 but250 / 10 <> 50Incorrect resultbecause account ratiois calculated prior toand over-ridden by theproduct additionformula.

250 / 10 = 25 but24 + 26 <> 25Correct result becauseaccount ratio iscalculated after theproduct additionformula.

P3=P1+P

2ThenA3=

A1/A2

A3=A1/A2ThenP3=P1+P2

1

2

1

2

Page 14: 04 - Logics Scripts

© SAP 2008 / Page 14

Dimension Member FormulasThe Library File

SAP Business Planning and Consolidation provides a Library File with standard functions thatyou can use in your dimension member formulas.You can include the library file for use in dimension member formulas specified on the Optionssheet of the Account dimension.Then you can define dimension formulas using the standard functions available from the libraryfile.Syntax example:

Page 15: 04 - Logics Scripts

Dimension Member FormulasAssigning the Library File

Assigned from SAP Business Planning and Consolidation Administration in theDimension Library subdirectory in the hierarchy of a particular Application SetMaintain Dimension Members.

Optionstab

© SAP 2008 / Page 15

Page 16: 04 - Logics Scripts

© SAP 2008 / Page 16

Dimension Member FormulasFunctions in the Library File

The following standard functions are available in SAP Business Planning andConsolidation:

Basic Financial Formulas – Account Average and Growth Rate.Liquidity Analysis Ratios – Current Ratio, Quick Ratio, Networking Capital Ratio.

The following SAP Business Planning and Consolidation 5.x standard functions arenot included in SAP Business Planning and Consolidation 7.0, version for SAPNetWeaver:

Profitability Ratios – Return on Assets, Return on Equity, Return on Common Equity, Cost ofGoods Sold to Sales, Net Profit Margin, Gross Profit Margin, SG&A to Sales Ratio.Efficiency Analysis Ratios – Asset Turnover Ratio, A/R Turnover Ratio, Average CollectionPeriod, A/P Turnover Ratio, Inventory Turnover Ratio, Average Age of Inventory, Sales to TotalAssets Ratio, Days in Receivables, Days in Payables, Days in Inventory.Capital Structure Analysis Ratios – Debt Ratio, Debt to Equity Ratio, Interest Coverage Ratio,Debt Coverage Ratio.Capital Market Analysis Ratios – Earnings per Share, Price Earnings Ratio, Book Value perShare, Market to Book Ratio, Dividend Yield, Dividend Payout.

Page 17: 04 - Logics Scripts

Dimension Member FormulasPro and Cons

ProConsistency - the same logic is applied to all members in all applications that use thedimension.

ConsLack of flexibility - dimension logic applies to all levels in the dimension and in allapplications using the dimension.If you want to apply a formula only to base level members or want a formula to be used inonly one application you should use advanced logic.Creates load on the server.

Page 18: 04 - Logics Scripts

© SAP 2008 / Page 18

Script LogicOverview

Script Logic – enables calculations on base-level cells that result in data stored withinan application. The results are aggregated up the dimensional hierarchy intact,without being re-calculated at upper levels.

Some example of when to use a Script Logic formulas are: unit times pricecalculations, foreign currency translation, allocations, and others.

Script logic can be run in any of three ways:Automatically after data is sent to the database from BPC for Excel using the Default.lgffile.After Journal data sends using either Default.lgf, or if present, Journal.lgf files.From Data Manager as a batch processing event to call Script Logic formulas.

Page 19: 04 - Logics Scripts

Script LogicHow it works

The Logic module:Reads a specific data selection from the application.Applies to it a set of user-defined formulas (stored in a logic file).Derives the values.Writes those values back to the application.

Results are written directly to the application as base data, and are aggregated upthe dimensional hierarchy as they are, without being recalculated at upper levels.

All dimension logic formulas are applied to these results.This process allows you to perform such calculations as units times price because theformulas are applied only to those members specified in the logic file.

Page 20: 04 - Logics Scripts

ScopeHow it works (cont’d)

Application

Source Data

Destination Data

Calculation Output

Delta

-

=

Calculations

Page 21: 04 - Logics Scripts

© SAP 2008 / Page 21

Script LogicMaintaining

Accessed from SAP Business Planning and Consolidation Administration in the ScriptLogic subdirectory in the hierarchy of a particular Application.

Page 22: 04 - Logics Scripts

© SAP 2008 / Page 22

Script LogicLogic Files

Default Logic gets executed on every write-back to an application.

Use the *INCLUDE command to have one logic file call another logic file.

Page 23: 04 - Logics Scripts

© SAP 2008 / Page 23

Script LogicScript Logic Tester

Program UJK_SCRIPT_LOGIC_TESTER can be used to test and debug script logic.

Page 24: 04 - Logics Scripts

Creating a new logic script - Steps

Creating a new logic scripts involves the following 5 steps:Creating the logic script file (Admin Console)Compile the logic script (Admin Console)Create a Process Chain (Netweaver BI)Add the newly created package to the user interface (BPC for Excel)Set the run-time parameters of the Package (BPC for Excel), like the user prompt orthe logic file that will be executed.

Page 25: 04 - Logics Scripts

© SAP 2008 / Page 25

Script LogicStructure

Script Logic can be broken down into 3 components:Scoping- What am I running the data on?

Data manager scopingInput schedule scopingScope control

Body/Code – What do I want to do with the scoped records?*IIf Statements*REC[#] based MDX statements*WHEN / *IS/ *ENDWHENAllocation Logic

Writing the record*Commit

Page 26: 04 - Logics Scripts

© SAP 2008 / Page 26

Script LogicThe Library File

SAP Business Planning and Consolidation provides a Library File with standardfunctions that you can use in your own Script Logic formulas.

ApShell includes the default System_library.lgf which stores a library of standardfunctions.

Can be called by using the INCLUDE function in your logic file.The Logic module scans the library file for the appropriate formulas to use basedon the information in the LGF file.

Page 27: 04 - Logics Scripts

Script LogicCalculationsThere are two main ways to perform: A + B = CMDX Syntax:

[ACCOUNT].[#C] = [ACCOUNT]. [A] + [ACCOUNT]. [B]– The calculated member is prefixed with a ‘#’

SQL Syntax :*WHEN ACCOUNT*IS “A”,”B”

*REC(ACCOUNT=“C”)*ENDWHEN– The calculated member is specified in the *REC()

The MDX syntax is straight forward, but may incur a performance penalty.

The SQL syntax is only executed for the records where valuey do exists, thisimproves the performance but makes the writing of the logic less intuitive

Page 28: 04 - Logics Scripts

Script LogicScope Source

Definition of the execution scope :Data Send (Default logic script)

Scope is derived by the sent data, A list of all the unique members in the sent datais used to derive the scope.Scope can be overridden / modified / filtered with the *XDIM keywords

Running a Data Manager PackageScope is derived from the User Prompt for the dimensions that are part of theprompt. All non-calculated members are selected for the other dimensions.Scope can be overridden / modified / filtered with the *XDIM keywords

In the MDX mode, the execution scope represents the data region wherecalculations result should be posted.In the SQL mode, the execution scope represents the data region where thesource data are.

Page 29: 04 - Logics Scripts

Script LogicScope Source – Keywords

The following 3 keywords can be used to modify the scope:

*XDIM_MEMBERSETOverwrites the scope for that dimension

*XDIM_ADDMEMBERSETAdd members to the scope of that dimension

*XDIM_FILTERFilters the members of the scope of that dimension

*XDIM_MAXMEMBERSSpecifies the maximum number of members that should be included in one query (per

dimension)

*SELECTAssigns a list of members to a memory variable

Page 30: 04 - Logics Scripts

Script Logic*XDIM_MEMBERSET

*XDIM_MEMBERSET Category = PLAN*XDIM_MEMBERSET Entity = C3000*XDIM_MEMBERSET P_DataSrc = MANUAL*XDIM_MEMBERSET RptCurrency = LC*XDIM_MEMBERSET P_Activity = EMPL1*XDIM_MEMBERSET P_ACCT = CE0004220

*XDIM_MEMBERSET TIME = BAS(2007.TOTAL)//*XDIM_MEMBERSET TIME = DEP(2007.Q3)//*XDIM_MEMBERSET TIME = ALL(2007.TOTAL)

*WHEN P_ACCT*IS CE0004220*REC (EXPRESSION = 907)*ENDWHEN*COMMIT

Variant on XDIM_MEMBERSET*XDIM_MEMBERSET {Dimension name} = BAS{Members Set}*XDIM_MEMBERSET {Dimension name} = DEP{Members Set}*XDIM_MEMBERSET {Dimension name} = ALL{Members Set}

Example:*XDIM_MEMBERSET TIME = BAS(2007.TOTAL)Selects all base level members of the 2007.TOTAL parent node

Additional observation from JeffH -*XDIM_MEMBERSET TIME = <ALL> does NOTwork!

Page 31: 04 - Logics Scripts

Script Logic*XDIM_ADDMEMBERSET

*XDIM_MEMBERSET Category = PLAN*XDIM_MEMBERSET Entity = C3000*XDIM_MEMBERSET P_DataSrc = MANUAL*XDIM_MEMBERSET RptCurrency = LC*XDIM_MEMBERSET P_Activity = EMPL1*XDIM_MEMBERSET P_ACCT = CE0004220*XDIM_MEMBERSET TIME = 2007.JAN*XDIM_ADDMEMBERSET TIME = 2007.FEB

*WHEN P_ACCT*IS CE0004220*REC (EXPRESSION = 901)*ENDWHEN*COMMIT

Adds to Member Selection*XDIM_ADDMEMBERSET {dimension} = {members set}

Example:

User sends data only on Entity1 and the default logic contains:

*XDIM_ADDMEMBERSET ENTITY=Entity2

…Logic will be executed for Entity1 AND Entity2.

Page 32: 04 - Logics Scripts

Script Logic*XDIM_FILTER

*XDIM_FILTERThis instruction does not replace the scope, but filters the existing scope.

Syntax*XDIM_FILTER {Dimension name} = {Members Set}

ExampleIf the scope is France, Italy, USA, the instruction:

*XDIM_FILTER ENTITY= [ENTITY].Properties(“EUROPE”)=”Y”…would limit the scope to the European Entities : France and Italy

Page 33: 04 - Logics Scripts

Script Logic*XDIM_MAXMEMBERS

*XDIM_MEMBERSET Category = PLAN*XDIM_MEMBERSET Entity = C3000*XDIM_MEMBERSET P_DataSrc = MANUAL*XDIM_MEMBERSET RptCurrency = LC*XDIM_MEMBERSET P_Activity = EMPL1*XDIM_MEMBERSET P_ACCT = CE0004220//*XDIM_MEMBERSET TIME = 2007.JAN

*XDIM_MAXMEMBERS TIME = 4// this forces the system to process the//total number of records in//smaller groups, in this case groups of four,//rather than one big group

*WHEN P_ACCT*IS CE0004220*REC (EXPRESSION = 901)*ENDWHEN

*COMMIT

Limits the maximum number of members in a query*XDIM_MAXMEMBERS {dimension}= {max number of members}*XDIM_MAXMEMBERS Entity = 50

Above instruction, if entities to process exceed the limitof 50 members, the logicwill break the query into multiple queries of no morethan 50 entities each.

PREFORMANCE RELATED

Additional observations• Significant performance enhancement

by entering a large value forXDIM_MAXMEMBERS observed.

• ENITITY is automatically defaulted toXDIM_MAXMEMBERS ENTITY =1

• May want keep defaultXDIM_MAXMEMBERS ENTITY =1when considering financial systemimplications.

Page 34: 04 - Logics Scripts

Script Logic*SELECT

*XDIM_MEMBERSET Category = PLAN*XDIM_MEMBERSET P_DataSrc = MANUAL*XDIM_MEMBERSET RptCurrency = LC*XDIM_MEMBERSET P_Activity = EMPL1

*SELECT(%ENTSet%, "[ID]", ENTITY, "[INTCO] ='I_C3000' ")*XDIM_MEMBERSET Entity = %ENTSet%

*SELECT(%ACCSet%, "[ID]", P_ACCT, "[CALC]='N'")*XDIM_MEMBERSET P_ACCT = %ACCSet%

*WHEN P_ACCT*IS CE0004210*REC (EXPRESSION = 10)*IS CE0004220*REC (EXPRESSION = 20)*IS CE0004230*REC (EXPRESSION = 30)*ENDWHEN

*COMMIT

Dynamic Member Selection

*SELECT ({variable}, {What}, {From}, {Condition})

*SELECT(%ENTSet%, "[ID]", ENTITY, "[INTCO] ='I_C3000' ")

Page 35: 04 - Logics Scripts

Script Logic*SELECTCASE *CASE

*XDIM_MEMBERSET Category = PLAN*XDIM_MEMBERSET Entity = C3000*XDIM_MEMBERSET P_DataSrc = MANUAL*XDIM_MEMBERSET RptCurrency = LC*XDIM_MEMBERSET P_Activity = EMPL1*XDIM_MEMBERSET P_ACCT = CE0004220*XDIM_MEMBERSET TIME = 2007.JAN

*SELECTCASE [P_acct].[CE0004210]*CASE 5002[#CE0004220] = 9011

*CASEELSE[#CE0004230] = 9022

*ENDSELECT

*COMMIT

*SELECTCASE is a syntax friendly conditional statement similarto the IF>>Then>>Else statements used in otherapplications.

In this example: look at the record if the account is CE0004210,if the value of that record is 5002, then create a new recordswith account CE0004220 with a value of 9011, if the value ofthe record is NOT 5002, then create an alternative recordwith account CE0004230 with a value of 9022.

SELECTCASE does NOT allow nesting.

Page 36: 04 - Logics Scripts

Script LogicCalculations - *REC

The *REC instruction is used to generate a new database.

The *REC statement has two type of parameters:

Calculation on the current value of the record (Using the keywords “EXPRESSION” and“FACTOR”

Overwriting the members where the records should be generated (you usually do not want tooverwrite your source record with the result, but write that result back to another member)

Example:

The following syntax multiplies the value of the record by 2 and writes-it back to the categorybudget

*REC(FACTOR=2,CATEGORY=“BUDGET”)

The *REC statement can only be used within an *WHEN / *ENDWHEN structure

Page 37: 04 - Logics Scripts

Script LogicCalculations - *REC Factor / Expression

The amount to be posted on the new record can be derived from the existing valueusing ‘Factor’ and ‘Expression’ key words

The ‘Factor’ key word multiplies the existing value by the specified factorThe ‘Expression’ key word allows the input of a formula (can contain arithmetical operators,like ‘+’,’-’,’*’,’/’, fixed values of the value of the source value (%value%)A value from another account can be used with MDX Syntax, for example:

EXPRESSION=%VALUE%/[P_ACCT].[CE0004020]EXPRESSION=%VALUE%/([P_ACCT].[CE0652000],[P_ACTIVITY].[LABPRD])

[FACTOR | EXPRESSION = {Expression}]

Example*REC(FACTOR=1/2)… Current value is multiplied by 0.5*REC(EXPRESSION=%VALUE% + 500)… Adds 500 to the existing value

Page 38: 04 - Logics Scripts

Script LogicCalculations - *WHEN / *IS

The keywords *WHEN and *IS are used to filter the records that get processed

*WHEN Dimension*IS “Value”,”Value2”

*REC(…)*ELSE

*REC(…)*ENDWHEN

A *When / *Endwhen structure can contain several *IS statements and one *ELSEstatement

The *When keyword can use any property of a dimension, for example“Entity.Currency”. The ”*IS” keword can then filter on the values of that property

Page 39: 04 - Logics Scripts

Script LogicCalculations - *WHEN / *ENDWHEN Example

This example copies the values of the account sales from the category “Actual” to“Budget” and multiply the values by 2

*WHEN Category*IS “Actual”

*WHEN Account*IS “Sales”

*REC(FACTOR = 2, Category=“Budget”)*ENDWHEN

*ENDWHEN

Page 40: 04 - Logics Scripts

Script LogicCalculations - Lookup values

For the “EXPRESSION” and “FACTOR” parameter, values of other members canalso be used with the following two statements:

*LOOKUPPossibility to Lookup data in another application (for example for Currency ExchangeRates)All values that are defined in the *LOOKUP are queried at the beginning of the logicexecution and are then available throughout the logic execution

*GETRetrieves a value from memory, the value that is retrieved need to be part of the scope (noadditional query is required to read the lookup values)Only value from the same application can be retrieved

Page 41: 04 - Logics Scripts

Script LogicCalculations - *LOOKUP

*LOOKUP/*ENDLOOKUP*Lookup/*EndLookup - This set of instructions can be used in conjunction with a WHEN/ENDWHENstructure to retrieve (“lookup”) some other values that may be needed either in the calculation of the newvalue or to define some criteria to be evaluated.A relationship is defined between the current record being processed and the record to lookupCan be used in Factor\Expression or *WHENCan lookup values in current application or different application in the same application set

Syntax*LOOKUP {App}

*DIM [{Lookup ID}:] {Dimension Name}=“Value”| {Calling Dimension Name} [. {Property}]

[*DIM….]*ENDLOOKUP

*Where:{App} is the name of the application from which the amounts are searched{DimensionName} is a dimension in the lookup app{CallingDimensionName} is a dimension in the current application{LookupID} is an optional identifier of the “looked-up” amount. This is only required whenmultiple values must be retrieved.

Page 42: 04 - Logics Scripts

Script LogicCalculations - *LOOKUP Example

Consider the currency calculation Value * Rate, where value is in the primaryapplication and rate is in the supporting rate application

*LOOKUP RATE*DIM RATESRC="RATECALC"*DIM RATE=ACCOUNT.RATETYPE*DIM SOURCECURR:INPUTCURRENCY=ENTITY.CURRENCY*DIM USD:INPUTCURRENCY="USD"*DIM EURO:INPUTCURRENCY="EURO"

*ENDLOOKUP

Page 43: 04 - Logics Scripts

Script LogicCalculations - Multi Application Logic

LOOKUP was used to read from another application previously. There is also astatement to write-back the result of a calculation to another application.

*Destination_app = <<application name >>

The desination application needs to have the same structure than the sourceapplication, the keywords *Skip_dim, *Add_dim and *Rename_dim are notsupported

Page 44: 04 - Logics Scripts

Script LogicWrite-back – Overview

Once calculation have been performed, the results need to be sent back (orcommitted) to the database.

This operation is very resource intensive and should be limited to minimum number ofcommits.

The records are not written back directly to the write-back fact table, but are postedthrough the send governor. Depending on the send governor settings, a logic withseveral commit sections may take a long time to execute.

To avoid multiple write-backs, some calculations need to be rewritten to avoiddependency on other calculated accounts

Page 45: 04 - Logics Scripts

Script LogicWrite-back - *COMMIT

A « Commit » send the data back to the databaseA « Commit » may be required when there are several sections in a logic file and the secondsection need the output of the first section as inputA « Commit » may also be required when the scope is different for different sectionsThe number of « Commit » should be limited to a minimum, as this instruction has an importantperformance impact

SyntaxThere are a variety of commit instructions that can be used:*COMMIT

*COMMIT_EACH_MEMBER={dimname}

*COMMIT_EACH_LEVEL={dimname}

The behavior of the XDIM_MAXMEMBERS option for SQL logic is that the process will committhe generated result as they are generated by each single query.

When XDIM_MAXMEMBERS is used in MDX type logics, the logic query is broken in as manyqueries as required. However all resulting records are committed to the database in one lumpat the end of the loop of queries.

It may be preferable to perform a commit to the database after each individual query. This can beaccomplished inserting the instruction:

*COMMIT_MAXMEMBERS

Page 46: 04 - Logics Scripts

Script LogicExecution

Advanced logic can be automatically invoked each time data is sent to thedatabase.

Logic contained in the Default logic file is executed immediately after data is sent andthe results can be seen in SAP Business Planning and Consolidation right away.

Advanced logic can be run from Data Manager for batch processing of formulas.Using Data Manager to execute Logic module formulas is useful for calculations that donot need to be executed immediately.For example, an administrator may decide to wait until all the data has been entered inthe local currency before generating the translated amounts in the reporting currencies.

Page 47: 04 - Logics Scripts

Script LogicData Manager Package

These packages are executed on demand by the users and they will usually requiresome additional input by the users (like the period or the file they want to import).

The logic file cannot be executed by itself, it requires a Process Chain (Netweaver BIProcess Chain, transaction “RSPC”) to be setup first, that Process Chain containsa component that will then call a logic file. Each logic file can have it’s own ProcessChain or a generic Process Chain can be created, where the “Logic Script” nameis passed as parameter

Page 48: 04 - Logics Scripts

Script LogicDeltas with BPC Microsoft Release

In SQL Logic, the values are not cumulated between different *IS sections, like inthe following example:*WHEN ACCOUNT*IS “ACC1”

*REC(ACCOUNT=“ACC3”)*IS “ACC2”

*REC(ACCOUNT=“ACC3”)*ENDWHENACC3 will only contain the value of Account “ACC1” or “ACC2”.

Page 49: 04 - Logics Scripts

Script LogicPros and Cons

ProsReal-time - allows for real-time calculations.Flexible - enables you to apply different formulas to different applications within anapplication set (dimension logic is applied to all applications using the dimension).Syntax options - you can use SQL or MDX syntax.

Page 50: 04 - Logics Scripts

Account Transformation Business RulesOverview

The account transformation function is designed to:Read the values posted under specific combinations of accounts, flow types anddata sourcesAggregate these valuesPost the aggregated amount under an alternate destination account, flow and datasource combination.

Options need to exist to allow for inversion of the sign on posting of the calculated amounts(change debit to credit and vice versa), to use reference data in other periods and years todetermine the amount to be posted and to support YTD calculations in Period basedapplications.The values to be read, the posting rules and the sign determination are all defined in thebusiness rule tables for “Account Transformation”.The Account Transformation function can be utilized in either a Financial or a legalconsolidation application.An example of where this would be used would be to calculate and store amounts which arerequired for purposes of performing Cash Flow reporting.

Page 51: 04 - Logics Scripts

Account Transformations Business RulesSyntax

How does the Account Transformation calculation work?These calculations can only use the following 4 dimensions:– Account– Flow– Datasrc– TimeThe instructions *RUN_PROGRAM is used to execute the calculations defined in theAccount Transformation Business Rules tables*RUN_PROGRAM CALC_ACCOUNT

CATEGORY = %CATEGORY_SET%GROUPS = %RPTCURRENCY_SET%TID_RA = %TIME_SET%CALC=CALC1OTHER = [ENTITY=%ENTITY_SET%]

*ENDRUN_PROGRAMThe parameter “CALC” defines which “Calculation Group” should be run. Alldimension names specified between percentages should be replaced with thedimension names used in the current application

Page 52: 04 - Logics Scripts

Account Transformations Business RulesTable settings

Supporting fields in the Account Transformation Business Rule TableTransformation Group: ID to group the calculationsSource Account: valid member (base or parent) or a list defined with a DIMLISTproperty (Accountl)Source Flow: valid member (base or parent) or a list defined with a DIMLIST property(Flow)Source Category: valid member (base or parent) or a list defined with a DIMLISTproperty (Category)Source Datasrc: blank, valid member (base or parent) or a list defined with a DIMLISTproperty (Datasrc)Destination Account: blank (same as source member) or base member (Accountl)Destination Category: blank (same as source member) or base member (Accountl)Destination Flow: blank (same as source member) or base member (Flow)Destination Datasrc: blank (same as source member) or base member (Datasrc)Reverse Sign: blank or “Y”Source Year: blank, absolute value (2006, 2007) or relative value (+1, -2)Source Period: blank, absolute value (JAN, FEB) or relative value (+1, -2)Apply to YTD: blank or “Y”. In a periodic application, this field can be set to « Y » toapply calculation on the YTD value

Page 53: 04 - Logics Scripts

Account Transformation Business RulesExample

The following example shows the “Account Transformation” table that would be usedto copy the Account “CE0004220” to the Account “CE0004530”, keeping the samecategory, flows and data source

Page 54: 04 - Logics Scripts

Allocation EngineOverview

Usage:*RUNALLOCATION*FACTOR={expression}*DIM {dim name} WHAT={set}; WHERE={set}; [USING ={set};] [TOTAL={set}]*DIM …*ENDALLOCATION

DescriptionWithin SAP Business Planning and Consolidation 5.x, this was run as a stored procedure.Within SAP Business Planning and Consolidation 7.0, version for SAP NetWeaver, this isnatively a Script Logic Keyword.An allocation method to allocate a value to a number of target member using referencevalues or percentageRather than writing custom script logic, the allocation engine was designed to simplifyallocations and is a best practice methodology.The allocation engine is referenced in a script logic package, but uses a table basedapproach.

© SAP 2008 / Page 54

Page 55: 04 - Logics Scripts

© SAP 2008 / Page 55

Allocation EngineDefinition

Allocation Engine Table Components*RunAllocation initiates the allocationDimensions to include in the allocation

*DIM AccountDimensions not defined in the allocation will default to scoping.

What – Base member to be allocatedsupports multiple members WHERE=AccountA,AccountB

Where – Destination members where the allocation will be writtensupports WHERE=BAS(ParentHX) syntax to define all base level members of a parent.supports use of properties WHERE=[STATUS]="FT" AND [EMP_CLASS]="Existing

Using – (Optional) member storing an allocation factor, “the amount of the driver.”Total – (Optional) Sum of the driver or Using amounts. Very useful when calculating a percentageUsing/TotalFactor (Optional)

Omitted - factor will always default to 1, Using and Total columns are ignoredNumerical values such as 2 – What x 2Using – What is multiplied by Using. Total column is ignored.Using/Total – What is multiplied by Using/Total1/COUNT – Divided evenly among 1/count of where members

Page 56: 04 - Logics Scripts

© SAP 2008 / Page 56

Allocation EngineExample

Example:The account RENT in entered in entity GLOBALOPS, inter-company NON_INTERCO. Thisamount must be allocated using a percentage of allocation that is entered by the user inaccount PERCENT in the appropriate entities and for the desired members of theCATEGORY, TIME, DATASRC and RPTCURRENCY dimensions. This allocationdemonstrates the following features:

It uses the {dimensiontype}DIM keyword to identify the dimensions by typeIt uses the “<<<” and “>>>” keywords to reference the definitions used to the left or tothe rightIt uses the “<>” operand to reference all members not equal to a given one

Page 57: 04 - Logics Scripts

© SAP 2008 / Page 57

Allocation EngineExample (cont’d)

Below is the corresponding script:*RUNALLOCATION*FACTOR=USING/100*DIM ACCOUNTDIM WHAT=RENT; WHERE=<<<; USING=PERCENT*DIM ENTITYDIM WHAT=GLOBALOPS; WHERE=>>>; USING<>GLOBALOPS*DIM INTCODIM WHAT=NON_INTERCO; WHERE=<<<; USING=<<<*ENDALLOCATION

Page 58: 04 - Logics Scripts

Badi

Page 59: 04 - Logics Scripts

1. Call Custom Logic• Where am I ….main views in BPC NW• Custom Logic Overview• Create Custom Logic for Input Schedule• Create Custom Logic for Data Package• Debugging Custom Logic

Agenda

Page 60: 04 - Logics Scripts

BPC (.Net Installation)

Admin Workbench

Modeling (RSA1)Info ProviderInfo Objects …Business ContentMeta Data Rep. …

Administration- Process Chain (RSPC)- BPC: File Service

User Interface (UJFS)…

BI (ABAP Installation)

Development- Dev. Workbench (SE80)- BADI (SE19)- SAP Table (SE16)- Programms (SE38)…

AuthorizationUser Maintanance (SU01),Role Maintanance (PFCG),Management of Analysis Authorizations (RSECADMIN)

ReportingInput SchedulingData Mangement…

Data ModelingMaintain Master DataScript LogicUser Management…

ReportingInput SchedulingData Mangement…

Data ModelingMaintain Master DataScript LogicUser Management…

Data ModelingMaintain Master DataScript LogicUser Management…

ReportingInput SchedulingData Mangement…

Data ModelingMaintain Master DataScript LogicUser Management…

ReportingInput SchedulingData Mangement…

Data ModelingMaintain Master DataScript LogicUser Management…

ReportingInput SchedulingData Mangement…

Data ModelingMaintain Master DataScript LogicUser Management…

ReportingInput SchedulingData Mangement…

ReportingInput SchedulingData Mangement…

ReportingInput SchedulingData Mangement…

Data ModelingMaintain Master DataScript LogicUser Management…

Data ModelingMaintain Master DataScript LogicUser Management…

Where am I… main view in BPC NW

Page 61: 04 - Logics Scripts

© SAP 2008 / Page 61

Custom Logic Overview

To create a new function, create a Business Add-in (BADI) Implementation ofUJ_CUSTOM_LOGIC (SE18).

If the BADI has a filter, then in script logic the customer need to provide the a filter value.Note: To pass parameters to the BADI, you can use Data Manager prompts and read thevalues of these parameters within your call custom logic code.

For instructions about implementing an SAP Business Add-In, see the ABAPonline help at:http://help.sap.com/saphelp_nw70/helpdata/en/32/a83942424dac04e10000000a1550b0/cont

ent.htm.

For instructions on how to pass parameters to Custom Logic BADI using START_BADIhttps://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f4252d-98ca-2b10-e689-f85085ae2d12

© SAP 2008 / Page 61

Page 62: 04 - Logics Scripts

Custom Logic Overview

External Breakpoint,Maintain Debugging User

BADI, Scipt, Input Schedule

Input Schedule and Default Logic

Custom Logic in Input ScheduleDecision Points: Custom Logic in Data PackageData Selection Query and Scipt Logic

Modeling BADI, Process Chain, Script, DataPackage

DebuggingExternal Breakpoint,Maintain Debugging User,Save “SYNCHRONOUS.run” File

You can use Custom Logic in two different ways,find below a short summary:

Page 63: 04 - Logics Scripts

BWDeveloper

BWDeveloper

BADIBADIBADIBADI

Custom Logic inABAP

Custom Logic inABAP

BPC AdminBPC Admin

Backend ApplicationBackend Application

BPC ExcelBPC Excel

Data InputLayout

ScriptLogicScriptLogic

1. Create BADI1. Create BADI

2. Create Script Logic2. Create Script Logic

3. Create Data Input Layout3. Create Data Input Layout

4. Save aktive Workbook4. Save aktive Workbook

CallBADICall

BADISave aktiveWorkbook 1. A) Define ABAP Code1. A) Define ABAP Code

1. B) Define Filter Value1. B) Define Filter Value

2. A) Call BADI in Scipt Logic2. A) Call BADI in Scipt Logic

Create Custom Logic for InputSchedule

Page 64: 04 - Logics Scripts

BWDeveloper

BWDeveloper

BADIBADIBADIBADI

Custom Logic inABAP

Custom Logic inABAP

BWAdminWorkbench

BWAdminWorkbench

Process ChainProcess ChainProcess ChainProcess Chain

BPC AdminBPC Admin

Backend ApplicationBackend Application

BPC ExcelBPC Excel

Data PackageScriptLogicScriptLogic

1. Create BADI1. Create BADI

2. Create Process Chain2. Create Process Chain

3. Create Script Logic3. Create Script Logic

4. Create Data ManagementPackage

4. Create Data ManagementPackage

5. Call Data Package5. Call Data Package

CallBADICall

BADI

CallProcess Chainwith ScriptLogic

Customizing viaDrag & DropCustomizing viaDrag & Drop

1. A) Define ABAP Code1. A) Define ABAP Code

1. B) Define Filter Value1. B) Define Filter Value

2. A) Create Start Process2. A) Create Start Process

2. B) BPC Modify Dynamically2. B) BPC Modify Dynamically

2. C) BPC Run Logic2. C) BPC Run Logic

2. D) or Process2. D) or Process

2. E) BPC Clear BPC Tables2. E) BPC Clear BPC Tables

3. A) Call BADI in Scipt Logic3. A) Call BADI in Scipt Logic

Create Custom Logic for DataPackage

Page 65: 04 - Logics Scripts

Debugging Customer Logic

1. Maintain Debugging User on BPC Server Manager

2. Set External Debug User in your Coding

3. Only for Data Package:

Create File „SYNCHRONOUS.run” with Content Y

(direct under C:\ on you Client PC)

Page 66: 04 - Logics Scripts

Lessons learned

Page 67: 04 - Logics Scripts

Lessons Learned

Script Logic has still a few functional gaps with the Microsoft Release, but iscatching up quickly (lots of features were delivered in SP01 and SP02)

Performance of Dimension Member Formulas (MDX) is rather poor, should beavoided whenever possible

Limit the number of *COMMIT

Limit the scope of your calculations

Limit the content of your Default logic file

Page 68: 04 - Logics Scripts

© SAP 2008 / Page 68

Thank you!

© SAP 2008 / Page 68

Page 69: 04 - Logics Scripts

© SAP 2008 / Page 69

Copyright 2008 SAP AGAll rights reserved

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changedwithout prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

SAP, R/3, xApps, xApp, SAP NetWeaver, Duet, SAP Business ByDesign, ByDesign, PartnerEdge and other SAP products and services mentioned herein as well as their respective logos aretrademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned and associated logos displayedare the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

The information in this document is proprietary to SAP. This document is a preliminary version and not subject to your license agreement or any other agreement with SAP. This documentcontains 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 assumes no responsibility for errors or omissions in this document. SAP does not warrant the accuracy or completeness of the information, text, graphics, links, orother items contained within this material. This document is provided without a warranty of any kind, either express or implied, including but not limited to the implied warranties ofmerchantability, fitness for a particular purpose, or non-infringement.

SAP shall 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. This limitationshall not apply in cases of intent or gross negligence.

The statutory liability for personal injury and defective products is not affected. SAP has no control over the information that you may access through the use of hot links contained in thesematerials and does not endorse your use of third-party Web pages nor provide any warranty whatsoever relating to third-party Web pages

Weitergabe und Vervielfältigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne die ausdrückliche schriftliche Genehmigung durchSAP AG nicht gestattet. In dieser Publikation enthaltene Informationen können ohne vorherige Ankündigung geändert werden.

Einige von der SAP AG und deren Vertriebspartnern vertriebene Softwareprodukte können Softwarekomponenten umfassen, die Eigentum anderer Softwarehersteller sind.

SAP, R/3, xApps, xApp, SAP NetWeaver, Duet, SAP Business ByDesign, ByDesign, PartnerEdge und andere in diesem Dokument erwähnte SAP-Produkte und Services sowie diedazugehörigen Logos sind Marken oder eingetragene Marken der SAP AG in Deutschland und in mehreren anderen Ländern weltweit. Alle anderen in diesem Dokument erwähnten Namenvon Produkten und Services sowie die damit verbundenen Firmenlogos sind Marken der jeweiligen Unternehmen. Die Angaben im Text sind unverbindlich und dienen lediglich zuInformationszwecken. Produkte können länderspezifische Unterschiede aufweisen.

Die in diesem Dokument enthaltenen Informationen sind Eigentum von SAP. Dieses Dokument ist eine Vorabversion und unterliegt nicht Ihrer Lizenzvereinbarung oder einer anderenVereinbarung mit SAP. Dieses Dokument enthält nur vorgesehene Strategien, Entwicklungen und Funktionen des SAP®-Produkts und ist für SAP nicht bindend, einen bestimmtenGeschäftsweg, eine Produktstrategie bzw. -entwicklung einzuschlagen. SAP übernimmt keine Verantwortung für Fehler oder Auslassungen in diesen Materialien. SAP garantiert nicht dieRichtigkeit oder Vollständigkeit der Informationen, Texte, Grafiken, Links oder anderer in diesen Materialien enthaltenen Elemente. Diese Publikation wird ohne jegliche Gewähr, wederausdrücklich noch stillschweigend, bereitgestellt. Dies gilt u. a., aber nicht ausschließlich, hinsichtlich der Gewährleistung der Marktgängigkeit und der Eignung für einen bestimmten Zwecksowie für die Gewährleistung der Nichtverletzung geltenden Rechts.

SAP übernimmt keine Haftung für Schäden jeglicher Art, einschließlich und ohne Einschränkung für direkte, spezielle, indirekte oder Folgeschäden im Zusammenhang mit der Verwendungdieser Unterlagen. Diese Einschränkung gilt nicht bei Vorsatz oder grober Fahrlässigkeit.

Die gesetzliche Haftung bei Personenschäden oder die Produkthaftung bleibt unberührt. Die Informationen, auf die Sie möglicherweise über die in diesem Material enthaltenen Hotlinkszugreifen, unterliegen nicht dem Einfluss von SAP, und SAP unterstützt nicht die Nutzung von Internetseiten Dritter durch Sie und gibt keinerlei Gewährleistungen oder Zusagen überInternetseiten Dritter ab.

Alle Rechte vorbehalten.


Top Related