advanced macros 310 dp en

85
Advanced Macros ADDON.NDAPODP Release 310

Upload: raghav-rathod

Post on 21-Oct-2015

772 views

Category:

Documents


19 download

DESCRIPTION

Macros APO

TRANSCRIPT

Page 1: Advanced Macros 310 DP En

Advanced Macros

AD

DO

N.

ND

AP

OD

P

R e l e a s e 3 1 0

Page 2: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 2

Copyright

© Copyright 2002 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purposewithoutthe 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 proprietarysoftware components of other software vendors.

Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® areregistered 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, IntelligentMiner, WebSphere®, Netfinity®, Tivoli®, Informix and Informix® Dynamic ServerTM aretrademarks of IBM Corporation in USA 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®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®,VideoFrame®, MultiWin® and other Citrix product names referenced herein are trademarks ofCitrix Systems, Inc.

HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World WideWeb 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 fortechnology invented and implemented by Netscape.

SAP, SAP Logo, R/2, RIVA, R/3, SAP ArchiveLink, SAP Business Workflow, WebFlow,SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP, mySAP.com, and otherSAP products and services mentioned herein as well as their respective logos aretrademarks or registered trademarks of SAP AG in Germany and in several other countriesall over the world. MarketSet and Enterprise Buyer are jointly owned trademarks ofSAP Markets and Commerce One. All other product and service names mentioned are thetrademarks of their respective owners.

Page 3: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 3

Icons

Icon Meaning

Caution

Example

Note

Recommendation

Syntax

Typographic Conventions

Type Style Description

Example text Words or characters that appear on the screen. These include fieldnames, screen titles, pushbuttons as well as menu names, paths andoptions.

Cross-references to other documentation.

Example text Emphasized words or phrases in body text, titles of graphics and tables.

EXAMPLE TEXT Names of elements in the system. These include report names,program names, transaction codes, table names, and individual keywords of a programming language, when surrounded by body text, forexample, SELECT and INCLUDE.

Example text Screen output. This includes file and directory names and their paths,messages, source code, names of variables and parameters as well asnames of installation, upgrade and database tools.

EXAMPLE TEXT Keys on the keyboard, for example, function keys (such as F2) or theENTER key.

Example text Exact user entry. These are words or characters that you enter in thesystem exactly as they appear in the documentation.

<Example text> Variable user entry. Pointed brackets indicate that you replace thesewords and characters with appropriate entries.

Page 4: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 4

Advanced Macros ............................................................................................................. 6

MacroBuilder Screen..................................................................................................... 8

Advanced Macro Structures........................................................................................ 9

Using Macro Elements...........................................................................................12

Using Macro Tools.................................................................................................15

Definition of Macros in the MacroBuilder .................................................................17

Semantic Check for Macros....................................................................................19

Menu Functions for Macros ....................................................................................21

Operators and Functions in Macros ........................................................................22

Mathematical Operators and Functions ................................................................24

Statistical Functions ...........................................................................................27

Logical (Boolean) Functions ................................................................................31

Functions Related to Info Objects and Planning Books .........................................32

Multilevel Functions in the Supply Chain Network..............................................44

Date Functions ...................................................................................................46

General and Planning Table Functions ................................................................51

Attributes of Macro Elements..................................................................................58

Standard Macros ...................................................................................................60

Forecast Analysis Using Macros....................................................................................61

Example of a Macro Alert ..........................................................................................63

Translating Advanced Macros .......................................................................................64

Business Cases for Macros...........................................................................................65

Example of a Macro to Convert Percentage Values.....................................................66

Make 2nd Column Read-Only/Make 2nd Column Ready-For-Input...............................67

Make 2nd Column Invisible/Make 2nd Column Visible .................................................68

Hide All Columns <> December (Year View)...............................................................69

Set/Delete Icon for Row 1 (All Planning Objects).........................................................70

Change Foreground Color to Red for Negative Values ................................................71

Calculate Cumulated Values: Year-to-Date.................................................................72

Calculate and Round % Difference.............................................................................73

Info Message If Sum > 1000 ......................................................................................74

Trigger DB Alerts If Value > 0 ....................................................................................75

Calculate Sum of 3 Successive Periods Using Rows/Areas .........................................76

Using Nested Functions ............................................................................................77

Calculate Only for Periods Before 01/01/2000.............................................................78

Using the Number of Workdays for the Calculation......................................................79

Using Actual Currency Conversion Factor...................................................................80

Get Missing Forecast Entries from User .....................................................................81

Using Values from Different Periods ...........................................................................82

Page 5: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 5

Adjust Forecast Depending on LifeCycle ....................................................................83

Values of Row 1 Shift by Offsets in Row 2..................................................................84

Submit a User-Specific Report ...................................................................................85

Trigger Alert Based on Reorder Point .........................................................................86

Popup With Standard Deviation of Forecast Key Figures .............................................87

Page 6: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 6

Advanced Macros

UseUse advanced macros to perform complex calculations quickly and easily.

Macros are executed either directly by the user in interactive planning or automatically at apredefined point in time during a background job.

The definition of macros is optional.

You do not have to write macros yourself. Some stock level and days' supply macros are alsodelivered with the standard SNP planning books. You can create your own planning book forSNP using one of the existing books as a template, and copy the standard macros to the newbook.

IntegrationYou create an advanced macro either when creating or chaning a planning book inCustomizing, or in design mode of interactive planning. You can define a macro either for anentire planning book or for a specific data view.

Prerequisites1. You have created a planning area.

2. You have created a planning buckets profile.

3. You have created a planning book with at least one data view.

FeaturesYou can:

• Control how macro steps are processed through control instructions and conditions.

• Build a macro consisting of one or more steps.

• Control how macro results are calculated through control instructions and conditions.

• Use a wide range of functions and operators (see Operators and Functions in Macros[Page 22]).

• Define offsets so that, for example, the result in one period is determined by a value inthe previous period.

• Restrict the horizon in which the macro is executed to a specific period or periods.

• Write macro results to either a row, or a column, or a cell.

• Write the results of one macro step to a row, column, cell or variable, and use them onlyin subsequent iterations, macro steps or macros.

• Trigger an alert in the Alert Monitor showing the outcome of a macro execution.

Page 7: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 7

To create authorizations for the creation and execution of macros, choose Tools→ Administration → User Maintenance → Roles from the SAP Easy Accessmenu. For more details see Authorization in Supply Network and DemandPlanning [Ext.].

Page 8: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 8

MacroBuilder Screen

DefinitionWhen defining advanced macros, you work in a special desktop environment known as theMacroBuilder.

UseTo open the MacroBuilder, do one of the following:

• From the SAP Easy Access menu, choose Demand Planning → Environment → CurrentSettings → MacroBuilder.

• From design mode of interactive demand planning, choose MacroBuilder => Planning

book or MacroBuilder => Data view .

StructureThe MacroBuilder consists of the following screen areas:

• Macro elements [Page 12] in a tree on the top left

• Depot with parked macros on the bottom left

Keep all macros that you are not currently editing in the depot. This has performanceadvantages: the macros tree containing the macros that you are currently editingworks faster.

• Demand planning table in the top center

• Macro tree with the macro tools [Page 15] in the bottom center

To see the attributes of any item in the tree, double-click on the item.

• Standard macros [Page 60] on the top right

• Clipboard on the bottom right

For more information on how to edit macros, see Definition of Macros in the MacroBuilder[Page 17].

Page 9: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 9

Advanced Macro Structures

DefinitionAn advanced macro consists of one or more macro steps. To define the conditions underwhich individual macro steps are carried out, you use control structures. Each macro stepconsists of one or more calculations. To define these calculations in the macro tree, you usecalculation structures.

StructureA macro can comprise of up to 4 levels. The graphic below shows a simple example :

Macro Title

Name of step

Row row name1 (validity) =

Macro level

Step level

Result level

Row row name2 (validity)

Operator/function

Row row name3 (validity)

Argument level

Level1 2 3 4

Macro Step Result Argument

1. Macro level

This is the top level and consists of the macro name only.

2. Step level

At this level you can enter either a step or a control structure. A macro must containat least one step. A step contains a calculation or series of calculation. A step is alsoan iteration loop. The calculation or operation is repeated over a predefined period, ifyou work with rows.

3. Result level

At this level you specify the macro object to which the results of a calculation oroperation is written. This can be a key figure in the planning book, or an element inthe auxiliary table that you use to store an intermediate result temporarily. At this levelyou can also enter control structures, action boxes, documents, proceduralmessages, or alerts.

4. Argument level

At this level you enter the calculations or operations. Similarly conditions are definedat argument level, if the control structure is entered at result level.

The graphic below is a concrete example of the structure above. The macro calculates theadjusted forecast by adding the manual adjustment to the sales forecast. This is done for theperiod of one year in the future.

Page 10: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 10

Calculate adjusted forecast

Calculate (12 Iterations : M01.2003 ; M 12.2003 )

Row Adjusted forecast (frm M01.2003) =

Macro level

Step level

Result level

Row Sales forecast (frm M01.2003)

+

Row Manual adjustment (frm M01.2003)

Argument level

Control StructuresAs mentioned above, you use control structures at either step level or result level. In the firstcase you can control structures to decide which step to execute depending on whichconditions are satisfied.

The statements that are available here are based on the corresponding ABAP statements,such as IF, DO, CASE, WHILE and are similar in most programming languages. For moredetails refer to the SAP Library for the SAP Web Application Server under Controlling theProgram Flow [Ext.]. Not all ABAP statements are supported in macro control structures.

There are more options when working at the step level than the result level. For instance, youcan use CASE WHEN structures to branch to different steps depending on the value of avariable or key figure.

The following is an example of a macro that makes extensive use of controlstructures. Note the level of the various objects. For information on the functionsused, see Functions Related to Info Objects and Planning Book [Page 32].

Using layout variable as loop counter

Initialize counter

Set loop counter = 1

LAYOUTVARIABLE_SET( ‘LOOPCOUNTER’ ; 1 )DO

New Step: (1 iterations: M 01.2000 ; M01.2000)

Row: Manual Adjustments (Frm M 01.2000) =

LAYOUTVAR_VALUE( ‘LOOPCOUNTER’ )

Add 1 to loop counter

LAYOUTVARIABLE_SET( ‘LOOPCOUNTER’ ;

EVAL(LAYOUTVAR_VALUE( ‘LOOPCOUNTER’ ) + 1 )

)

IF

Condition

LAYOUTVAR_VALUE( ‘LOOPCOUNTER’ )> 5

EXIT

ENDIF

ENDDO

Page 11: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 11

Calculation Structures

You use calculation structures not only to execute calculations but also to carry out otheractions in which a value is not directly assigned to a key figure or variable. Examples of suchactions are:

• Triggering an alert

• Displaying a message or dialog box

• Sending an e-mail

Calculation structures always consist of at least one step.

In general a calculation step consists of a macro element at the result level followed by one ormore elements at the argument level. A simple example is the second graphic above.

Page 12: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 12

Using Macro Elements

UseUse macro elements in combination with macro tools [Page 15] and drag&drop techniques[Page 17] to define macros.

FeaturesIcon Element Description

Macro Used in Demand Planning or Supply Network Planning tocarry out complex or frequent planning tasks quickly andeasily. You can execute a macro in interactive planningor as part of mass processing.

User exit macro A unique and/or complex macro used in DemandPlanning or Supply Network Planning that you implementthrough functional enhancement APODM005 (transactionCMOD). A user exit macro can be executed in interactiveplanning or mass processing.

Step A macro step consists of one or more macro calculationsor macro activities. For each macro step, you define howmany iterations of the macro calculations or macroactivities are to be performed; that is, the area of thetable to which the macro calculations/activities apply.

The sequence of the macro calculations/activites in astep is not significant; that is, a calculation/activity cannotuse the results of another calculation/activity within thesame iteration.

Control statement Used together with a condition (see below) to controlmacro steps and calculations.

Condition Used for the definition of a logical condition that, togetherwith a control instruction, is used for macro steps andcalculations.

Row Row in the table. You can assign the results of acalculation to a row (a results row). A row can be used asan argument in a calculation. A row can also be anargument in a logical condition (an argument row). Thecalculation is repeated for all the cells that lie within theperiod defined for the step.

Column Column in the table. You can assign the results of acalculation to a column (a results column). A column canbe used as an argument in a calculation. A column canalso be an argument in a logical condition (an argumentcolumn). As for rows, calculations are repeated for all thecells in the column.

Cell Cell in the table. You can assign the results of acalculation to a cell (a results cell). A cell can be used asan argument in a calculation. A cell can also be anargument in a logical condition (an argument cell).

Area Several adjacent cells in the table. You can assign theresults of a calculation to an area. Use an area if thefunction of a macro step changes several cells in oneiteration. For example, the function CPY copies values

Page 13: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 13

from one area to another area: e.g. to the auxiliary table.In the "copy to" area, you select only the top left cell ofthe area before pasting. Another use of areas is inmathematical operations, for example where a sum isformed over a range of cells or a maximum value isfound.

Auxiliary table Holds data that is used subsequently as part of themacro execution. Use the auxiliary table to retainintermediary results for subsequent calculations, or tocollect data for calculations.

The same elements are avialble in the auxillary table asin the planning book table.

An auxiliary table is available in every macros book.

Values in an auxiliary table cannot be saved. To savethem, you must assign them to elements in the planningbook table.

Operator/function Symbolizes:

• Comparative operators such as< or >

• Arithmetic operators such as + or -

• A wide range of complex functions that enable you tomanipulate data in your planning book. Thesefunctions include several useful DP and SNP tools.

See also Operators and Functions in Macros [Page 22].

Function You define functions for a rectangular section of thetable. The section borders either are fixed or move witheach iteration.

If an "$" appears next to a function in the macro tree, thismeans that the coordinates of the section are fixed andare not relative to the iterations.

See also F1 Help.

Alert/status Using this element, you can send an alert to the AlertMonitor: for example, you can define an alert that istriggered when a condition (e.g. demand > 1000 boxes)is fulfilled.

A status alert displays the status after the execution ofthe macro. Any previous statuses are deleted from theAlert Montior. If you run a macro twice, you see only thelatest alert.

A message alert displays the current status after theexecution of the macro, and also any previous statuses.If you run a macro twice, you see two alerts.

You assign one of the following priorities to an alert:

• Error

• Warning

• Information

You also assign a text to an alert. This is the text thatappears in the Alert Monitor; for example, MAPE is toobig: &. In the Alert Monitor, the actual value of MAPE

Page 14: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 14

appears in place of the &.

Proceduralmessage

Using this element, you can have the system issue amessage. You define the message text yourself. Ininteractive forecasting, an information message appearsin a dialog box, while warning, success and errormessages appear at the bottom of the screen. In massprocessing, the messages are shown in the job log.

Action box Using this element, you can trigger an action thatcontains a function. If you do not want to assign themacro results to a specific element of the planning table,use an action box. Always use the following functions inan action box:

• HELPTAB_CLEAR

• OUTPUT_POPUP()

• REPORT_SUBMIT()

Document Using this element, you can have the system send anemail. The recipients can be a single internal user, adistribution list, or an external user. There are options forsending to Internet addresses, for sending regular orexpress mails, and for including the demand planningtable as an attachment to the email.

Page 15: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 15

Using Macro Tools

UseUse macro tools in combination with macro elements [Page 12] and drag&drop techniques[Page 17] to define macros.

FeaturesIcon Tool Use this icon to

Attributes Display or change an element's attributes.

Select the element, whose attributes youwant to change or display. Click on the icon.A dialog box with the attributes of theselected element.

This has the effecvt as double-clicking onthe element or selecting it and choosingAttributes from the context menu.

See also Macro Attributes [Page 58].

Delete Delete an element in the macro tree. Thedeleted element is automatically copied tothe macro clipboard.

Check Check the syntax of one macro or of allmacros in the tree.

Generate Generate one macro or all macros. Youmust generated a macro before it can beexecuted.

Active/inactive Activate/deactivate an element in the macrotree. For example, use this tool to checkindividual sections of complex macros bydeactivating some sections and thenchecking the remaining section(s).

Copy to macro clipboard Copy an element in the macro tree to theclipboard.

Paste Paste the contents of the clipboard to themacro tree.

Undo Undo the previous step. You can undo up to15 steps.

Redo Redo the step you have just undone. Youcan redo up to 15 undone steps.

Expand all Expand all nodes in the macro tree.

Collapse all Collapse all nodes in the macro tree.

Save layout settings Save the MacroBuilder's new layout afteryou have adjusted the size of some of thescreen areas. The new screen layout isthen retained and appears the next time youopen the MacroBuilder.

Page 16: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 16

Definition of Macros in the MacroBuilder

UseThere are two basic methods of working in the MacroBuilder:

• The context menu

• Drag&Drop techniques

You define macros in planning books in combination with macro elements [Page 12] andmacro tools [Page 15].

Activities

Context Menu

You use the context menu primarily in the macro tree section. If you select an existing macroelement (this can even be at the Macro level), the system displays a menu with all theavailable options for this element at the current position in the macro. Each macro element islisted separately.

Terminology

Insert - Enter the new element before the selected element

Attach - Enter the new element after the selected element at the same level

Add - Enter the new element after the selected element at the next level

The context menu offers two options that are not available with Drag&Drop:

• Active/inactiveActivate/deactivate an element in the macro tree as in the macro toolbar [Page 15].

• Stopping point on/offSets a stopping point. This means that during execution of the macro the macro stops atthis element. A dialog box appears in which the value of the element is displayed. Youcontinue processing by choosing .

These two options are for use when creating macros, particularly for debugging complexmacros.

Drag&DropUse Drag&Drop to do any of the following:

• Add or insert any macro element in the macro tree

When you drop the element, the system offers you a choice of options if more thanoption is available.

• Move elements within the macro tree

• Drag a macro from the macro tree to the standard macros [Page 60] screen area

• Remove a macro from a standard macro sequence by dragging the macro downwards tothe blank space in the standard macros screen area

• Change the sequence of the standard macros

• Copy a part of the macro tree to the clipboard

Page 17: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 17

The appearance of the icon means that the action is not possible for this element. Theappearance of the + icon means that the action is possible for this element, in which case youcan let go of the left mouse button.

For more information on the different areas of the MacroBuilder screen, see MacroBuilderScreen [Page 8].

Page 18: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 18

Semantic Check for Macros

UseThe syntax checker in the Macro Builder checks the formal correctness of the macro coding.There were however some situations that cannot be checked, but cause problems whenusing the macro. These are often performance issues, where setting an indicator candrastically accelerate the execution of a macro. (In an extreme case a macro could contain anever-ending loop that is not detected by the syntax check.)

This function has been conceived so that new checks can be added as necessary.

IntegrationThis section is optional.

Answer the following questions:

• How is it related to other functions?

• What other functions does the customer need for this function to work?

Subsequently delete the paragraphs in green.

PrerequisitesThis section is optional.

Answer the following questions:

• What has to be in place or has to happen before the customer can use this function?

• What events or system settings (Customizing) trigger this function?

Subsequently delete the paragraphs in green.

FeaturesThis section is optional.

Answer the following question: What does the function do in detail?

Subsequently delete the paragraphs in green.

You can start the semantic check at the following levels:

• Macro book

The check runs for all the macros in the book.

• Macro

One or more macros are checked

• Step

A macro step is checked

• Result

The individual calculation or process is checked. A semantic check at more detailed(argument) level is superfluous.

At the moment the following checks are available:

Page 19: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 19

o 'Do not initialize aux. table'

The system checks wheteher this indicator at the macro level has been set. If nota warning is displayed.

If the auxiliary table is not initialized when you call up the macro, any values thatare in the table from the execution of previous macros remain in the table andcan be used in the current macro. All entries in the auxiliary table are lost whenyou leave the planning book.

o Layout

The system checks that the correct Change scope has been assigned to aresults element in the attributes. If the function that is called changes theattributes of a cell, for instance by changing the background color or settin anicon, the Change scope should be Attributes, otherwise Values or Fixedvalues.

o 'Do not display initial values'

This indicator at macro level affects performance. If it is not set initial values, that is cells thathave no entry, are converted to '0', and are taken into consideration during calculations.

ActivitiesThis section is optional.

Answer the following questions:

• What does the customer do?

• What does the system do?

Subsequently delete the paragraphs in green.

You can start the semantic check from either the Macro Workbench or the Macro Builder

ExampleThis section is optional.

Answer the following question: Can you give me an example of the use of this function?

Subsequently delete the paragraphs in green.

Page 20: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 20

Menu Functions for Macros

UseThree functions are available to you if you access the MacroBuilder as a stand-aloneapplication (Demand Planning/Supply Network Planning → Environment → CurrentSettings → Macro Builder) as opposed to through interactive planning. You find thesefunctions in the Edit menu.

Features

Menu option Use this function to

Change name of book Change the name of a macro book. A macro book contains eitherall of the macros created for the planning book as a whole or all ofthe macros created for a specific data view in the planning book.

Initially, the macro book has the same name as the planning book.

Import macro(s) Import either all macros or one macro from another macro book.

After you have carried out the import, you must perform aconsistency check on the macros to ensure, for example, that allthe rows in the source book also exist in the target book.

After you have carried out the consistency check, you mustactivate the macros in the target macro book.

User function Add a function that you have programmed in your own system tothe list of possible operators/functions in the MacroBuilder. Youhave programmed the function with transaction SE37. In the dialogbox, which appears after choosing the menu entry, enter thetechnical name of the user function. Choose Enter. Another screenappears in which you select the export parameters of the function.This selection must be consistent with parameters in the functionitself.

Page 21: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 21

Operators and Functions in MacrosYou enter functions in the following manner:

1. Drag and drop the operator/function icon to the relevant line in the macro work area. Adialog box appears.

2. On the bottom line choose the function you want to insert by using the pull-down box orF4 help. The function automatically appears in both lines. On the top line you can addalpha-numeric arguments to the functions.

For more details of individual function see the following topics according to thetype of function you want to use:

Mathematical Operators and Functions [Page 24]

Statistical Functions [Page 27]

Logical (Boolean) Functions [Page 31]

Functions Related to Info Objects [Page 32]

Date Functions [Page 46]

General and Planning Table Functions [Page 51]

SNP Functions [Ext.]

3. If you want to add another macro element (an icon) to your macro, do not close theparentheses (in other words delete the right-hand parenthesis) and choose . Enter themacro element as usual. After you have made all the necessary entries, finish thefunction by adding ) as the last line.

You can nest macro functions within each other. In the following example the macrostep converts the value of row 1 from the internal unit of the current resource to theexternal unit contained in the resource master.

Convert to resource unit (12 Iterations : Column 1 ; Column 12 )

Row row1 (Frm Column 1 )

* UNIT_CON_FAC (

Row: Values of row 1 in resource unit ( Frm Column 1 ) =

INTERNAL_RESOURCE_UNIT( ACT_RESOURCE ) ;

RESOURCE_UNIT( ACT_RESOURCE ) )

You can also define and use your own functions. For more details, see User function in MenuFunctions for Macros [Page 21].

Entry Conventions

An argument is an input parameter, an independent variable, in a function. Enter charactervalues of an argument in single inverted commas. Enter numerical values of an argumentwithout single inverted commas.

Page 22: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 22

Use a semicolon as a separator between the arguments of a function. Leave nospace between a function operator and a parenthesis, but insert blanks beforeand after arguments in the parentheses; for example,

o ROUND( X ; Y )

o ROUND( SUM ( X ; Z ) ; Y )

$ represents a fixed coordinate.

Changing Attributes

Most of the functions available are value functions, controlling the numbers or values storedwithin APO. However, there is another class of functions in APO, the attribute functions, thatcontrol the properties of the data view instead of the stored values. For instance, thesefunctions change the color of a cell or row, hide or unhide cells or rows, or changes theavaialability for input.

If you want to use one of these functions, you must change the Change scope field on theattributes of the result (row, column, or element) to Attributes.

The results of attribute functions are not persistent in APO. In other words, if youturn a row’s background color green, this change is not stored permanently by thesystem. So when you make a new selection in interactive planning or leave andreenter the planning view, that green color change will be lost. Therefore, if youwant to see the results of the attribute change next time you enter the selection,you will need to rerun the relevant macros again. In some circumstances you mayalso need an additional key figure to save the results of actions from previoussessions or selections.

It is not possible to modify the same result row with two or more attributefunctions at the same time. The example below would lead to an error during thecheck. You must repeat the results row for each attribute function.

Row Adjusted forecast (Attributes) =

CELL_BG( 12 )

CELL_INPUT( 0 )

Similarly if you wish to use the attribute of a cell, column, or row in a calculation, you mustchange the Data Source field in the attributes of the argument to Row attributes or Columnattributes.

Page 23: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 23

Mathematical Operators and Functions

Mathematical Operators

Operator Explanation

( Opening bracket

) Closing bracket

* Multiplication

** Power (e.g. 2 * * 3 = 2 * 2 * 2)

+ Addition

- Subtraction

/ Division

; Separator between arguments. An argument is an inputparameter. For example, in function f, expressed as f( X1 ;X2 ), the arguments are X1 and X2.

< Smaller than

<= Smaller than or equal to

> Larger than

>= Larger than or equal to

Mathematical Functions

Function ExplanationABS() ABS( X ) returns the absolute value |X| for X. The

argument can be either a number that you enter in anOperator/function dialog box or one of the macroelements cell, row or column from the planning table orauxiliary table.

ACOS() Arccos( X ) where X is between –1 and 1, so that thefunction has values in the range [-π/2, π/2]. The argumentcan be either a number that you enter in anOperator/function dialog box or one of the macroelements cell, row or column from the planning table orauxiliary table.

ASIN() Arc sin( X ) where X is between –1 and 1, so that thefunction has values in the range [-π/2, π/2]. The argumentcan be either a number that you enter in anOperator/function dialog box or one of the macroelements cell, row or column from the planning table orauxiliary table.

ATAN() Arc tan( X ) has values in the range [-π/2, π/2]. Theargument can be either a number that you enter in anOperator/function dialog box or one of the macroelements cell, row or column from the planning table orauxiliary table.

BETWEEN Operator: for example, X BETWEEN 0 AND 10 returns thevalue 1 if X falls within the range 0 through 10.

COS() COS( X ) returns the cosine of an angle measured inradians. The argument can be either a number that you

Page 24: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 24

enter in an Operator/function dialog box, or one of themacro elements cell, row or column from the planningtable or auxiliary table.

COSH() COSH ( X ) returns the hyperbolic cosine. The argumentcan be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orauxiliary table.

DIV Whole number division (quotient) operator: for example, 6DIV 4 returns 1.

EXP() EXP( X ) is the exponential function. The argument can beeither a number that you enter in an Operator/functiondialog box, or one of the macro elements cell, row orcolumn from the planning table or the auxiliary table.

FAC() FAC( n ) returns the factor of n, that is, the result ofmultiplying the integers from 1 through n, expressed as n!If n = 3, then 3! = 3 * 2 * 1 = 6. The argument can beeither a number that you enter in an Operator/functiondialog box, or one of the macro elements cell, row, orcolumn from the planning table or the auxiliary table.

FLOOR() FLOOR( X ) returns the largest integer value that is notgreater than X. The argument can be either a number thatyou enter in an Operator/function dialog box, or one ofthe macro elements cell, row or column from theplanning table or the auxiliary table.

FRAC() FRAC( X ) returns the decimal part of X. The argumentcan be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orauxiliary table.

LOG() LOG( X ) returns the natural logarithm of X. The argumentcan be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table.

LOG10() LOG10( X ) returns the logarithm to the base 10 of X .Theargument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table.

MOD Whole number division (remainder) operator: for example,6 MOD 4 returns 0.5.

PARTIALSUM() PARTIALSUM( X ; Y1 ; ... ; Yn ) allows you to sum avariable number of values in a time series where Xspecifies the number of values and Y1 through Yn specifythe time series.

ROUND() ROUND( X ; Y ) rounds X to Y decimal places. Thearguments can be numbers that you enter inOperator/function dialog boxes, as well as cell(s),row(s) or column(s) from the planning table or theauxiliary table.

SIGN() SIGN( X ) returnsthe value of 1 if X > 0the value of 0 if X = 0the value of -1 if X < 0The argument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table ortheauxiliary table.

Page 25: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 25

SIN() SIN( X ) returns the sine of angle X measured in radians.The argument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column or from the planning tableor the auxiliary table.

SQRT() SQRT( X ) returns the square root of a non-negativenumber. The argument can be either a number that youenter in an Operator/function dialog box, or one of themacro elements cell, row or column from the planningtable or the auxiliary table.

SUM() SUM ( X1 ; X2;... Xn ) returns the sum of the specifiednumbers.

TAN() TAN( X ) returns the tangent of angle X measured inradians. The argument can be either a number that youenter in an Operator/function dialog box, or one of themacro elements cell, row or column from the planningtable or the auxiliary table.

TANH() TANH( X ) returns the hyperbolic tangent of X. Theargument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table.

TRUNC() TRUNC( X ) returns the integer part of X. The argumentcan be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table.

Page 26: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 26

Statistical Functions

Function Explanation

AVG() AVG( X1 ;...; Xn ) returns the mean average of X1 throughXn. The arguments can be numbers that you enter inOperator/function dialog boxes, as well as rows,columns, cells or areas from the planning table orauxiliary table.

BINOM() BINOM( n ; k ) calculates the binomial coefficient basedon the formula n! / k!(n-k)! Use this function to determinethe total number of possible combinations withoutrepetition of k items in a set of n items. The argumentscan be numbers that you enter in Operator/functiondialog boxes, as well as rows, columns or cells from theplanning table or auxiliary table.

CDFB() CDFB( X ; n ; p ) returns the probability that the value of abinomial ( n ; p ) distributed variable (see DFB() ) is lessthan or equal to X; thus, the cumulative probabilityfunction of the binomial distribution in a sample of size nwhere p is the probability that a faulty item is drawn. Thearguments can be numbers that you enter inOperator/function dialog boxes as well as rows,columns or cells from the planning table or auxiliarytable.

CDFH() CDFH( X ; n ; M ; N ) returns the probability that the valueof a distributed variable (see DFH() ) is less than or equalto X; thus, the cumulative probabiity function of thehypergeometric distribution, where n is the size of thesample, M is the number of faulty items in the sample, andN is the size of the population. The arguments can benumbers that you enter in Operator/function dialogboxes, as well as rows, columns or cells from theplanning table or auxiliary table.

CDFN() CDFN( X ) returns the probability that the value of astandard normal distributed variable is less than X; thus,the cumulative function of the standard normaldistribution. The argument can be either a number thatyou enter in an Operator/function dialog box, or one ofthe macro elements row, column or cell from theplanning table or auxiliary table.

CDFT() CDFT( X ; n ) returns the probability that the value of astandard normal distributed variable is less than X; thus,the cumulative density function of Student's t distributionwhere n is the degrees of freedom (n >= 4). Thearguments can be numbers that you enter inOperator/function dialog boxes, as well as rows,columns, or cells from the planning table or auxiliarytable.

CONSTANT() CONSTANT( X1 ; ... ; Xn ; Y1 ; ... ; Yn ) returns theconstant A of a linear regression line Y = A + BX for aseries of observed values. X1 through Xn gives the valuesof the explanatory variable. Y1 through Yn gives thevalues of the depedent variable. The number of the values

Page 27: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 27

Xi and Yi must be the same. The arguments of thefunction can be number(s) that you enter inOperator/function dialog boxes as well as cell(s),row(s), column(s) or area(s) from the planning table orthe auxiliary table.

COR() COR( X1 ; ... ; Xn ; Y1 ; ... ; Yn ) returns the correlationcoefficient for a two-dimensional random variable forwhich the values X1 through Xn and Y1 through Yn areobserved. This allows you to examine the relationshipbetween two random variables. The number of the valuesXi and Yi must be the same. The arguments of thefunction can be number(s) that you enter inOperator/function dialog box as well as cell(s), row(s),column(s) or area(s) from the planning table or theauxiliary table.

COV() COV( X1 ; ... ; Xn ; Y1 ; ... ; Yn ) returns the covariance forthe two data sets X1 through Xn and Y1 through Yn. Thearguments of the function can be number(s) that you enterin Operator/function dialog boxes as well as cell(s),row(s), column(s) or area(s) from the planning table orthe auxiliary table.

DFB() DFB( m ; n ; p ) returns the probability of the binomialdistribution where m is the number of faulty items in asample of size n, and p is the probability that a faulty itemwill be drawn. The arguments can be numbers that youenter in Operator/function dialog boxes, as well as rows,columns or cells from the planning table or auxiliarytable.

DFH() DFH( m ; n ; M ; N ) returns the probability of thehypergeometric distribution, that is, the probability offinding m faulty items in a sample of size n where M is thenumber of faulty items in the population and N is the sizeof the population. The arguments can be number(s) thatyou enter in Operator/function dialog boxes, as well asrows, columns or cells from the planning table orauxiliary table.

E_STDEV() E_STDEV( X1 ; ... ; Xn ) returns the estimated value forthe standard deviation of a random variable based on theobserved values X1 through Xn, i.e. SQRT( E_VAR( X1 ;... ; Xn ) ). The arguments can be number(s) that that youenter in Operator/function dialog boxes, as well asrow(s), column(s), cell(s), or area(s) from the planningtable or auxiliary table.

E_VAR() E_VAR( X1 ; ... ; Xn ) returns the unbiased estimatedvalue for the variance of a random variable based on theobserved values X1 through Xn. The arguments can benumber(s) that that you enter in Operator/function dialogboxes, as well as row(s), column(s), cell(s), or area(s)from the planning table or auxiliary table. The correctionfactor n / n-1 is the difference between the functionsE_VAR() and VAR().

GAMMA() GAMMA( X ) returns the gamma function for X. Theargument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table.

Page 28: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 28

MAD() MAD( X1 ; ... ; Xn ) returns the mean absolute deviation ofthe values of the values X1 through Xn. The argumentscan be number(s) that you enter in Operator/functiondialog boxes, as well as cell(s), row(s), column(s) orarea(s) from the planning table or the auxiliary table.

MAPE() MAPE( X1 ; ... ; Xn ; Y1 ; ... ; Yn ) returns the meanabsolute percentage error for the values X1, Y1 throughXn, Yn. The arguments can be numbers that you enter inOperator/function dialog boxes, as well as cell(s),row(s), column(s) or area(s) from the planning table orthe auxiliary table.

MAX() MAX( X1 ; ... ; Xn ) returns the greatest value in the rangeX1 through Xn. The arguments can be either numbers thatyou enter in Operator/function dialog boxes, or cell(s),row(s), column(s) or area(s) from the planning table orthe auxiliary table.

MEAN() MEAN( X1 ; ... ; Xn ) returns the mean of the values X1through Xn. The arguments can be numbers that youenter in Operator/function dialog boxes, as well ascell(s), row(s), column(s) or area(s) from the planningtable or the auxiliary table.

MEDIAN() MEDIAN( X1 ; ... ; Xn ) returns the median of the valuesX1 through Xn. The arguments can be numbers that youenter in Operator/function dialog boxes, as well ascell(s), row(s), column(s) or area(s) from the planningtable or the auxiliary table.

MIN() MIN( X1 ; ... ; Xn ) returns the smallest value of the valuesX1 through Xn. The arguments can be numbers that youenter in Operator/function dialog boxes, as well ascell(s), row(s), column(s) or area(s) from the planningtable or the auxiliary table.

MPE() MPE( X1 ; ... ; Xn ; Y1 ; ... ; Yn) returns the meanpercentage error for the values X1, Y1 through Xn, Yn.The arguments can be number(s) that you enter inOperator/function dialog boxes, as well as cell(s),row(s), column(s) or area(s) from the planning table orthe auxiliary table.

MSE() MSE( X1 ; ... ; Xn ; Y1 ; ... ; Yn ) returns the mean squareerror for the values X1, Y1 through Xn, Yn. Thearguments can be numbers that you enter inOperator/function dialog boxes, as well as cell(s),row(s), column(s) or area(s) from the planning table orthe auxiliary table.

PERMUT() PERMUT( X ; Y ) returns the number of possiblepermutations when X objects are selected from a set of Yobjects where Y > X or Y = X. PERMUT (X ; Y ) = X! /(X -Y)! The arguments can be numbers that you enter in anOperator/function dialog box, as well as cell(s), row(s)or column(s) from the planning table or the auxiliarytable.

RMSE() RMSE( X1 ; ... ; Xn ; Y1 ; ... ; Yn ) returns the root of themean square error for the values X1, Y1 through Xn, Yn.The arguments can be numbers that you enter inOperator/function dialog boxes, as well as cell(s),row(s), column(s) or area(s) from the planning table or

Page 29: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 29

the auxiliary table.

STDEV() STDEV( X1 ; ... ; Xn ) returns the standard deviation of thevalues X1 through Xn. The arguments can be numbersthat you enter in Operator/function dialog boxes, as wellas cell(s), row(s), column(s) or area(s) from the planningtable or the auxiliary table.

TREND() TREND( X1 ; ... ; Xn ; Y1 ; ... ; Yn ) returns the trend B in alinear regression line Y = A + BX for a series of observedpairs of values. X1 through Xn gives the values of theexplanatory variable. Y1 through Yn gives the values ofthe depedent variable. The number of the values Xi and Yimust be the same. The arguments can be numbers thatyou enter in an Operator/function dialog box, as well ascell(s), row(s), column(s) or area(s) from the planningtable or the auxiliary table.

VAR() VAR( X1 ; ... ; Xn ) returns the variance of the values X1through Xn. The arguments can be numbers that youenter in Operator/function dialog boxes, as well ascell(s), row(s), column(s) or area(s) from the planningtable or the auxiliary table.

VX() VX( X1 ; ... ; Xn ) returns the coefficient of variation for thevalues X1 through Xn, calculated as the standarddeviation STDEV( X1 ; ... ; Xn ) divided by the meanMEAN ( X1 ; ... ; Xn ). The arguments can be numbersthat you enter in Operator/function dialog boxes, as wellas cell(s), row(s), column(s) or area(s) from the planningtable or the auxiliary table.

Page 30: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 30

Logical (Boolean) FunctionsFunction Explanation

AND Boolean operator for conditions: true only if bothconditions are true.

NOT Boolean operator for conditions: logical negation.

OR Logical operator: true if either one or both conditions aretrue.

Page 31: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 31

Functions Related to Info Objects and PlanningBooks

Function Explanation

ACT_COLUMN ACT_COLUMN returns the number of the column that iscurrently being processed.

ACT_IOBJNM_VALUE() ACT_IOBJNM_VALUE( 'IOBJNM'; <GRID=2'> ) returnsthe value of the InfoObject that is currently being planned.'GRID=2' is an optional parameter. If you specify thisparameter, the value of the specified InfoObject in thesecond grid at the time of the calculation is returned. Forexample, the result of ACT_IOBJNM_VALUE( 'SALORG')might be 'north'.

ACT_LEVEL or ACT_LEVEL() ACT_LEVEL returns the level of the object you areplanning. 'GRID=2' is an optional parameter. If you specifythis parameter, the level of the planning object in thesecond grid is returned. For example, the result ofACT_LEVEL ( 'GRID=2' ) is 2, if the planning object at thetime of the calculation is the result of the second drill-down. in grid 2.

ACT_LOCATION orACT_LOCATION()

ACT_LOCATION returns the name of the location that iscurrently being planned where the InfoObject for thelocation is 9ALOCNO. For example, the result ofACT_LOCATION might be DC-BERLIN. 'GRID=2' is anoptional parameter. If you specify this parameter, thename of the location being calculated in the second grid isreturned.

ACT_LOCATION _PRODUCTSor ACT_LOCATION_PRODUCTS()

ACT_LOCATION _PRODUCTS returns all the product-locations pairs that are contained in the current selection.'GRID=2' is an optional parameter. If you specify thisparameter, the system returns the location products in theselection in the second grid.

ACT_PLOB ACT_PLOB returns the internal number of the planningobject for which the macro is currently being processed.The internal number of a planning object is often neededin other macro functions.

ACT_PLOB_GRID2 ACT_PLOB_GRID2 returns the internal number of theplanning object in grid 2 for which the macro is currentlybeing processed. The internal number of a planning objectis often needed in other macro functions.

ACT_PRODUCT orACT_PRODUCT()

ACT_PRODUCT returns the name of the product that iscurrently being calculated where the InfoObject for theproduct is 9AMATNR. For example, the result ofACT_PRODUCT might be 4711. 'GRID=2' is an optionalparameter. If you specify this parameter, the name of theproduct

ACT_RESOURCE orACT_RESOURCE()

ACT_RESOURCE returns the name of the resource thatis currently being planned where the InfoObject name ofthe resource is 9ARNAME. For example, the result ofACT_RESOURCE might be RES-20_1000_001. 'GRID=2'is an optional parameter. If you specify this parameter, the

Page 32: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 32

name of the resource being calculated in the second gridis returned.

ACT_USER ACT_USER returns the user name of the current planner.

ACT_VERSION orACT_VERSION()

ACT_VERSION returns the version that is currently beingplanned where the InfoObject name of the version is9AVERSION. 'GRID=2' is an optional argument. If youspecify this argument, the version being planned in thesecond grid is returned.For example, the result of ACT_VERSION( 'GRID=2' )might be 001.

AGG_LEVEL() AGG_LEVEL( 'IOBJNM'; <GRID=2'> ) returns 1 if you areplanning on an aggregate level with respect to theInfoObject IOBJNM; where IOBJNM is the technical nameof the InfoObject. For example, if your selection containsproduct 11 and product 12 and if 9AMATNR is theInfoObject name of the product, AGG_LEVEL('9AMATNR' ) returns 1. AGG_LEVEL( 'IOBJNM' ) returns0 if you are planning on the detailed level with respect tothe InfoObject IOBJNM; for example, if your selectioncontains product 11 only, AGG_LEVEL ('9AMATNR' )returns 0. You enter the InfoObject name - in thisexample, '9AMATNR' - as the argument in anOperator/Function dialog box. 'GRID=2' is an optionalparameter. If you specify this parameter, the function iscarried out with respect to the InfoObject currently beingplanned in the second grid.

ALERT_BDATE() ALERT_BDATE( ALERT ) returns the start date of theearliest valid alert/status of the alert/status type specifiedby ALERT for the current selection. The argument of thisfunction is an alert/status element. For more informationon macro elements, see the Application Help for DemandPlanning.

ALERT_EDATE() ALERT_EDATE( ALERT ) returns the finish date of thelatest valid alert/status of the alert/ status type specified byALERT for the current selection. The argument of thisfunction is an alert/status element.

ALERT_EXIST() ALERT_EXIST( ALERT ) returns the number ofalerts/statuses that exist for alert/status type ALERT forthe current selection. The argument of this function is analert/status element.

ALERT_PROFILE_THRESH() ALERT_PROFILE_THRESH( ‘profile’ ; ‘alert type’ ; ‘alertpriority’ ; <’alert object type’> ; <’application’>) returns thethreshold value for a particular alert type and Priority(information, warning, error) in an alert profile.

ALLOC() ALLOC( n ; m ; X1 ; ... ; Xn + m + 1 ; Y1 ; ... ; Yn + m + 1 )returns the open allocation quantity that is available forsatisfying sales orders, where n is the number ofallocation periods before the current period, m is thenumber of allocation periods after the current period, Xi isthe allocation quantity for period i ( i = 1 ... n + m + 1 ),and Yi is the incoming orders quantity for period i. Thearguments can be numbers that you enter inOperator/function dialog boxes as well as rows,columns, cells or areas from the planning table orauxiliary table.

Page 33: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 33

ALLOC_MISQTY() ALLOC_MISQTY( n ; m ; X1 ; ... ; Xn + m + 1 ; Y1 ; ... ; Yn+ m + 1 ) returns the amount by which the customer hasalready exhausted their allocation, where n is the numberof allocation periods before the current period, m is thenumber of allocation periods after the current period, Xi isthe allocation quantity for period i ( i = 1 ... n + m + 1 ),and Yi is the incoming orders quantity for period i. Thearguments can be numbers that you enter inOperator/function dialog boxes as well as rows,columns, cells or areas from the planning table orauxiliary table.

BUCKET_BDATE() BUCKET_BDATE( X1 ; ... ; Xn ) returns the earliest startdate of the periods given by the cell(s), row(s) and/orcolumn(s) (not areas) X1 through Xn of the planning tableor the auxiliary table. This date is expressed as an integerwith reference to the date 0001/01/01. In the attributes ofthe argument elements, you must specify Period data asthe data source.

BUCKET_DATE_IN() BUCKET_DATE_IN( X ; Y1 ; ... ; Yn ) returns 1 if date Xfalls within the periods given by the cell(s), row(s) and/orcolumn(s) (not areas) Y1 through Yn. Otherwise, 0 isreturned. The date X (for example, the function TODAY orDATE() ) is expressed as an integer with reference to thedate 0001/01/01. The argument can be either a numberthat you enter in an Operator/function dialog box or oneof the macro elements cell, row or column from theplanning table or auxiliary table. In the attributes of theargument elements Y1 through Yn, you must specifyPeriod data as the data source.

BUCKET_DAYS() BUCKET_DAYS( X1 ; ... ; Xn ) returns the number ofGregorian calendar days of the periods given by thecell(s), row(s) and/or column(s) (not areas) X1 throughXn. In the attributes of the argument elements, you mustspecify Period data as the data source.

BUCKET_DESCRIPTION() BUCKET_DESCRIPTION( X ) returns for the specifiedcolumn X the text that appears in the column of thatperiod in the planning table.

BUCKET_EDATE() BUCKET_EDATE( X1 ; ... ; Xn ) returns the latest finishdate of the periods given by the cell(s), row(s) and/orcolumn(s) (not areas) X1 through Xn. This date isexpressed as an integer with reference to the date0001/01/01. In the attributes of the argument elements,you must specify Period data as the data source.

BUCKET_WDAYS() BUCKET_WDAYS( <calendar> ; X1 ; ... ; Xn) returns thenumber of workdays in the periods given by the cell(s),row(s), and/or column(s) (not areas) X1 through Xn. Inthe attributes of the argument elements, you must specifyPeriod data as the data source. The specification of acalendar as the first argument is optional. If you do notspecify a calendar, the system reads the calendar givenby the time stream in the storage buckets profile. If notime stream is defined, the system uses calendar days.

CALC_ERROR CALC_ERROR returns the value X if an error hasoccurred during execution of the macro.

CALENDAR() CALENDAR( 'location' ; 'calendar type' ; <version> )

Page 34: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 34

returns the calendar of the specified type that is used bythe specified location in the specified version. Thespecification of a version as the third argument is optional.CALENDAR( ACT_LOCATION ; 'PP' ) would return theproduction planning calendar of the location you arecurrently planning.

CALENDAR_WDAYS() CALENDAR_WDAYS( ‘calendar’ ; from date ; <to date> )returns the number of workdays between the from dateand the to date in the calendar specified.

CBP_SET_INDICATOR() CBP_SET_INDICATOR ('mode') switches the display ofthe CBP progress indicator on or off. The argument iseither 'ON' or 'OFF'. The default value is 'ON'.

CBP_SET_ROUNDING() CBP_SET_ROUNDING ('mode') switches rounding on oroff for CBP. The argument is either 'ON' or 'OFF'. Thedefault value is 'ON'.

COLLABORATION() COLLABORATION ( NAME ) returns a value of 1 if youare currently planning collaboration NAME; otherwise, 0.You enter the name NAME of the collaboration as anargument in an Operator/function dialog box.

DET_LEVEL() DET_LEVEL( 'IOBJNM' ; <GRID=2> ) returns 0 if you areplanning on an aggregate level with respect to theInfoObject IOBJNM, where IOBJNM is the technical nameof the InfoObject. For example, if your selection containsproduct 11 and product 12, and if 9AMATNR is theInfoObject name of products, DET_LEVEL( '9AMATNR' )returns 0. DET_LEVEL( 'IOBJNM' ) returns 1 if you areplanning on the detailed level with respect to theInfoObject IOBJNM; for example, if your selectioncontains product 11 only, DET_LEVEL( '9AMATNR' )returns 1. You enter the InfoObject name - in thisexample, 9AMATNR - as the argument in anOperator/function dialog box. 'GRID=2' is an optionalparameter. If you specify this parameter, the function iscarried out with respect to the InfoObject currently beingplanned in the second grid.

DRILL_DOWN() DRILL_DOWN(' InfoObject',<'internal'>) carries out a drill-down using the specified InfoObject. The display is as forDetails (all) in planning table. If you set the optionalargument 'internal' the display is not changed. This optionimproves performance, if you intend to drill-up in the samemacro subsequently.

DRILL_UP() DRILL_UP(' InfoObject') carries out a drill-up using thespecified InfoObject.

FIX_CALC() FIX_CALC( X1; X2: <input check> ) performs fixingcalculation with X1 as the row containing the key figurewith the value to be fixed and X2 the key figure for thefixed values. If the input check indicator is set (for instanceX), the system tries to correct any inconsistencies thatmay occur due to changes being made on the detail level.For example, a key figure has a value of 100 at theaggregate level and consists of three values at detail level50, 30 and 20. You then change the last value to 40, thesystem will reduce the remaining levels so that the total isstill 100.Macros using this function should not be used at detail

Page 35: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 35

level.

FORECAST_PROFILE_SET() FORECAST_PROFILE_SET('profile'; 'profile type';'version';< key figure 'IOBJNM'> ) sets the forecast profile'profile' for the forecasting type 'profile type' (S -univariate, M - MLR, C - composite) and the version'version'. An optional entry is the key figure for which theprofile is valid, for example 9AFCST for the standardforecast key figure.

INVENTORY_COST() INVENTORY_COST( 'product' ; 'location' ; <'version'> )returns the inventory cost of the specified product at aspecified location in the specified version. The thirdargument for the version is optional. INVENTORY_COST(ACT_PRODUCT ; ACT_LOCATION ) returns theinventory cost of the currently planned product in thecurrently planned location.

INTERNAL_RESOURCE_UNIT() INTERNAL_RESOURCE_UNIT( 'resource' ; 'version' )returns the unit of measure in which a resource is saved inLiveCache.

ITERATION_COUNTER ITERATION_COUNTER returns the number of iterationsthat have been carried out in the current step.

IOBJNM_VALUE() IOBJNM_VALUE( 'IOBJNM' ; 'VALUE' ) determineswhether the current selection contains only data for thespecified characteristic value VALUE of the InfoObjectIOBJNM. If yes, the system returns the value 1; otherwise,0. Enter the arguments in a dialog box of theOperator/function element. Use this function to find out,for example, if the current selection contains data forproduct VALUE.

KEYFS_PLOB() KEYFS_PLOB(X) returns the internal number of planningobject in row X. In the attributes of the argument row, thevalue in the Data field must be Row attributes. You canuse this function as an argument in other macro functions.

KEYFS_VERSION() KEYFS_VERSION( X ) returns the version of the keyfigure values in row X. In the attributes of the argumentrow, the value in the Data field must be Row attributes.

LAYOUTVAR_VALUE() LAYOUTVAR_VALUE ( 'my_variable' ) returns the valueof a numeric layout variable where 'my_variable' is thename of the variable.

LAYOUTVARIABLE() LAYOUTVARIABLE( 'my_variable' ) returns the value ofan alpha-numeric layout variable where 'my_variable' isthe name of the variable.

LAYOUTVARIABLE_SET() LAYOUTVARIABLE_SET( 'my_variable' ; X ) sets thevalue of a numerical or alphanumerical layout variable toX where 'my_variable' is the name of the variable and X isthe value of the variable. With this function you can usethe specified variable in (an)other macro(s) in the samemacro book. Put the value of the variable in invertedcommas if it is a character value; for example, 'X'. If thevalue of the variable is a quantity, do not put it in invertedcommas; for example, X.

LOC() LOC( 'FIELD_NAME' ; <'location'> ; <'version'> ) returnsthe content of a numerical field in the location masterrecord of the specified location. The arguments for thelocation and version are optional. If you specify no

Page 36: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 36

argument for the location, the system uses the currentlyplanned location. However, it is better for performancereasons to use the function ACT_LOCATION. Forexample, LOC( 'DURAT' ; ACT_LOCATION ) returns themaximum duration during continuous move of the currentlocation.

LOC_C() LOC_C( 'FIELD_NAME' ; <'location'> ; <'version'> )returns the content of a character field in the locationmaster record of the specified location. The arguments forthe location and version are optional. If you specify noargument for the location, the system uses the currentlyplanned location. However, it is better for performancereasons to use the function ACT_LOCATION. Forexample, LOC_C( 'PARTNER' ; ACT_LOCATION )returns the partner for the current location.

LOC_EXTRA() LOG_EXTRA( n ; <'location'> ; <'version'> ) gets thevalue of an extra field in the location master record for thespecified location in the specified version, where nrepresents the number of the extra field. For example,LOC_EXTRA( 1 ; ACT_LOCATION ) gets the value inextra field 1 for the currently planned location. Thearguments for location and version are optional. If youspecify no argument for the location, the system uses thecurrently planned location. However, it is better forperformance reasons to use the functionACT_LOCATION. Use this function for numeric fields.

LOC_EXTRAC() LOG_EXTRAC( n ; <'location'> ; <'version'> ) gets thevalue of an extra character field in the location masterrecord for the specified location in the specified version,where n represents the number of the extra field. Forexample, LOC_EXTRAC( 1 ; ACT_LOCATION ) gets thevalue in extra field 1 for the currently planned location, ifthis field is of type character. The arguments for locationand version are optional. If you specify no argument forthe location, the system uses the currently plannedlocation. However, it is better for performance reasons touse the function ACT_LOCATION.

LOC_EXTRA_SET() LOG_EXTRA_SET( n ; 'field_value' ; <'location'> ;'<version>' ) sets the value of an extra field in the locationmaster record for the specified location in the specifiedversion, where n represents the number of the extra fieldand 'field_value' represents the character or numericalvalue you want to give the field. Enter a numerical valuewithout single inverted commas. The arguments forlocation and version are optional. If you specify noargument for the location, the system uses the currentlyplanned location. However, it is better for performancereasons to use the function ACT_LOCATION.

LOC_SET() LOC_SET( ‘field name’ ; 'field_value' ; <'location'> ;'<version>' ) sets the value of the specified field in thelocation master record for the specified location in thespecified version. The arguments for location and versionare optional. If you specify no argument for the location,the system uses the currently planned location. However,it is better for performance reasons to use the functionACT_LOCATION.

Page 37: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 37

LOCATION_TYPE() LOCATION_TYPE ( 'location' ) returns the location type ofthe location in the argument, for exampleACT_LOCATION.

MAT() MAT( 'FIELD_NAME' ; <'product'> ; <'version'> ) returnsthe content of a numerical field in the product masterrecord of the specified product. MAT( 'BRGEW' ;ACT_PRODUCT ) returns the gross weight of the currentproduct. The arguments for product and version areoptional. If you specify no argument for the product, thesystem uses the currently planned product. However, it isbetter for performance reasons to use the functionACT_LOCATION.

MAT_C() MAT_C( 'FIELD_NAME' ; <'product'> ; <'version'> )returns the content of a character field in the productmaster record of the specified product. The arguments forproduct and version are optional. If you specify noargument for the product, the system uses the currentlyplanned product. However, it is better for performancereasons to use the function ACT_PRODUCT. Forexample, MAT_C( 'KOSCH' ; ACT_PRODUCT ) returnsthe product allocation procedure for the current product.

MAT_EXTRA() MAT_EXTRA( n ; <'product'> ; <'version'> ) gets thevalue of an extra field in the product master record for thespecified product in the specified version, where nrepresents the number of the extra field. The argumentsfor product and version are optional. If you specify noargument for the product, the system uses the currentlyplanned product. However, it is better for performancereasons to use the function ACT_PRODUCT. Forexample, MAT_EXTRA( 1 ; ACT_PRODUCT ) gets thevalue in extra field 1 for the currently planned product.

MAT_EXTRA_SET() MAT_EXTRA_SET( n ; 'field_value' ; <'product'> ;'<version>' ) sets the value of an extra field in the productmaster record for the specified product in the specifiedversion, where n represents the number of the extra fieldand 'field_value' represents the character or numericalvalue you want to give the field. Enter a numerical valuewithout single inverted commas. The arguments forproduct and version are optional. If you specify noargument for the product, the system uses the currentlyplanned product. However, it is better for performancereasons to use the function ACT_PRODUCT.

MAT_SET() MAT_SET ( ‘field name’ ; field_value' ; <'product'> ;'<version>' ) sets the value of the specified field in theproduct master record for the specified product in thespecified version. The arguments for product and versionare optional. If you specify no argument for the product,the system uses the currently planned product. However,it is better for performance reasons to use the functionACT_PRODUCT.

MATLOC() MATLOC( 'FIELD_NAME' ; <'product'> ; <'location'> ;<'version'> ) returns the content of a numerical field in thelocation/product master record of the specified productand location. The arguments for the product, location andversion are optional. If you specify no argument for theproduct and/or location, the system uses the current

Page 38: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 38

product/location. However, it is better for performancereasons to use the functions ACT_LOCATION aYYndACT_PRODUCT. For example, MATLOC( 'BSTMA' ;ACT_PRODUCT ; ACT_LOCATION ) returns themaximum lot size for this location product.

MATLOC_C() MATLOC_C( 'FIELD_NAME' ; <'product'> ; <'location'> ;<'version'> ) returns the content of a character field in thelocation/product master record of the specified productand location. The arguments for product, location andversion are optional. If you specify no argument for theproduct and/or location, the system uses the currentproduct/location. However, it is better for performancereasons to use the functions ACT_LOCATION andACT_PRODUCT. For example, MATLOC( 'BESKZ' ;ACT_PRODUCT ; ACT_LOCATION ) returns theprocurement type for this location product.

MATLOC_EXTRA() MATLOC_EXTRA( n ; <'product'> ; <'location'> ;<'version'> ) gets the value of an extra field in theproduct/location master record for the specified productand location in the specified version, where n representsthe number of the extra field. The arguments for theproduct, location and version are optional. If you specifyno argument for the product and/or location, the systemuses the current product/location. However, it is better forperformance reasons to use the functionsACT_LOCATION and ACT_PRODUCT. For example,MATLOC_EXTRA( 1 ; ACT_PRODUCT ;ACT_LOCATION ) gets the value in extra field 1 for thecurrently planned location product. Use this function fornumeric fields

MATLOC_EXTRA_C() MATLOC_EXTRA( n ; <'product'> ; <'location'> ;<'version'> ) gets the value of an extra character field inthe product/location master record for the specifiedproduct and location in the specified version, where nrepresents the number of the extra character field. Thearguments for the product, location and version areoptional. If you specify no argument for the product and/orlocation, the system uses the current product/location.However, it is better for performance reasons to use thefunctions ACT_LOCATION and ACT_PRODUCT. Forexample, MATLOC_EXTRA( 1 ; ACT_PRODUCT ;ACT_LOCATION ) gets the value in extra character field 1for the currently planned location product.

MATLOC_EXTRA_SET() MATLOC_EXTRA_SET( n ; 'field_value' ; <'product'> ;<'location'> ; '<version>' ) sets the value of an extra field inthe location product master record for the specifiedproduct and location in the specified version, where nrepresents the number of the extra field and 'field_value'represents the character or numerical value you want togive the field. Enter a numerical value without singleinverted commas. The arguments for the product, locationand version are optional. If you specify no argument forthe product and/or location, the system uses the currentproduct/location. However, it is better for performancereasons to use the functions ACT_LOCATION andACT_PRODUCT.

MATLOC_SET() MATLOC_SET(( ‘field name’ ; ; 'field_value' ; <'product'> ;

Page 39: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 39

<'location'> ; '<version>' ) sets the value of the specifiedfield in the location product master record for the specifiedproduct and location in the specified version. Thearguments for the product, location and version areoptional. If you specify no argument for the product and/orlocation, the system uses the current product/location.However, it is better for performance reasons to use thefunctions ACT_LOCATION and ACT_PRODUCT.

MULTILEVEL_DEMAND_MEAN()(SNP)

MULTILEVEL_DEMAND_MEAN( forecast key figure,actual key figure, product, location, version, <period>)returns the sum of demands from all locations in thesupply chain. Values for the future are taken from theforecast key figure, for the past from the actual key figure,in both cases for the given product, location (here forinstance the plant or distribution center for which you areplanning), and version. The entries actual key figure andperiod are not strictly necessary but improve performance,if you use MULTILEVEL_DEMAND_VAR in the samemacro. For more information, see Multilevel Functions inthe Supply Chain Network [Page 44].

MULTILEVEL_DEMAND_VAR()(SNP)

MULTILEVEL_DEMAND_VAR( forecast key figure, actualkey figure, product, location, version, <period> ) returnsthe error variance between the forecast demand andactual demand for all locations in the supply chain. Thisvalue is determined for the whole historical period or theperiod specified. As above you also enter the product,location, and version of interest, for exampleACT_PRODUCT, ACT_LOCATION, and ACT_VERSION.For more information, see Multilevel Functions in theSupply Chain Network [Page 44].

MULTILEVEL_LEAD_MEAN()

(SNP)

MULTILEVEL_LEAD_MEAN( forecast key figure, actualkey figure, product, location, version, <period>) is similarto MULTILEVEL_DEMAND_MEAN(). From a customerview it calculates the lead time for a product in a location.For more information, see Multilevel Functions in theSupply Chain Network [Page 44].

MULTILEVEL_LEAD_VAR()(SNP)

MULTILEVEL_LEAD_VAR( forecast key figure, actual keyfigure, product, location, version, <period> ) returns theerror variance between the forecast lead time and actuallead time for the specified product and location. This valueis determined for the whole historical period or the periodspecified. As above you also enter the product, location,and version of interest, for example ACT_PRODUCT,ACT_LOCATION, and ACT_VERSION. For moreinformation, see Multilevel Functions in the Supply ChainNetwork [Page 44].

PARTNER() PARTNER( NAME ) returns the value 1 if planning iscurrently being done by partner NAME; otherwise, 0. Youenter the name NAME of the partner as an argument in anOperator/function dialog box. Use this function inCollaborative Planning.

PLOBS_FOR_LEVEL() PLOBS_FOR_LEVEL( X ) returns the number of planningobjects on the specified level where X represents theplanning level. For example, PLOBS_FOR_LEVEL( 1 )returns the number of products in the product groupselection if you have first selected a product group and

Page 40: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 40

then drilled down to product level.

PRODUCT_LIFE() PRODUCT_LIFE( X ; <'product'> ) returns the value 1 ifdata is selected for exactly one product and if thespecified date X comes after the phase-in time span andbefore the phase-out time span of the product. Otherwise,a value of 0 is returned. For example, PRODUCT_LIFE (DATE ( 20010220 ) ) returns the value 1 if the product isin its growth or maturity phase on February 20th, 2001.The argument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table. The argument for product is optional.

PRODUCT_PHIN_END orPRODUCT_PHIN_END()

PRODUCT_PHIN_END( <'GRID=2'> ; <'product'> )returns the end date of the specified product's launchphase as maintained for the phase-in profile in the productmaster record. The arguments for grid 2 and product areoptional. If you do not specify a product, the systemreturns the end date of the phase-in time span of thecurrently planned product. However, for performancereasons, SAP recommends that you use the functionACT_PRODUCT to represent the current product.

PRODUCT_PHIN_START orPRODUCT_PHIN_START()

PRODUCT_PHIN_START( <'GRID=2'> ; <'product'> )returns the start date of the specified product's launchphase as maintained for the phase-in profile in the productmaster record. The arguments for grid 2 and product areoptional. If you do not specify a product, the systemreturns the start date of the phase-in time span of thecurrently planned product. However, for performancereasons, SAP recommends that you use the functionACT_PRODUCT to represent the current product.

PRODUCT_PHOUT_END orPRODUCT_PHOUT_END()

PRODUCT_PHOUT_END( <'GRID=2'> ; <'product'> )returns the end date of the specified product's declinephase as maintained for the phase-out profile in theproduct master record. The arguments for grid 2 andproduct are optional. If you do not specify a product, thesystem returns the end date of the phase-out time span ofthe currently planned product. However, for performancereasons, SAP recommends that you use the functionACT_PRODUCT to represent the current product.

PRODUCT_PHOUT_START orPRODUCT_PHOUT_START()

PRODUCT_PHOUT_START( <'GRID=2'> ; <'product'> )returns the start date of the specified product's declinephase as maintained for the phase-out profile in theproduct master record. The arguments for grid 2 andproduct are optional. If you do not specify a product, thesystem returns the start date of the phase-out time spanof the currently planned product. However, forperformance reasons, SAP recommends that you use thefunction ACT_PRODUCT to represent the current product.

RESOURCE_COST() RESOURCE_COST( 'resource' ; 'resource variant' ;DATE ) returns the cost of the specified resource for thespecified capacity variant on the specified date.

RESOURCE_EDIT() RESOURCE_EDIT( 'resource' ; 'version' ) returns thevalue ' X ' if the resource can be edited in the specifiedversion, ' ' if it cannot.

RESOURCE_OVERLOAD() RESOURCE_OVERLOAD( 'resource' ; 'version' ) returnsthe resource overload for the specified resource in the

Page 41: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 41

specified version. For example,RESOURCE_OVERLOAD ( ACT_RESOURCE ;ACT_VERSION ) might return 10%.

RESOURCE_RESTYPE() RESOURCE_RESTYPE( 'resource' ; 'version' ) returnsthe resource type of the specified resource in the specifiedversion. For example, RESOURCE_RESTYPE(ACT_RESOURCE ; ACT_VERSION ) returns resourcetype 'P', 'T', 'S' or 'H' (production, transportation, storageor handling) for the current resource in the current version.

RESOURCE_UNDERLOAD() RESOURCE_UNDERLOAD( 'resource' ; 'version' )returns the resource underload for the specified resourcein the specified version. For example,RESOURCE_UNDERLOAD ( ACT_RESOURCE ;ACT_VERSION ) might return 10%.

RESOURCE_UNIT() RESOURCE_UNIT ( 'resource' ; 'version' ) returns the unitfor the resource that is contained in the resource masterrecord in the specified version.

RESOURCE_VARIANT() RESOURCE_VARIANT( 'version' ; 'resource_variant' ;'from_date' ; 'to_date' ) returns the available capacity forthe specified resource variant in the specified time span.

SUM_CALC() SUM_CALC( key figure ) calculates the sum of all detaillevels of the specified key figure.

TIMESHIFT_BACKWARDS() TIMESHIFT_BACKWARDS(

X1 ; ... ; Xn ; Y1 ; ... ; Yn ) shifts the values of time seriesX1 through Xn backward in time by the number of periodsgiven in time series Y1 through Yn. For example,

the time series look like this: X 10 20 30 40 50Y 1 2 1 3 1.The result looks like this:

30 40 30 - 50 -

The value 10 is shifted back 1 period in time, the value 20is shifted back 2 periods in time, and so on.

TIMESHIFT_FORWARDS() TIMESHIFT_FORWARDS( X1 ; ... ; Xn ; Y1 ; ... ; Yn )shifts the values of time series X1 through Xn forward intime by the number of periods given in time series Y1through Yn. For example, the time series look like this:X 10 20 30 40 50Y 1 3 1 2 1.

The result looks like this: 10 - 30 20 90The value 10 is shifted forward 1 period in time, the value20 is shifted forward 3 periods in time, and so on

TS_GET() TS_GET( 'TS_TYPE' ; 'key_value_1' ; 'key_value_2' ;'key_value_3' ; <value_from> ; <value_to> ) reads thevalues of a database time series where 'TS_TYPE'defines the time series type, the second, third and fourtharguments represent the values from the 3 possible keyfields of the time series, and the fifth and sixth arguments(which are optional) define the value range that you wantto read.

Page 42: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 42

The mandatory fields have the following types:

TSTYPE = CHAR 20key_value1 = CHAR 60key_value2 = CHAR 60key_value3 = CHAR 60

Example: A time series with ID 'I'', 'A' ; 'B' ; 'C' is

Pos 1 2 3 4 5 6 78 9

Value 10 10 20 30 50 5060 90 120.

TSGET ( ''I'', 'A' ; 'B' ; 'C' ; 2 ; 9 ) returns10 20 30 50 50 60 90

120

Use an area as the macro result element.

TS_SET() TS_SET( 'TS_TYPE' ; 'key_value_1' ; 'key_value_2' ;'key_value_3' ; offset_value ; Y1 ; ... ; Yn ) writes valuesto a database time series where 'TS_TYPE' defines thetime series type, the second, third and fourth argumentsrepresent the values from the 3 possible key fields of thetime series, the fifth argument defines the period offset(for example, 5 = starting in column 5), and Y1 through Yndefine the row, column, cell or area to which you want towrite the values.

VALUE_CONTAINED() VALUE_CONTAINED( value ; range ) returns the value 1if the value is contained in the specified range.

W_AVG_CALC() W_AVG_CALC( key figure with values ; key figure withweighting factors ) calculates the weighted average of thefirst key figure using the weighting factors given in thesecond key figure.

Page 43: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 43

Multilevel Functions in the Supply Chain NetworkThese four functions enable you to determine statistical values for use with multilevelscenarios.

20

40

100 150 130

Customers

Supplier

Distribution center with own consumption

In the above graphic example, the figures represent the planned consumption of a product atdifferent levels in the supply chain for one particular period. As well as aggregating thedemand from the lower levels the locations also have their own consumption.

The function MULTILEVEL_DEMAND_MEAN forms the sum of these planned demands, inthis case 100 + 150 + 130 + 40 + 20 = 440.

The function MULTILEVEL_DEMAND_VAR determines the error variance between theplanned and actual values for the whole specified period or if you have not specified a period,the complete past.

(Error variance = 2)( ii i XaXp −∑ where iXp and iXa are the planned and actual values

respectively.)

Page 44: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 44

Suppliers

Customer

3 days

2 days

2 days

4 days2 days

The function MULTILEVEL_LEAD_MEAN calculates the planned lead time for a customer toa receive a product in the period. The system always uses the longest lead time, that is thevalues from the critical path. The system considers the time from the customer back to thenext location that has safety stock. In the above graphic the value would be 6 days.

The function MULTILEVEL_LEAD_VAR determines the error variance between the plannedand actual values for the whole specified period or if you have not specified a period, thecomplete past.

(Error variance = 2)( ii i XaXp −∑ where iXp and iXa are the planned and actual values

respectively.)

Page 45: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 45

Date FunctionsFunction Explanation

ALERT_BDATE() ALERT_BDATE( ALERT ) returns the start date of theearliest valid alert/status of the alert/status type specifiedby ALERT for the current selection. The argument of thisfunction is an alert/status element..

ALERT_EDATE() ALERT_EDATE( ALERT ) returns the finish date of thelatest valid alert/status of the alert/ status type specified byALERT for the current selection. The argument of thisfunction is an alert/status element.

BUCKET_BDATE() BUCKET_BDATE( X1 ; ... ; Xn ) returns the earliestpossible start date of the periods given by the cell(s),row(s) and/or column(s) (not areas) X1 through Xn of theplanning table or the auxiliary table. This date isexpressed as an integer with reference to the date0001/01/01. In the attributes of the argument elements,you must specify Period data as the data source.

BUCKET_DATE_IN() BUCKET_DATE_IN( X ; Y1 ; ... ; Yn ) returns 1 if date Xfalls within the periods given by the cell(s), row(s) and/orcolumn(s) (not areas) Y1 through Yn. Otherwise, 0 isreturned. The date X (for example, the function TODAY orDATE() ) is expressed as an integer with reference to thedate 0001/01/01. The argument can be either a numberthat you enter in an Operator/function dialog box or oneof the macro elements cell, row or column from theplanning table or auxiliary table. In the attributes of theargument elements Y1 through Yn, you must specifyPeriod data as the data source.

BUCKET_DAYS() BUCKET_DAYS( X1 ; ... ; Xn ) returns the number ofGregorian calendar days of the periods given by thecell(s), row(s) and/or column(s) (not areas) X1 throughXn. In the attributes of the argument elements, you mustspecify Period data as the data source.

BUCKET_EDATE()_

BUCKET_EDATE( X1 ; ... ; Xn ) returns the latest finishdate of the periods given by the cell(s), row(s) and/orcolumn(s) (not areas) X1 through Xn. This date isexpressed as an integer with reference to the date0001/01/01. In the attributes of the argument elements,you must specify Period data as the data source.

BUCKET_FISCAL_PERIOD() see FISCAL_PERIOD()

BUCKET_WDAYS() BUCKET_WDAYS( <calendar> ; X1 ; ... ; Xn) returns thenumber of workdays in the periods given by the cell(s),row(s), and/or column(s) (not areas) X1 through Xn. Inthe attributes of the argument elements, you must specifyPeriod data as the data source. The specification of acalendar as the first argument is optional. If you do notspecify a calendar, the system reads the calendar givenby the time stream in the storage buckets profile. If notime stream is defined, the system uses calendar days.

CALENDAR_WDAYS CALENDAR_WDAYS( ‘calendar’ ; from date ; <to date> )returns the number of workdays between the from dateand the to date in the calendar specified. The calendar is

Page 46: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 46

the timestream ID.

DATE() DATE( YYYYMMDD ) returns the integer value whichcorresponds to the number of days between 0001/01/01and the specified date. You enter the date YYYYMMDD inthe format YYYYMMDD in an Operator/function dialogbox. For example, DATE( 19990101 ) = 729756. Use thisfunction in order to include a fixed, known date in a macro.

DAY() DAY( X ) returns the day of a date that is expressed ininteger format with reference to the date 0001/01/01. Forexample, DAY( DATE( 19990220 )) = 20. The argumentcan be either a number that you enter in anOperator/function dialog box or one of the macroelements cell, row or column from the planning table orauxiliary table.

FISCAL_BDATE() FISCAL_BDATE( X;<fiscal year variant>) returns the startof the posting period contains the date X expressed ininteger format with reference to the date 0001/01/01. Youcan enter the date as DATE ( 19990101 ) or using otherdate functions such as BUCKET EDATE(). The optionalsecond argument specifies the fiscal year variant.

FISCAL_EDATE() FISCAL_EDATE( X;<fiscal year variant>) returns the endof the posting period containing the date X expressed ininteger format with reference to the date 0001/01/01. Youcan enter the date as DATE ( 19990101 ) or using otherdate functions such as BUCKET EDATE(). The optionalsecond argument specifies the fiscal year variant.

FISCAL_PERIOD() FISCAL_PERIOD(X) returns the number of the postingperiod specified by column X.

FISCAL_YEAR FISCAL_YEAR (X) returns the fiscal year of the periodspecified by column X.

MONTH() MONTH( X ) returns the month of a date X that isexpressed in integer format with reference to the date0001/01/01. For example, MONTH( DATE ( 19990220 )returns 2. The argument can be either a number that youenter in an Operator/function dialog box, or one of themacro elements cell, row or column from the planningtable or the auxiliary table.

MONTH_BDATE() MONTH_BDATE( X ) returns the start date of the monthgiven in the argument in integer format with reference tothe date 0001/01/01.

MONTH_EDATE() MONTH_EDATE( X ) returns the finish date of the monthgiven in the argument in integer format with reference tothe date 0001/01/01.

PRODUCT_PHIN_END orPRODUCT_PHIN_END()

PRODUCT_PHIN_END( <'GRID=2'> ; <'product'> )returns the end date of the specified product's launchphase as maintained for the phase-in profile in the productmaster record. The arguments for grid 2 and product areoptional. If you do not specify a product, the systemreturns the end date of the phase-in time span of thecurrently planned product. However, for performancereasons, SAP recommends that you use the functionACT_PRODUCT to represent the current product.

PRODUCT_PHIN_START orPRODUCT_PHIN_START()

PRODUCT_PHIN_START( <'GRID=2'> ; <'product'> )returns the start date of the specified product's launch

Page 47: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 47

phase as maintained for the phase-in profile in the productmaster record. The arguments for grid 2 and product areoptional. If you do not specify a product, the systemreturns the start date of the phase-in time span of thecurrently planned product. However, for performancereasons, SAP recommends that you use the functionACT_PRODUCT to represent the current product.

PRODUCT_PHOUT_END orPRODUCT_PHOUT_END()

PRODUCT_PHOUT_END( <'GRID=2'> ; <'product'> )returns the end date of the specified product's declinephase as maintained for the phase-out profile in theproduct master record. The arguments for grid 2 andproduct are optional. If you do not specify a product, thesystem returns the end date of the phase-out time span ofthe currently planned product. However, for performancereasons, SAP recommends that you use the functionACT_PRODUCT to represent the current product.

PRODUCT_PHOUT_START orPRODUCT_PHOUT_START()

PRODUCT_PHOUT_START( <'GRID=2'> ; <'product'> )returns the start date of the specified product's declinephase as maintained for the phase-out profile in theproduct master record. The arguments for grid 2 andproduct are optional. If you do not specify a product, thesystem returns the start date of the phase-out time spanof the currently planned product. However, forperformance reasons, SAP recommends that you use thefunction ACT_PRODUCT to represent the current product.

TIMESHIFT_BACKWARDS() TIMESHIFT_BACKWARDS(

X1 ; ... ; Xn ; Y1 ; ... ; Yn ) shifts the values of time seriesX1 through Xn backward in time by the number of periodsgiven in time series Y1 through Yn. For example,

the time series look like this: X 10 20 30 40 50Y 1 2 1 3 1.The result looks like this:

30 40 30 - 50 -

The value 10 is shifted back 1 period in time, the value 20is shifted back 2 periods in time, and so on.

TIMESHIFT_FORWARDS() TIMESHIFT_FORWARDS( X1 ; ... ; Xn ; Y1 ; ... ; Yn )shifts the values of time series X1 through Xn forward intime by the number of periods given in time series Y1through Yn. For example, the time series look like this:X 10 20 30 40 50Y 1 3 1 2 1.

The result looks like this: 10 - 30 20 90The value 10 is shifted forward 1 period in time, the value20 is shifted forward 3 periods in time, and so on

TODAY TODAY returns today's date in integer format withreference to the date 0001/01/01. For example, you canuse this function as the argument of another function:

DAY ( TODAY )

WEEK ( TODAY )

MONTH ( TODAY )

Page 48: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 48

PRODUCT_LIFE ( TODAY )

WEEKDAY ( TODAY )

WEEK_BDATE( TODAY )

WEEK_EDATE( TODAY )

YEAR ( TODAY )

YEAR_BDATE( TODAY )

YEAR_EDATE( TODAY )

BUCKET_DATE_IN ( TODAY ; ... )

WEEK() WEEK( X ) returns the week of a date X that is expressedin integer format with reference to the date 0001/01/01.For example, WEEK( DATE ( 20001220 ) returns 51. Theargument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table.

WEEK_BDATE() WEEK_BDATE( X ) returns the start date of the week inwhich the specified day X falls. For example, if today'sdate is Wednesday, December 20th in the year 2000,WEEK_BDATE( TODAY ) returns 20001218.

WEEK_EDATE() WEEK_EDATE( X ) returns the end date of the week inwhich the specified day X falls. For example, if today'sdate is Wednesday, December 20th in the year 2000,WEEK_EDATE( TODAY ) returns 20001224.

YEAR_BDATE() YEAR_BDATE( X ) returns the start date of the year inwhich the specified day X falls. For example, if today'sdate is Wednesday, December 20th in the year 2000,YEAR_BDATE( TODAY ) returns 20000101.

YEAR_EDATE() YEAR_EDATE( X ) returns the end date of the year inwhich the specified day X falls. For example, if today'sdate is Wednesday, December 20th in the year 2000,YEAR_EDATE( TODAY ) returns 20001231.

WEEKDAY() WEEKDAY( X ) returns as a number between 1 and 7 theweekday of a date that is expressed in integer format withreference to the date 0001/01/01, where 1 = Monday and7 = Sunday. For example, for January 20th 1999WEEKDAY( DATE( 19990120 ) ) returns 3. The argumentcan be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table.

YEAR() YEAR( X ) returns the year of a date that is expressed ininteger format with reference to the date 0001/01/01. Forexample, for January 20th 1999 YEAR( DATE ( 19990120) ) returns 1999. The argument can be either a numberthat you enter in an Operator/function dialog box, or oneof the macro elements cell, row or column from theplanning table or the auxiliary table.

Page 49: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 49

General and Planning Table Functions

Function Explanation

CELL_BG() CELL_BG( X ) sets the background color of a cell to: blackif X = 0, blue if X = 1, white if X = 2, yellow if X = 3, cyan ifX = 4, green if X = 5, red if X = 6, magenta if X = 7, deepblue if X = 8, gray if X = 9, bright yellow if X = 10, intensivecyan if X = 11, intensive green if X = 12, deep red if X =13, deep magenta if X = 14. The argument can be a cell,a row or a column of the planning table. You can applythis function to a row, column or cell of the planningtable. In the attributes of the row/column/ cell you must setthe Scope of change to Attributes. For example,Macro1 |----- Step1 (1 iteration)|----- CELL ( sales ; period )|----- Cell_BG( 6 )

CELL_FG() CELL_FG( x ) sets the foreground color of a cell to: blackif X = 0, blue if X = 1, white if X = 2, yellow if X = 3, cyan ifX = 4, green if X = 5, red if X = 6, magenta if X = 7, deepblue if X = 8, gray if X = 9, bright yellow if X = 10, intensivecyan if X = 11, intensive green if X = 12, deep red if X =13, deep magenta if X = 14. The argument can be a cell,a row or a column of the planning table. You can applythis function to a row, column or cell of the planningtable. In the attributes of the row/column/ cell you must setthe Scope of change to Attributes. For example,Macro1|----- Step1 ( 1 iteration )|----- CELL ( sales ; period )|----- Cell_FG( 6 )

CELL_INPUT() CELL_INPUT( X ) sets the input status of a cell. If X = 1,the status of the cell is set to ready-for-input. If X = 0, thestatus of the cell is set to read-only. The argument can beeither a number that you enter in an Operator/functiondialog box, or one of the macro elements cell, row orcolumn from the planning table or the auxiliary table. Youcan apply this function to a row or cell. In the attributes ofthe row or cell, set the Scope of change to Attributes.

CELL_LICON() CELL_LICON( x ) displays the icon x to the left of the celltext. Twenty-nine icons are available:1 = Activity2 = Alert3 = Warehouse4 = Customer 5 = Customer warehouse6 = Distribution center7 = Planning level8 = Hint9 = Location10 = Product11 = Model12 = Operation13 = Order

Page 50: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 50

14 = Plant15 = Product group16 = Relationship17 = Resource18 = Store location19 = Supplier20 = Transportation mode21 = Transportation point22 = Warning23 = Filter24 = Sum25 = Grid OCX26 = User27 = Locked28 = Zoom in29 = Zoom out

Setting X = 0 deletes any existing icon. If you only want toset or delete an icon in Grid2, add 200 to the valuedetermined above.

CELL_RICON() CELL_RICON( x ) displays the icon x to the right of thecell text. Twenty-nine icons are available: 1 = Activity2 = Alert3 = Warehouse4 = Customer 5 = Customer warehouse6 = Distribution center7 = Planning level8 = Hint9 = Location10 = Product11 = Model12 = Operation13 = Order14 = Plant15 = Product group16 = Relationship17 = Resource18 = Store location19 = Supplier20 = Transportation mode21 = Transportation point22 = Warning23 = Filter24 = Sum25 = Grid OCX26 = User27 = Locked28 = Zoom in29 = Zoom out

Setting X = 0 deletes any existing icon. If you only want toset or delete an icon in Grid2, add 200 to the valuedetermined above

CHAR_VALUES_INPUT() CHAR_VALUES_INPUT ( 'dialog_box_description' ;'field_label_1' ; ... ; 'field_label_n' ) prompts the user toenter n character strings in a dialog box that appearsautomatically when this function is executed. A maximumof 10 character strings can be entered. Thus, you canhave a maximum of 11 arguments for this function. As the

Page 51: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 51

first argument you specify the text that will appear in thetitle bar of the dialog box. Write this text in single invertedcommas with underscores between each word. As theother arguments, you specify the field labels for the fieldsin which the user will enter the character strings.

COL_INPUT() COL_INPUT( X ) sets the input status of a column. If X =1, the status of the column is ready for input. If X = 0, thestatus of the column is read-only. The argument can beeither a number that you enter in an Operator/functiondialog box, or one of the macro elements cell, row orcolumn in the planning or auxiliary table. You can applythis function to a column or cell of the planning table. Inthe attributes of the column or cell, set the Scope ofchange to Attributes. This applies to Grid 1. To refer toGrid 2 use X = 20 for read-only, and X = 21 for ready forinput. Similarly X = 10 and X = 11 to refer just to GRID 1.

COL_LICON() Displays the icon x to the left of the column text. Twenty-nine icons are available (see CELL_LICON). In theattributes of the column, set the Scope of change toAttributes.

COL_RICON() Displays the icon x to the right of the column text. Twenty-nine icons are available (see CELL_RICON). In theattributes of the column, set the Scope of change toAttributes.

COL_VISIBLE() COL_VISIBLE( X ) sets the visibility of a column. If X = 1,the column is visible. If X = 0, the column is not visible.The argument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column in the planning or auxiliarytable. You can apply this function to a column or cell ofthe planning table. In the attributes of the column or cell,set the Data source to Attributes. This applies to Grid 1.To refer to Grid 2 use X = 20 for read-only, and X = 21 forready for input. Similarly X = 10 and X = 11 to refer just toGRID 1.

COLUMN_MARKED() COLUMN_MARKED returns the value 1 if the columnspecified in the argument has been selected. Otherwisethe value is 0. In the attributes of the row or cell, set theData source to Row Attributes.

CURR_CONV_FAC() CURR_CONV_FAC( 'source currency' ; 'target currency' ;'exchange rate type' ; DATE ) returns the currencyconversion factor for the specified source currency, targetcurrency and exchange rate type on the specified date.This date can be TODAY (that is, the system date) oranother date (see the functions DATE() and TODAY).TODAY is a function, so you do not need to put it ininverted commas. Example: CURR_CONV_FAC( 'USD' ;'EUR' ; 'M' ; TODAY ).

DATA_IS_LOCKED DATA_IS_LOCKED returns the value 1, if the data islocked for the current user, meaning they can edit thedata. It returns the value 0, if the data is locked by anotheruser, meaning the current user cannot edit the data.

DISPLAY_CONV_FACTOR() DISPLAY_CONV_FACTOR (Row) returns the conversionfactor between the unit in which the data is storedinternally and the unit in which it is displayed for the row.For example, time data may be stored in LiveCache in

Page 52: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 52

seconds but it is displayed in the planning table in hours.DISPLAY_CONV_FACTOR would then return 3600 In theattributes of the row or cell, set the Data source to RowAttributes.

EVAL() EVAL() is an auxillary function for constructing morecomplicated functions. EVAL() evaluates the arithmeticexpression in the argument so that this result can be usedin another function. The argument can be either a numberthat you enter in an Operator/function dialog box, or oneof the macro elements cell, row or column in theplanning or auxiliary table.

Use this function to calculate the argument of otherfunctions at runtime.

For example EVAL ( ( 1 + 2 ) * 3 ) = 9

HELPTAB_CLEAR HELPTAB_CLEAR initializes the values in the auxiliarytable. You can use this function anywhere in a macro. Ifyou wish to initialize the values in the auxiliary table at thebeginning of a macro, leave unchecked the macroattribute Do not initialize auxiliary table.

MARKED_COLUMN() orMARKED_COLUMN

MARKED_COLUMN(<'FIRST/LAST'>) returns the columnnumbers of all marked columns. If 'FIRST' or 'LAST' isincluded as an argument, the function returns the first orlast marked column in the time series. 'FIRST' and 'LAST'are the only possible arguments.

MARKED_FIXED_COLS MARKED_FIXED_COLS returns the numbers of themarked fixed columns

MARKED_FIXED_ROWS MARKED_FIXED_ROWS returns the numbers of themarked fixed rows

MARKED_PLOB MARKED_PLOB returns the internal planning objectnumber of the marked rows. Using this number has theadvantage in comparison to the row number that thisnumber remains constant irrespective of where the objectappears in the grid.

MARKED_ROW() orMARKED_ROW

MARKED_ROW(<'FIRST/LAST'>) returns the rownumbers of all marked rows. If 'FIRST' or 'LAST' isincluded as an argument, the function returns the first orlast marked row. 'FIRST' and 'LAST' are the only possiblearguments.

NUM_VALUES_INPUT() NUM_VALUES_INPUT ( 'dialog_box_description' ;'field_label_1' ; ... ; 'field_label_n' ) prompts the user toenter n numerical values in a dialog box that appearsautomatically when this function is executed. As the firstargument you specify the text that will appear in the titlebar of the dialog box. Write this text in single invertedcommas with underscores between each word or use thefunction STRING_CONCATENATE () . As the otherarguments, you specify the field labels for the fields inwhich the user will enter the numerical values. Amaximum of 10 numerical values can be entered. Thus,you can have a maximum of 11 arguments for thisfunction.

NUMBER() NUMBER( E1 ; ... ; En ) returns the total number of cells inthe macro elements E1 through En. E1 through En can becell(s), row(s), column(s) and/or area(s) from either the

Page 53: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 53

planning table or the auxiliary table.For insatnce, you can use this function to determine thenumber of time buckets in the current grid.

OUTPUT_POPUP OUTPUT_POPUP('dialog_box_description' ;'field_label_1' ; value in field 1 ; ... ; 'field_label_10' ; valuein field 10 ) opens a dialog box that shows thealphanumeric or numerical values of extra fields in theproduct and/or location master record. A maximum of 10field values can be displayed in this box.

PLOB_DATA_VISIBLE() PLOB_DATA_VISIBLE( X; 'planning object'...'planningobject n' ) sets the visibility of the specified planningobject(s). You use this function if you are are working withdrill-down in the Details (all) view. If X =1 the planningobjects are displayed. If X=0 the planning objects arehidden. Use functions ACT_PLOB, MARKED_PLOB, orKEYFS_PLOB to specify the planning objects.

PLOB_MARKED() PLOB_MARKED returns the value 1 if the planning objectspecified in the argument has been selected. Otherwisethe value is 0. Use functions ACT_PLOB,MARKED_PLOB, or KEYFS_PLOB to specify theplanning objects.

REPORT_SUBMIT() REPORT_SUBMIT( 'program_name' ; <'job_name'> ;<'job_number'>; <'newmode'>) causes the specifiedprogram to be executed. Use the optional arguments, jobname and job number, if you wish the program to run inthe background. If you set the argument 'newmode', theresults are displayed in a new window.

ROW_BG() ROW_BG( X ) sets the background color of a row to:

black if X = 0

blue if X = 1

white if X = 2

yellow if X = 3

cyan if X = 4

green if X = 5

red if X = 6

magenta if X = 7

deep blue if X = 8

gray if X = 9

bright yellow if X = 10

intensive cyan if X = 11

intensive green if X = 12

deep red if X = 13

deep magenta if X = 14

The argument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table. You can apply this function to a row orcell. In the attributes of the row or cell, set the Scope ofchange to Attributes.

Page 54: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 54

ROW_FG() ROW_FG( X ) sets the foreground color of a row to:

black if X = 0

blue if X = 1

white if X = 2

yellow if X = 3

cyan if X = 4

green if X = 5

red if X = 6

magenta if X = 7

deep blue if X = 8

gray if X = 9

bright yellow if X = 10

intensive cyan if X = 11

intensive green if X = 12

deep red if X = 13

deep magenta if X = 14

The argument can be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table. You can apply this function to a row orcell. In the attributes of the row or cell, set the Scope ofchange to Attributes.

ROW_INPUT() ROW_INPUT( X ) sets the input status of a row. If X = 1,the status of the cell is set to ready-for-input. If X = 0, thestatus of the cell is set to read-only. The argument can beeither a number that you enter in an Operator/functiondialog box, or one of the macro elements cell, row orcolumn from the planning table or the auxiliary table. Youcan apply this function to a row or cell. In the attributes ofthe row or cell, set the Scope of change to Attributes.

ROW_LICON() Displays the icon X to the left of the row text. Twenty-nineicons are available (see CELL_LICON).

ROW_MARKED() ROW_MARKED returns the value 1 if the row specified inthe argument has been selected. Otherwise the value is 0.

ROW_RELIEF() ROW_RELIEF ( X ) sets the contrast status of a row. If X= 1, the row is thrown into relief; that is, it stands out incontrast to the other rows. The argument can be either anumber that you enter in an Operator/function dialogbox, or one of the macro elements cell, row or columnfrom the planning table or the auxiliary table. You canapply this function to a row or a cell. In the attributes of therow or cell, set the Scope of change to Attributes.

ROW_RICON() Displays the icon X to the right of the row text. Twenty-nine icons are available (see CELL_RICON).

ROW_VALUES_CHANGED() ROW_VALUES_CHANGED( X ) returns 1 if the user haschanged one or more values in row X in the currentplanning session since last pressing Enter. In theattributes of the row, enter Row Attributes as the data

Page 55: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 55

source.

ROW_VISIBLE() ROW_VISIBLE( X ) sets the visibility of a row. If X = 1, therow is visible. If X = 0, the row is not visible. The argumentcan be either a number that you enter in anOperator/function dialog box, or one of the macroelements cell, row or column from the planning table orthe auxiliary table. You can apply this function to a row ora cell. In the attributes of the row or cell, set the Scope ofchange to Attributes.

STRINGS_CONCTENATE() STRINGS_CONCTENATE('string1'...'stringn') insertsblanks between several character strings to produce onestring.

TRANSPORT_COST() TRANSPORT_COST( 'product' ; 'from_location' ;'to_location' ; 'shipment_type' ; 'version' ) returns the costof transporting the specified product from one location toanother, using the specified shipment type.

UNIT_CONV_FAC() UNIT_CONV_FAC( NAME1 ; NAME2 ) returns theconversion factor for conversion from unit NAME1 to unitNAME2. You enter the names of the units inOperator/function dialog boxes; for example,UNIT_CONV_FAC ( KG ; TO ) = 1000.

USER() USER( NAME ) = 1 if the user name of the person whologged on is NAME; for example, USER( SUCHANEK ) =1 if the logon name of the planner is Suchanek.Otherwise, USER( SUCHANEK ) = 0. You enter theargument in an Operator/function dialog box.

VALUE_OF_ROW_CHANGED() VALUE_OF_ROW_CHANGED( X ; Y1 ; ... Yn ) returns 1if the user has changed one or more key figure values incolumns Y1 through Yn of row X in the current planningsession since last pressing Enter. In the attributes of therow, enter Row Attributes as the data source..

Page 56: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 56

Attributes of Macro Elements

UseYou can change the attributes of the various macro elements (macros, steps, conditions etc.).The attributes that can be edited vary with the element type and include the periods for whichthe element is valid and additional functions.

FeaturesIn every macro element you can change the name in the attributes.

Macro

Here you specify:

• Whether the macro can be executed directly

• Whether a confirmation prompt appears when you execute the macro

• Whether the auxiliary table is initialized when you call up the macro

If the auxiliary table is not initialized when you call up the macro, any values that arein the table from the execution of previous macros remain in the table and can beused in the current macro. All entries in the auxiliary table are lost when you leave theplanning book.

• The level at which the macro operates

The level is defined by the current drill-down situation. This means in interactiveplanning that the aggregate level is the level at which you enter the planning book bymaking a selection. If you then drill-down on characteristic A, this is level 1. If yousubsequently drill-down on a further characteristic B, this is level 2. In batch mode thedrill-down situation is controlled by the macro functions DRILL_DOWN() andDRILL_UP() – see Functions Related to Info Objects and Planning Book [Page 32].

• Whether cells that have no entries (initial) are left blank or receive the value "0". Toimprove performance, we recommend that you set this indicator.

You can also assign the macro an icon that appears in the planning table. You can thenexecute the macro by clicking on this icon.

You also see whether if the macro is used as a standard macro [Page 60] and if so, whichtype and at which position the macro appears in the list for the relevant type (start, exit, levelchang, or default).

You can also define collective macros that consist of other macros in the planning book.These macros are then performed automatically in the given order.

You define a macro as a collective macro when you create it, by setting theMacro type field to Collective macro. If you have already assigned other elements(steps, conditions etc.) to it, you can no longer change a macro to a collectivemacro.

Step

In the step attributes you primarily define the time period to which the step applies. You canspecify that it applies to:

• The whole period

• The past

• The future

Page 57: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 57

• Freely definable. Here you can enter existing time buckets or columns. This means thatthe position of the column in the table remains constant, the dates may move. Forexample, the macro applies to the second time bucket in the future to the tenth timebucket in the future.

• Date dependent. Here the time buckets are selected that contain the specified dates. Thedates remain constant and the time bucket may change. For example, the macro appliesfrom 01/01/2001 through 06/30/2001. You can specify whether the date has to be at thestart of a time bucket or whether it only has to be in a time bucket.

• Whether the columns at the start and end are adjusted automatically.

ActivitiesWhen you create a new macro element the attribute dialog box appears automatically. Youcan access it later via the context menu, or by double-clicking on the element in the workarea.

Page 58: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 58

Standard Macros

DefinitionA standard macro is a macro that is executed automatically; its execution is not triggeredmanually by the planner.

A standard macro is one of the following types:

• Default

A default macro is executed when the planner opens the planning desktop andspecifies the selection ID, regenerates the screen (for example, by choosing Enter orTab), or saves the plan.

• Level change

A level change macro is executed when the planner drills up or down in interactiveforecasting.

• Start

A start macro is executed when the planner opens the planning desktop and specifiesthe selection ID.

• Exit

An exit macro is executed when the planner saves the plan. The planning desktop isclosed automatically.

UseTo define a macro as a standard macro:

1. Drag and drop the macro from the macro tree to the appropriate standard macro icon inthe top right area of the MacroBuilder.

2. Set the attribute No direct execution for the macro.

One possible use of standard macros is to calculate the difference between forecasts ofdifferent periods. This is part of the process for Statistical Error Analysis [Ext.].

Page 59: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 59

Forecast Analysis Using Macros

PurposeIn this process, you track predefined situations in the forecast through the use of macros.

PrerequisitesYou have installed the Alert Monitor.

Process FlowThis process flow describes just one way in which you can use macros and alerts to monitorthe forecast.

1. Create a planning book and define in it one or more macros. Attach alerts to the macros;in the macro structure [Page 9] the alert is the result of a condition. For an example, seeExample of a Macro Alert [Page 63].

If you want to display only the current forecasting status after the execution of themacro and delete any previous statuses from the Alert Monitor, set a status alert.

If you want to display the forecasting status after the execution of the macro, and alsoany previous statuses, set a message alert.

2. In the Alert Monitor, create an SDP alert profile.

Alert profiles are used to display specific alerts to specific users. They do not affectwhether or not alerts are created.

3. In interactive demand planning (for mass processing, see below*) assign the alert profileyou created in step 2 by choosing Edit → Assign alert profile. Do not select Forecastdeletes old alerts automatically.

4. For the monitoring of macro alerts in mass processing, see below.

5. Switch to the forecast view of interactive demand planning, using a univariate forecastprofile to create a forecast.

6. Return to the user-defined view, adopting the created forecast.

7. Execute the macro(s).

8. From the workspace toolbar, choose Display/refresh alerts .

The macro alerts appears at the bottom of the screen.

9. Check the macro alerts.

10. Make any necessary adjustments to the forecast model or the forecast results.

11. Run the forecast again.

12. In the user-defined data view, refresh the alerts by choosing Edit → Update alerts.

13. Study the alerts to see if the adjustments you made in step 7 have corrected the problem.

If you created message alerts in step 1, you can compare the alerts that you viewedin step 7 with the new ones. This is the case if you did not select Forecast deletes oldalerts automatically in step 3.

14. Repeat steps 7 through 10 until no more new alerts appear.

* If you are forecasting in the background, continue as follows at step 3:

Page 60: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 60

3. On the Forecast tabstrip of the mass processing activity, specify that alerts are to becreated.

4. If desired, specify that old alerts are to be deleted by this forecast.

If you check this box, old alerts are deleted when the mass forecasting job isprocessed even if no new alerts are created.

5. Run the forecast in the background as a mass processing job. For more information, seeForecast Execution with Mass Processing [Ext.].

6. Open the Alert Monitor by choosing Supply Chain Monitoring ? Alert Monitor and checkthe alerts.

Page 61: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 61

Example of a Macro AlertThis macro calculates the difference between this week's forecast and the previous week'sforecast and issues an alert if the difference is greater than 20%. Forecast and Previousforecast are two key figures (two rows) in the planning table.

Company XYZ manufactures product ABC, sales of which have been stable over time as it isa basic commodity. Therefore, there should be no drastic differences between this week’sforecast and the previous week’s forecast, as under normal circumstances no suddenchanges would be expected to occur. If this week’s forecast for period 3 is 100 but last week'sforecast for period 3 was 60, this is an exception that needs to be brought to the notice of thedemand planner. This macro detects such exceptions, triggers an alert, and changes thecolor of the corresponding cell to red. The planner can then take action as necessary.

Calculate difference (15 iterations: W 41.2000 ; W3.2001)

ENDIF

Macros

% difference Fcst and Prev.Fcst (Frm W 41.2000)

Previous forecast (Frm W 41.2000)

-

Forecast (Frm W 41.2000)

) /

Forecast (Frrm W 41.2000)

IFAlert

Condition: Forecast deviation > 20%

[ Previous forecast deviation in %: & ] with

Forecast (Attributes) =

CELL_BG(13)

ELSE

Forecast (Attributes) =

Check for > 20% change in forecast

100 * ABS(

> 20

% difference Fcst and Prev.Fcst (Frm W 41.2000)

CELL_BG(15)

% difference Fcst and Prev.Fcst (Frm W 41.2000)

-

--

-

-

-

-

-

Page 62: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 62

Translating Advanced Macros

UseUse this function to translate macro descriptions and alert texts into your logon language.

PrerequisitesThe macro was defined or the alert was triggered in a system whose logon language wasdifferent than the current logon language.

FeaturesThe language in which macro descriptions and alert texts appear in a planning book isdetermined as follows:

1. If available, the texts are shown in the logon language.

2. If no texts exist in the logon language, English is shown.

3. If no texts exist in English either, any other available language is shown.

The language in which an alert text appears in the Alert Monitor is determined by thelanguage in which you were logged on when the alert was triggered.

ActivitiesTo translate macro descriptions or alert texts into the current logon language, overwrite theforeign language texts in the planning book. When you save the planning book, the texts youentered are saved as the macro descriptions and alert texts of the current logon language.The foreign language texts are retained for the original language system.

Page 63: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 63

Business Cases for MacrosThe standard APO system comes with two macros books containing examples of the use ofmacro functions and operators: SAP Example and Template Macros and SDP Book 9AEXAMVIEW (SALES DATA). In SAP example and template macros you can look at the examplesbut you cannot execute the macros. To execute the macros, import them to another macrobook that you have created yourself (for more information, see Menu Functions for Macros[Page 21]) and alter their definition to fit the rows of the second book. In SDP Book 9AEXAMVIEW (SALES DATA) you can execute the macros.

The following documentation suggests some business cases in which you might use thesemacros. Where no example macro book is mentioned, please refer to SAP Example andTemplate Macros.

Page 64: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 64

Example of a Macro to Convert Percentage ValuesThis macro converts a percentage value based on the row “Corrected Forecast” automaticallyto an absolute value, and an absolute value into a percentage. The demand planner candecide on a case by case basis in which form to enter the value.

IF

ENDIF

Macros

Calculate % <-> Value : ( 30 Iterations : W 41.1999; W 18.2000)

Auxilary row 1 ( Frm W 41.1999)

=

Percentage Adjustment ( Frm W 41.199)

/ 100 *

Corrected Forecast (Frm W 41.2000)

ELSE

Promotion Percnetage <-> Value

% entered

Auxilary row 1 ( FM W 41.1999)

Absolute Adjustment ( Frm W 41.199)

Percentage Adjustment ( Frm W 41.199)

/ 100 *

Corrected Forecast (Frm W 41.2000)

Absolute Adjustment ( Frm W 41.199) =

Absolute Adjustment ( Frm W 41.199)

/ 100 *

Corrected Forecast (Frm W 41.2000)

Percentage Adjustment ( Frm W 41.199)

Absolute Adjustment ( Frm W 41.199) =

Absolute Adjustment ( Frm W 41.199) =

-

-

-

-

-

-

-

Page 65: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 65

Make 2nd Column Read-Only/Make 2nd ColumnReady-For-InputA demand planner is planning the demand for a consumer product whose forecast in the lastweek of the year has already been fixed by top management, on the basis that demand fromtwo major suppliers in this week will be extremely high. This macro ensures that the forecastfigures in this period are not touched while the demand planner can apply forecastingtechniques to other periods.

Some weeks later top management decides that it is necessary to modify the figures they hadfixed for the last week of the year, due to a sudden change in the situation of one of thesuppliers. They execute a second macro to allow changes to be made to the demand plan inthis period.

Page 66: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 66

Make 2nd Column Invisible/Make 2nd ColumnVisibleA demand planner is planning the demand for a consumer product whose forecast in the lastweek of the year has already been fixed by top management, on the basis that demand fromsome major suppliers will be extremely high in this week. Management does not wish thedemand planner to see their forecast for this period because it might influence his judgementin other periods. This macro ensures that the forecast figures for the last week of the year arenot visible to the demand planner, but that he can create demand plans in other periods.

Some weeks later top management decides that it is necessary to modify the figures they hadfixed for the last week of the year, due to a sudden change in the situation of one of thesuppliers. They execute a second macro to make the demand plan in this period visible again.

Page 67: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 67

Hide All Columns <> December (Year View)A demand planner is forecasting a product for which the corporate sector is the major buyer(for example, heavy duty vehicles). He has already done preliminary forecasting withoutconsidering seasonal effects because he wants to incorporate seasonal effects into theforecast manually. From previous history, it is known that sales are exceptionally high for thisproduct in December on account of depreciation benefits which are due only in this month.The demand planner uses this macro to hide all columns except those which correspond tothe month of December so that he can concentrate on the December columns and makeadjustments in these periods.

Page 68: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 68

Set/Delete Icon for Row 1 (All Planning Objects)A planner makes much use of a row and the data in other rows is also dependent on the datain this row. The planner puts an icon in front of this row in order to draw his attention to it.

When the planner decides he no longer needs the icon on this row, he can delete it by using asecond macro.

Page 69: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 69

Change Foreground Color to Red for NegativeValuesIf a planner enters a large number of values in the interactive planning table, he may not beable to see negative values. In terms of planning, negative values are an incorrect entry asdemand cannot be negative. A default macro changes the color of cells with negative valuesto red. Thus, the planner can quickly identify the errors.

Page 70: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 70

Calculate Cumulated Values: Year-to-DateA demand planner is analyzing various scenarios with respect to the inventory levels resultingfrom different sales volumes. In a pessimistic scenario, actual sales are less than theforecast, and inventory starts piling up because actual sales are less than production, which isbased on the forecast. This macro uses the difference between the forecast and a pessimisticsales estimate (contained in row 2) in order to calculate cumulative inventory levels at the endof every period, and writes the results to row 1. Having seen these worst-case inventorylevels, the demand planner may adjust the forecast figures, also taking into account theinventory policy of the company, warehouse capacities, and so on.

Page 71: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 71

Calculate and Round % DifferenceA demand planner creates a forecast in a planning book that includes rows for the baselineforecast and the final forecast. He uses this macro to calculate the % difference betweenthese two key figures and round it off to 3 digits. The macro writes the result to a third row.

For this example, please refer to macro book SDP Book 9AEXAM VIEW (SALES VIEW). Row1 is the baseline forecast, row 2 is the final forecast, and the results row is Total forecastadjustments in %.

Page 72: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 72

Info Message If Sum > 1000A demand planner is responsible for creating both a baseline forecast and promotions. It isthe policy of his company that when forecasted demand in a year is greater than 1000 units,promotions are not planned for that year because the company does not have the capacity toproduce more than 1000 units. The macro triggers a message to inform the planner when theforecast is greater than 1000. He is therefore saved the unnecessary effort of planningpromotions in that year.

In this example, row 1 represents the baseline forecast.

Page 73: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 73

Trigger DB Alerts If Value > 0A Planner has done preliminary forecasting for a product which is in the last stage of its lifecycle (decline stage) so after doing preliminary forecasting he wants to incorporate the effectsof life cycle to this product. So he will be having a row with the key figure as ‘ Adjustedforecast’ in his planning table. This row will contain adjustment on preliminary forecast due tolife cycle stage & should be having negative values. So, if some positive value comes in thetable , planner should be informed about this. This macro will trigger an alert with the valueshown so that planner can take appropriate action. If this is not the case, this macro willdelete all previous alerts in this context.

In the example, row 1 represents the preliminary forecast and row 2 the adjusted forecast.

Page 74: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 74

Calculate Sum of 3 Successive Periods UsingRows/AreasA demand planner has done forecasting on monthly basis and wants to get data on a rollingquarterly basis: the sum of the forecasts for January through March, the sum of the forecastsfor February through April, and so on.

For example, you could create the baseline forecast in one data view and execute this macroas a start macro in a second data view as the preface to doing further forecast calculations.One possibility would be to use these rolling quarterly figures to calculate a moving monthlyaverage and thus arrive at a smoother forecast. Alternatively, the rolling quarterly figurescould form the basis for calculating other forecast adjustments.

Page 75: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 75

Using Nested FunctionsOne planner has created a demand forecast. It is the job of a second planner to arrive at afinal forecast adjustment figure. The second planner has a data view containing monthlyforecast adjustment figures from two departments, say Marketing & Production. In theexample, row 1 represents the production adjustments, row 2 the marketing adjustments, androw 3 the final forecast adjustments. He wants to take a conservative estimate for the finalforecast adjustments and smooth this figure at the same time. By using this macro he doesthe following:

1. Calculates rolling quarterly figures for each month in both rows

2. Calculates a mean of the quarterly figure in each month

3. In each month, writes the greater of the two values to the final forecast adjustment figure

Example: Demand Manager's Data View

Jan 2002 Feb 2002 Mar 2002 Apr 2002 May 2002

ProductionAdjustments

10 15 20 85 45

MarketingAdjustments

20 25 30 35 40

FinalForecastAdjustments

25 40 50

In the example above, the first iteration would be:

1. Production Adjustments Row: 10 + 15 + 20 = 45Marketing Adjustments Row: 20 + 25 + 30 = 75

2. Monthly mean for February: Production Adjustments Row= 45/3= 15Monthly mean for February: Marketing Adjustments Row= 75/3= 25

3. 15 < 25 Final Forecast Adjustment for February = 25.

Page 76: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 76

Calculate Only for Periods Before 01/01/2000A demand planner's data view includes rows for actual sales data and sales history. Actualsales data is available until the end of last year. The current period is January. The plannerwants to store actual sales data up until the end of the previous year in the sales history rowwhere it can be utilized for forecasting into the future. For this purpose, he uses a macro thatchecks the date of each column (period) and, for the periods prior to this year, copies the datafrom the actual sales row to the sales history row.

In the example, row 1 represents sales history and row 2 represents actual sales data.

Page 77: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 77

Using the Number of Workdays for the CalculationA planner wishes to roughly estimate the daily average production rate necessary to meetdemand. He uses this macro to divide monthly demand by the number of workdays in eachmonth. He can therefore assess whether his forecasts are feasible given normal productionrate/capacities of the plant(s).

Another scenario in which this macro might be used is as follows: POS data from the past isavailable to the planner. The planner would like to compare average forecasted daily sales(which will be made on workdays only) with previous average daily sales.

Page 78: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 78

Using Actual Currency Conversion FactorCurrency conversion of the forecasted data may be required when all costing calculations aredone in DM but profit is to be calculated in $ and all revenue data is also quoted in $. Usemacros such as this one to convert monetary values between currencies.

In the example, row 1 represents the $ forecast and row 2 represents the DM forecast.

Page 79: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 79

Get Missing Forecast Entries from UserA demand planner is entering values for the baseline forecast. He enters zero by mistake insome of the periods, or forgets to enter values. When this macro is executed, a dialog boxappears for these periods and prompts the planner to enter values. The values thus enteredby the planner are transferred to the planning table.

For this example, see the macro book SDP Folder 9AEXAM View (SALES DATA).

Page 80: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 80

Using Values from Different PeriodsA demand planner is creating the baseline forecast for a product for which demand is growingcontinuously. The growth pattern can be mapped as a linear trend. The planner is interestedin knowing the average percentage growth for each period compared with its previous period.He executes this macro to obtain this information. In the example, the result is shown in therow % growth over previous period. This gives him the possibility to check the consistency ofthe forecast figures. A great variation in the growth figures may lead him to modify theforecast.

For this example, please refer to the macro book SDP Book 9AEXAM VIEW (SALES DATA).

Page 81: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 81

Adjust Forecast Depending on LifeCycleA demand planner is planning a product (for example, microprocessor chips) whose sales aresignificantly impacted by the product's lifecycle. First, he plans demand for the productwithout taking into consideration the effects of different lifecycle phases. He saves this firstforecast in the row Baseline forecast. Now, he wants to incorporate a factor of, say, 1.4 intothe demand for periods for which the product is live (that is, in its growth or maturity phases)and a factor of 0.8 into the demand for periods in which the product is not live (not in itsgrowth or maturity phases). By executing this macro, the planner obtains the Final forecastwhich has been adjusted for different lifecycle stages.

For this example, please refer to the macro book SDP Book 9AEXAM VIEW (SALES DATA).

Page 82: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 82

Values of Row 1 Shift by Offsets in Row 2A demand planner has finished planning demand for the finished product in the given horizonand is interested in finding the demand for dependent components. One unit of component 1is required to make one unit of the finished product; and under normal circumstances theprocurement lead time for component 1 is one month. In previous years, the supplier hasbeen unable to meet the demand for component1 in May on time. Therefore, in order to meetthe demand for the finished product in June, a lag of 2 months is required. The order forcomponent1 must be placed in April.

In the macro, the month of April (column 4) for row 2 will contain a value of ‘2’ while othercolumns of this row will contain a value of ‘1’. The macro shows the demand planner theperiod-dependent demand for component1.

Example: Demand for Finished Product and Component 1

January February March April May June

Demand forFinishedProduct(Row 1)

- 10 20 30 40 50

Offsets(Row 2)

- 1 1 1 1 2

Demand forComponent 1(Row 4)

10 20 30 90

Page 83: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 83

Submit a User-Specific ReportA demand planner wants to execute a program to import data from R/3 to APO before doingany demand planning, He does so by executing this macro. The macro triggers program‘ZUSER_REP’. As the purpose of the macro is to import data for demand planning, the macrois defined as a start macro.

Another possible use of this macro would be to attach the final forecast figures to an emailwhich is sent to the supply chain manager for review. The macro could be defined as an exitmacro so that the email is sent automatically once the demand planner has finished planning.

Page 84: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 84

Trigger Alert Based on Reorder PointA planner is planning supply and demand for a product at a warehouse location. Row 1 of thedata view shows inventory levels for this product at this location. The planner wishes to knowwhen he needs to order new inventory. The macro determines for each period whether thestock level has fallen below the reorder level for this product/location combination. If it has, analert is triggered informing the planner that he needs to reorder.

Page 85: Advanced Macros 310 DP En

SAP Online Help 07/04/02

Advanced Macros 401 85

Popup With Standard Deviation of Forecast KeyFiguresA demand planning coordinator is reviewing the forecasts made by two different departments(for example, production and marketing) for twelve periods. To get a quick impression of thestandard deviation figures of the two forecasts, he executes this macro. The macro opens adialog box showing the standard deviations of the forecasts. The planner does not need toview them in the planning table or save them once he has completed the forecast.

For this example, please refer to the macro book SDP Book 9AEXAM VIEW (SALES DATA).