Professional Documents
Culture Documents
Marc F. Bernard
Platinum Consultant
SAP NetWeaver RIG Americas
SAP Labs, LLC
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 2
How to Design a Planning Function
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 3
Example for a Planning Function
Field(s) to be changed
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 4
Planning Functions Subsets: Example
Sample data
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 5
Flowchart for Planning Functions
Start of Execution
Data Selection
FOREACH Subset.
ENDFOR.
End of Execution
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 6
Types of Generic Functions
Copy Distribute
Copy By Key
Copy to Several Target Objects By Key from Sender to Receiver
By Reference Data
By Reference Data from Sender to
Delete Receiver
Delete Based on Values
Delete Invalid Combinations Currency Translation
Formulas (FOX)
Repost
Repost Based on Values
Repost Characteristic Relationships
Exit Function
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 7
Complexity vs. Functionality
Predefined
Formulas (FOX) Exits
Functions
Complexity, Functionality
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 8
When to Use Formulas (FOX)
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
How to Implement Formulas (FOX)
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 10
FOX Formulas Definition
Definition:
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 11
FOX Formulas Basics
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 12
FOX Formulas Help (F1 and F4)
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 13
FOX Formulas Basic Examples
Example 1:
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
Some Elements of FOX Formulas
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 15
FOX Formulas Foreach Statement
The values for YEAR are taken from the records in the selection of
the planning package.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 16
FOX Formulas Variables
Example of formula using one planning area variable and three local
variables:
DATA ZCURPER TYPE 0FISCPER.
DATA ZFCPER TYPE 0FISCPER.
DATA COUNTER TYPE I.
* Copy current period to the next 5 forecast periods
ZCURPER = VARV('PERCUR').
DO.
COUNTER = COUNTER + 1.
ZFCPER = TMVL(ZCURPER,COUNTER).
{0COPASLQTY,ZFCPER,RFC} = {0COPASLQTY,ZCURPER,ACT}.
IF COUNTER = 5.
EXIT.
ENDIF.
ENDDO.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 17
FOX Formulas How to test
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 18
Execute a Planning Function
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 19
Execute a Planning Function with Trace
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 20
FOX Formulas How to Optimize
Less FOX coding leads to less ABAP coding that the system has
to process and therefore faster execution times.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 21
Real-world Example
Fields to be changed:
Parameter group:
FOREACH C,V,P.
{0AMOUNT,0000415001,V,CASHDISC,PA000004} =
( {0AMOUNT,0000400001,V,CUSTSALES,PA000004} -
{0AMOUNT,0000410001,V,PRICADJDIS,PA000004} +
{0AMOUNT,0000405002,V,PRICADJBKT,PA000004} ) * 0.02.
ENDFOR.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 22
Optimization 1: "Fields to be changed"
Find all characteristics that are restricted to only one value in the
formula. This means that the characteristic is NOT being changed
and therefore should be removed from the "fields to be changed".
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 23
Optimization 1: Example
Fields to be changed:
{ Cost Element, Planning Item }
Parameter group:
* Cash Discount = (Base Revenue - Price Adjustment) * 2%
DATA C TYPE 0COSTELMNT.
DATA P TYPE ZPLANITEM.
FOREACH C,P.
{0000415001,CASHDISC} =
( {0000400001,CUSTSALES} -
{0000410001,PRICADJDIS} +
{0000405002,PRICADJBKT} ) * 0.02.
ENDFOR.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 24
Optimization 2: "Formula selection"
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
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:
Optimization 3 B:
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 27
Optimization 4: "Formula operands"
Optimization 4 A:
Optimization 4 B:
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 28
Optimization 4: Example
Fields to be changed:
FOREACH M.
ENDFOR.
FOREACH M.
ENDFOR.
{#,TOTALSALES} = TOTAL.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 29
Optimization 5: "Operands in Foreach Loops"
Optimization 5 A:
Optimization 5 B:
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 }
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 31
Optimization 6: "Formulas on Multi Planning Areas"
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 32
Optimization 7: "Nested Loops"
Example: Records
0002 2011 20
FOREACH product.
FOREACH year.
...
FOREACH product, year.
ENDFOR.
ENDFOR.
ENDFOR.
0001 2010 10
0PRODUCT 0FISCYEAR 0AMOUNT
0001 2011 0
0002 2010 0 0001 2010 10
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 33
Optimization 8: "If Statements"
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 34
Tip 9: "Naming Conventions"
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 }
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 37
Tip 10: Example
Fields to be changed:
{ Company, Version }
FOREACH CHA_0COMPANY.
{CHA_0COMPANY,VAR_TVERSION} = {CHA_0COMPANY,ATR_SVERSION} .
ENDFOR.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 38
Tip 11: "Endless Loops"
Save the formula before testing! Otherwise you loose your work if
the program goes into an endless loop and you have to stop the
program.
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 39
Tip 12: "Performance Analysis"
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 40
Key Learnings
SAP AG 2005, Tips & Tricks for FOX Formulas in BW-BPS, Marc F. Bernard / 41
Copyright 2005 SAP AG. All 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 changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP,
Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are trademarks or registered trademarks of IBM Corporation in the United States and/or other
countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver and other SAP products and services mentioned herein as well as their respective logos are
trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned
are 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. 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
Copyright 2005 SAP AG. Alle Rechte vorbehalten
Weitergabe und Vervielfltigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne die ausdrckliche
schriftliche Genehmigung durch SAP AG nicht gestattet. In dieser Publikation enthaltene Informationen knnen ohne vorherige Ankndigung gendert werden.
Die von SAP AG oder deren Vertriebsfirmen angebotenen Softwareprodukte knnen Softwarekomponenten auch anderer Softwarehersteller enthalten.
Microsoft, Windows, Outlook, und PowerPoint sind eingetragene Marken der Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP,
Intelligent Miner, WebSphere, Netfinity, Tivoli, und Informix sind Marken oder eingetragene Marken der IBM Corporation in den USA und/oder anderen Lndern.
Oracle ist eine eingetragene Marke der Oracle Corporation.
UNIX, X/Open, OSF/1, und Motif sind eingetragene Marken der Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, und MultiWin sind Marken oder eingetragene Marken von Citrix Systems, Inc.
HTML, XML, XHTML und W3C sind Marken oder eingetragene Marken des W3C, World Wide Web Consortium, Massachusetts Institute of Technology.
Java ist eine eingetragene Marke von Sun Microsystems, Inc.
JavaScript ist eine eingetragene Marke der Sun Microsystems, Inc., verwendet unter der Lizenz der von Netscape entwickelten und implementierten
Technologie.
MaxDB ist eine Marke von MySQL AB, Schweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver und weitere im Text erwhnte SAP-Produkte und -Dienstleistungen sowie die entsprechenden
Logos sind Marken oder eingetragene Marken der SAP AG in Deutschland und anderen Lndern weltweit. Alle anderen Namen von Produkten und
Dienstleistungen sind Marken der jeweiligen Firmen. Die Angaben im Text sind unverbindlich und dienen lediglich zu Informationszwecken. Produkte knnen
lnderspezifische Unterschiede aufweisen.
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