Show TOC Entering content frame

Object documentationAdvanced Macro Structures Locate the document in its SAP Library structure

Definition

An advanced macro consists of one or more macro steps. To define the conditions under which individual macro steps are carried out, you use control structures. Each macro step consists of one or more calculations. To define these calculations in the macro tree, you use calculation structures.

Structure

A macro can comprise of up to 4 levels. The following figure shows a simple example:This graphic is explained in the accompanying text

       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 contain at least one step. A step contains a calculation or series of calculation. A step is also an iteration loop. The calculation or operation is repeated over a predefined period, if you work with rows. 

       3.      Result level

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

       4.      Argument level

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

The following figure is a concrete example of the structure above. The macro calculates the adjusted forecast by adding the manual adjustment to the sales forecast. This is done for the period of one year in the future.

This graphic is explained in the accompanying text

Control Structures

As mentioned above, you use control structures at either step level or result level. In the first case you can control structures to decide which step to execute depending on which conditions 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 further information see Structure linkControlling the Program Flow. 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, you can use CASE WHEN structures to branch to different steps depending on the value of a variable or key figure.

Example

The following is an example of a macro that makes extensive use of control structures. Note the level of the various objects. For information on the functions used, see Functions for Info Objects and Planning Book.

This graphic is explained in the accompanying text

Calculation Structures

You use calculation structures not only to execute calculations but also to carry out other actions in which a value is not directly assigned to a key figure or variable. Examples of such actions 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 or more elements at the argument level. A simple example is the second graphic above.

 

 

 

Leaving content frame