Start of Content Area

Function documentation Variables  Locate the document in its SAP Library structure

Use

Variables are used to parameterize a query, a planning function, a filter, a characteristic relationship or a data slice. When a query, planning function or Web application is executed, they are filled with values.

Variables act as placeholders for characteristic values, hierarchies, hierarchy nodes, texts, and formula elements, and can be processed in many different ways.

      Depending on the objects for which you want to define variables, there are different variable types. For more information, see the documentation on the Query Designer under Variable Typessa.

      The processing type determines how a variable is filled with a value for the runtime of the query, planning function or Web application. For more information, see the documentation on the Query Designer under Processing Types for Variablessa.

Example

When you use variables, one planning function definition, for example, can be used as a basis for many different planning functions: you want to create a planning function of type Copy that copies your current data from the current version to another version. You use a variable for the Version characteristic in the To parameters of the planning function. Before you execute the planning function, you decide to which version the current data is to be copied.

Note

For formula variables that are used in planning functions, for example for conversion functions, the processing type Replacement Path is not available. Only the Number dimension is supported here.

You cannot create text variables in the Planning Modeler. In input-ready queries, however, you can use text variables without any restrictions.

Integration

Variables as Reusable Objects

Variables do not depend on an InfoProvider, but on the respective InfoObject only. A variable that you define for an InfoObject is available in all InfoProviders that use this InfoObject.

Variables can be defined in the Query Designer or in the Planning Modeler or Planning Wizard.

Example

For example, when you define a variable for a planning function in the planning modeler, it is available for reuse for all queries or planning functions.

Validity Area of Variables

The same variable can have different values in different locations. A separate instance of the variable is created whenever a variable is filled with a value. In some cases different instances (and therefore the values) of variables are merged into a single instance. This means that the variable has the same value in all the objects involved. This happens, for example, when a variable is used in two different queries. However, this is only the exception.

Features

Variables help you to flexibly set or parameterize your objects. The following objects support the use of variables:

Using variables

Object

Using Variables

Queries (especially input-ready queries)

      For example, to parameterize characteristic restrictions in the query

      In formulas, conditions, exceptions and as a placeholder for text

When a query is started, variables can be assigned values in three different ways:

...

      With a predefined value

      With a variant

      With a user entry

Filters

To parameterize characteristic restrictions that describe the filter.

Planning functions

Depending on the respective planning function type, to parameterize conditions and parameters, for example, to parameterize the conversion factor in planning functions of type conversion.

Variables can be assigned values in the following ways:

      With a predefined value

      With a command in the application

Characteristic relationships

      To parameterize the hierarchy used

      To parameterize selection from a DataStore object

Data slices

To parameterize characteristic restrictions that describe the data slice.

Note

Variables that are used in characteristic relationships and data slices cannot call a dialog for the manual entry of values. These variables must have a value at the time of execution.

Times of Variable Calls

The different ways in which variables are used result in different times at which variables are executed and at which they are assigned new values.

Use

Time of Variable Call

Query

...

       1.      The variable is processed each time the application is restarted.

       2.      When you call the dialog box Change Values for Variables (also known as: Variables Screen). This forces the query to be restarted.

If you end the Variables Screen with OK, the value of the variable does not change if you did not actively make any changes. This means that the Exit is not executed for input-ready variables of type Exit in order to redefine the default value in the dialog box (since it could overwrite the value that is already defined). Variables in the area of the default values and variables for defining the presentation hierarchy take on the value of the current filter state of the characteristic or the currently defined presentation hierarchy. (You can override this behavior with an indicator in the Query Designer). In general, explicitly setting variable values (for example with URL parameters) has priority over implicitly setting these values (for example default value of a variable).

For more information about the dialog box Change Values for Variables, refer to Changing Variable Values.

Planning function

Only when executing the planning function. Here, too, explicitly set variable values have priority over implicitly set variable values. This results in the following conditions for defining the priority when filling a variable:

...

       1.      Is the variable set explicitly in the command with data binding?

       2.      Is a variant of the variable specified in the command?

       3.      Is the variable personalized?

       4.      Is there a default value?

       5.      Are none of these conditions satisfied? In this case the Variable Editor opens in the BEx Web while the system merges the variables merge in the BEx Analyzer.

Planning sequence

See Planning function.

Filter in planning sequence

Each time the planning sequence is executed.

Data slice

The first time it is called. You cannot change data slices by changing variables. If no variables are set, the dialog box Change Variables for Variables does not appear.

Note

It must be possible to replace the type of the variable used in data slices automatically. Variables that are entered manually are not allowed.

Characteristic relationship

See Data slice.

Merging Variables

If there are two variables with the same name in two different objects, the system creates instances of these variables. From then on there are physically two variables. In certain constellations the system automatically merges these instances so that all variable instances have the same value.

Constellation

Merge

Variables with same name in two queries

Yes.

Variables with same name in planning function and query

Only in BEx Analyzer and if the variable value was not replaced by a command there.

Note

To ensure the same value in a Web application, the executing command must perform data binding.

Variables with same name in planning sequence and query

See Planning function

Filter and planning function within a planning sequence

Yes.

Data slice or characteristic relationship with any other object

No.

In the Planning Modeler or Planning Wizard, as well as in the Query Designer, the following tools are available for creating and changing variable definitions according to context.

Tools for Creating, Changing and Displaying Variables

Tool

Description

Variables Wizard

The wizard takes you through the process of creating a variable step-by-step. Each individual step is context-sensitive and is modified according to the combination of variable and processing types used. This means that the Variables Wizard only offers the selection options that are permitted for that combination of variable and processing types.

For more information, see the documentation on the Query Designer under Defining Variables.

Note the following when you use the Variables Wizard in the context of the Planning Modeler or Planning Wizard:

      The first step is General Information.

      The system shows further dialog steps according to context:

       Detailss

       Default Valuess

       Replacement Paths

       Currencies and Unitss

(There is no Characteristic dialog step).

Variables Editor

The Variables Editor dialog box offers all the options for changing an existing variable. The individual tab pages of the dialog box show the previous settings for the variable.

Not all settings for variables can be changed in the Variables Editor. For example, the variable type and processing type cannot be changed once the variable is created.

Note the following when you use the Variables Editor in the context of the Planning Modeler or Planning Wizard: in addition to the change mode, the Variables Editor also has a display mode.

Activities

The tools for creating and changing variables are available wherever you enter constant values and can use variables.

In the Planning Modeler or Planning Wizard, you can also display and delete variables. In the restriction dialog for a characteristic in the filter, you see the list of the variables available for the selected characteristic in the Variables view for single values. The functions Create, Edit, Display and Delete are available here.

      If you choose Create, the Variables Wizard appears.

Note

The Variables Wizard opens with the settings made for the current context: For example, if the Variables Wizard opens in the dialog for characteristic restriction, it has the settings that are appropriate for the type of variable (characteristic variable), the appropriate characteristic and the basic characteristic, as required.

      If you choose Edit, the Variables Editor opens and you can change certain properties.

      If you choose Display, the Variables Editor opens in display mode.

      If you choose Delete, the system deletes the selected variables.

Note

For more information about using these two tools in the Query Designer, see Variables.

 

 

 

End of Content Area