Académique Documents
Professionnel Documents
Culture Documents
Marc F. Bernard
Platinum Consultant SAP NetWeaver RIG Americas SAP Labs, LLC
Learning Objectives
Determine the correct design for a planning function Understand how BPS formulas work Design formulas the right way Resolve performance problems or avoid them in the first place
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 2
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 3
Before
After
Field(s) to be changed
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 4
Number of calls/records 4 calls, one record per call 2 calls, records (1+2) and (3+4) 2 calls, records (1+3) and (2+4) 1 call, all records
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 5
Start of Execution Data Selection Build Subsets from Selected Data Phase 1 Reference Data Initialize Function (Add Subsets) FOREACH Subset. Phase 2 Execute Function ENDFOR. End of Execution
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 6
Copy
Delete
Delete Based on Values Delete Invalid Combinations
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 7
Predefined Functions
Formulas (FOX)
Exits
Complexity, Functionality
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 8
There is no predefined planning function that does the job. The task cannot be done in one standard planning function but several planning functions/sequence are needed. The customizing of a standard planning function becomes to complicated.
Performance: Most of the time it is faster to have one fox formula doing the job than a number of planning functions.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 9
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 10
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 11
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 12
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 13
Example 2: For each product copy data from the current year (2005) to the next year (2006)
Field(s) to be changed: Fiscal Year Formula: {2006} = {2005}. Note: You do not have to care about the product because of the subsets ("automatic FOREACH")!
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 14
Using Planning Area Variables: DATA LocalVariable TYPE InfoObject. LocalVariable = VARV('name of global variable'). Conditional Statements IF ELSEIF ENDIF.
IF ELSE ENDIF.
ELSE if no condition mentioned before works
FOREACH ENDFOR.
Ending, if last selected characteristic value or key figure is reached
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 15
The values for YEAR are taken from the records in the selection of the planning package. Assume we have data records for year 2005 and 2006.
First loop: YEAR is replaced with 2005, system calculates {2005} = {2004} * 1.05. Second loop: YEAR is replaced with 2006, system calculates {2006} = {2004} * 1.05.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 16
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 17
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 18
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 19
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 20
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 21
Real-world Example
Fields to be changed:
Parameter group:
* Cash Discount = (Base Revenue - Price Adjustment) * 2% DATA C TYPE 0COSTELMNT. DATA V TYPE 0VERSION. DATA P TYPE ZPLANITEM. FOREACH C,V,P. {0AMOUNT,0000415001,V,CASHDISC,PA000004} = ( {0AMOUNT,0000400001,V,CUSTSALES,PA000004} -
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 22
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 23
Optimization 1: Example
Optimization 1: "Fields to be changed" that are not changed
Remove from "Fields to be changed": Key figure = 0AMOUNT Remove from "Fields to be changed": Version = V Remove from "Fields to be changed": Planning Area = 'PA000004'
Parameter group: * Cash Discount = (Base Revenue - Price Adjustment) * 2% DATA C TYPE 0COSTELMNT. DATA P TYPE ZPLANITEM. FOREACH C,P. {0000415001,CASHDISC} = ( {0000400001,CUSTSALES} -
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 25
Optimization 2: Example
Optimization 2 A: "Formula selections (excl. reference data)" that are different than level
Restrict level to formula selection: Key figure Level: = 0AMOUNT, ZPRICEADJ, ZUNCOLLAR Formula: = 0AMOUNT
Restrict level to formula selection: Cost Element Level: No restriction Formula: = '0000415001'
Level is not restricted on Cost Element but formula changes only one Cost Element
Optimization 2 B: "Formula selections (incl. reference data)" that are different than level Optimization works same way as 2A but tries to combine two database selections.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 26
Optimization 3: "Conditions"
Optimization 3 A: If the condition is equal to the level restriction, then the condition can be removed.
Optimization 3 B: If there's only one condition it can be merged with the level selection.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 27
Optimization 4 A: Based on result data only Optimization 4 B: Based on reference data only
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 28
Optimization 4: Example
Fields to be changed: { Material, Planning Item }
If there are 1.000 materials, then TOTALSALES has to be read and updated 1.000 times
Parameter group (AFTER): DATA M TYPE 0MATERIAL. DATA TOTAL TYPE F. TOTAL = 0. FOREACH M. TOTAL = TOTAL + {M,CUSTSALES}. ENDFOR. {#,TOTALSALES} = TOTAL.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 29
Optimization 5 A: Based on result data only Optimization 5 B: Based on reference data only
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 30
Optimization 5: Example
Fields to be changed: { Cost Element, Planning Item }
Parameter group (BEFORE): * Cash Discount = (Base Revenue - Price Adjustment) * 2% DATA C TYPE 0COSTELMNT. DATA P TYPE ZPLANITEM. FOREACH C,P. {0000415001,CASHDISC} = ( {0000400001,CUSTSALES} -
The other operands are read inside the loop although they don't depend on C or P.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 31
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 32
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 33
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 34
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 35
Tip 9: Example
Fields to be changed: { Key figure name, Posting period, Version }
* Posting period and total amount DATA CHA_0FISCPER3 TYPE 0FISCPER3. DATA KYF_TOTAL TYPE F.
* Get actual period from BPS version (via variable) VAR_ZBPSVER = VARV( 'ZBPSVER' ). ATR_ZACTPER = ATRV( 'ZACTPER', VAR_ZBPSVER ). * Get total to be distributed greater than actual period KYF_TOTAL = 0. FOREACH CHA_0FISCPER3. IF CHA_0FISCPER3 > ATR_ZACTPER. KYF_TOTAL = KYF_TOTAL + {0AMOUNT,CHA_0FISCPER3,VAR_ZBPSVER}. ENDIF. ENDFOR.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 36
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 37
* Company DATA CHA_0COMPANY TYPE 0COMPANY. * Source version (attribute of company) DATA ATR_SVERSION TYPE SVERSION. * Target version (variable) DATA VAR_TVERSION TYPE 0VERSION.
Business Case: Copy data into a target version and each company potentially has a different source version.
Source version is set via attribute (ATRV) and then used in operand to read reference data. System will read ALL versions since it can't know which ones would be required!
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 38
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 39
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 40
Key Learnings
Follow the steps on "how to design a planning function" Use subsets to your advantage Remember the tips for implementing and optimizing FOX formulas Always determine the root cause first before starting to optimize
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 41
The information in this document is proprietary to SAP. No part of this document may be reproduced, copied, or transmitted in any form or for any purpose without the express prior written permission of SAP AG. This document is a preliminary version and not subject to your license agreement or any other agreement with SAP. 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. Please note that this document is subject to change and may be changed by SAP at any time without notice. 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, or other 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 of merchantability, 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 limitation shall 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 these materials and does not endorse your use of third-party Web pages nor provide any warranty whatsoever relating to third-party Web pages
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 42
The information in this document is proprietary to SAP. No part of this document may be reproduced, copied, or transmitted in any form or for any purpose without the express prior written permission of SAP AG. This document is a preliminary version and not subject to your license agreement or any other agreement with SAP. 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. Please note that this document is subject to change and may be changed by SAP at any time without notice. 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, or other 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 of merchantability, 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 limitation shall 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 these materials and does not endorse your use of third-party Web pages nor provide any warranty whatsoever relating to third-party Web pages
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 43