Académique Documents
Professionnel Documents
Culture Documents
51
4.3.2 Macros Macro functionality supports the data processing from a simple addition of rows to more complex calculations using a set of standard functions. Even own coding can be applied in user function macros. The macros are defined specifically for each data view in the macro builder. The macro builder is accessed via the macro workbench with the transaction /SAPAPO/ADVM. To avoid the tedious search for ones own data views, we recommend to assign a group to the data vies and set a filter for this group as shown in figure 4.17.
Set Filter
Apply Filter
The macro builder is called for the data view by double-click onto the row of the according data view, figure 4.18.
52
4 Demand Planning
Activate all Macros in Data View
To create a macro the according elements (starting with the macro element) are picked from the element-window on the top left by drag and drop. After the macro is defined, it has to be activated before it can be used. By default a macro is directly executable, unless it is inhibited within the macro definition. If the macro shall be executed at start of the interactive planning, when the level changes or after exit, the macro has to be assigned to the according events in the top right window by drag & drop. Note that frequent execution of macros affects the performance, therefore the assignment as default macro (i.e. the macro is executed after each enter) should not be generous. Since the macro syntax is a bit tricky in some cases, the use of the check function is helpful. Especially for the search of errors the deactivation of macro steps is another useful feature.
Macro Syntax A macro consists of one or more steps with one ore more operations each. The processing area (total, future, past or freely defined) is selected on step level. The basic syntax row 1 equals row 2 operator row 3 is shown in figure 4.19. In this example the forecast is calculated as an average between sales forecast and statistical forecast.
53
An IF-statement requires a control statement and a condition, figure 4.20. The only difficulty is to place the objects into the right level.
Another peculiarity is the use of brackets for the functions, figure 4.21. Make sure there is always a space between the expressions.
The available macro functions are described in the SAP standard help and in the notes 403072, 438766, 433166 and others. There is also a collective consulting note for macro functionality, note 539797. For intermediate calculation steps an auxiliary key figure can be used (as row, element or column). There is only one auxiliary key figure available which is used by all macros. In the macro it is specified whether this auxiliary key figure is cleared before start.
Format Macros Macros help not only to calculate values but can also be used to change the property of cells like their colour, the displayed symbols, their ability for input or display only and other. To change these properties the change scope of the according rows has to be switched to attributes (this option is selected by double clicking on the row in the macro builder). Macros can be carried out depending whether rows or columns in interactive planning are marked, e.g. using the function ROW_MARKED ( row
54
4 Demand Planning
number ). The corresponding function to find out the row number is MARKED_ROW.
User Exit Macros User exit macros allow to process a whole grid in contrast to user function macro. Effects of Changes in the Data View If a change in the sequence of the key figures in the data view occurs, the logic of the macros is not affected. Before APO 4.1 the selected rows in the macro were related to their position in the data view and not to the name of the key figure. Therefore a change in the sequence of the key figures e.g. the insertion of a new key figure had led to a disturbance of the macro semantic. Copy Macros There are two ways to copy macros. To copy a macro within a data view, select the macro and use right mouse Copy to Clipboard, then select any Insert From Clipboard. The other way is to macro and use right mouse import the macros from another data view via the menu path Edit Import Macro. Macro Execution Macros are used in interactive planning by manual request from the planning book or triggered by events like the start of the interactive planning,