X

SAP BW Hierarchy Variable

As mentioned in SAP BW Variables Tutorial, SAP BW Hierarchy Variable acts as a placeholder for hierarchies. You can use these types of variables when you want to select hierarchies. However, if you want to select hierarchy nodes, you must use hierarchy node variables. As mentioned in SAP BW Variables Tutorial, the Processing Type governs the way in which Text Variable gets filled with values during runtime of the query. Though there are various processing types, SAP BW Hierarchy Variables and Hierarchy Node Variables can have only some of the processing types.

SAP BW Hierarchy Variables can have the following processing types:

  • User Entry/Default Value
  • Customer Exit
  • SAP Exit

SAP BW Hierarchy Node Variables can have the following processing types:

  • User Entry/Default Value
  • Customer Exit
  • SAP Exit
  • Authorization

SAP BW Hierarchy Variables and Hierarchy Node Variables can become very confusing as there are many steps involved to create and use them. For the ease of understanding, let us take Deliveries Overview Report and add Hierarchy Restrictions on Ship-To Party field. This is how the Query looks initially:

Deliveries Overview Report: Query Designer

It has Division and Ship-To Party in rows, whereas Delivery quantity and Volume delivered are present in columns. The Filters section look as follows:

Deliveries Overview Report: Query Designer

There is just Division filter currently available. The requirement is to add restriction on Ship-To Party so that users can select a hierarchy and/or a hierarchy node as per his/her need.

Adding Hierarchy Restrictions to the Query

SAP BW Hierarchy Variable

Let us first add ‘Ship-To Party’ to the filters section. The screenshot is given below:

Adding Restrictions on Ship-To Party Field (1)

Now, right-click on ‘Ship-To Party’ field. The following screen appears:

Adding Restrictions on Ship-To Party Field (2)

Now, click on “Restrict…” highlighted in the above screen. The following screen appears:

Adding Restrictions on Ship-To Party Field (3)

The drop-down field for ‘Show’ has multiple options: History, Favorites, Single Values, and Variables. Let us select ‘Variables’ highlighted in the below screen:

Adding Restrictions on Ship-To Party Field (4)

The following screen appears:

Adding Restrictions on Ship-To Party Field (5)

Make sure that you select Variable Type as ‘Hierarchy Node Variables’ highlighted in the below screen.

Adding Restrictions on Ship-To Party Field (6)

You will see Variable Hierarchy at the bottom of the screen. Snapshot is given below:

Variable Hierarchy

Click on highlighted in the above screen to select hierarchy. The following screen appears:

Choosing the Hierarchy (1)

Let’s choose ‘Hierarchy Variables’ and click on highlighted in the below screen:

Choosing the Hierarchy (2)

The following screen appears:

Hierarchy Variables

Click on highlighted in the below screen to create a new SAP BW Hierarchy Variable.

Creating SAP BW Hierarchy Variable

The following screen appears:

SAP BW Hierarchy Variable Properties (1)

Enter technical name and description as per the following screen:

SAP BW Hierarchy Variable Properties (2)

Now, Go to ‘Details’ tab. The following screen appears:

SAP BW Hierarchy Variable Properties (3)

Let us make the variable ‘Mandatory’. A snapshot is given below:

SAP BW Hierarchy Variable Properties (4)

Now, go to ‘Default Values’ tab. The following screen appears:

Choosing the Default Hierarchy for Hierarchy Variable (1)

Let’s make ‘ERP Sales Planning Customers’ hierarchy as a default value. To achieve it, click on ‘Change Standard Values’ highlighted in the below screen:

Choosing the Default Hierarchy for Hierarchy Variable (2)

The following screen appears:

Choosing the Default Hierarchy for Hierarchy Variable (3)

Select ‘ERP Sales Planning Customers’ hierarchy from the list of available hierarchies.

Choosing the Default Hierarchy for Hierarchy Variable (4)

The following screen appears:

Choosing the Default Hierarchy for Hierarchy Variable (5)

Click on ‘OK’ button highlighted in the above screen to proceed. The following screen appears:

Choosing the Default Hierarchy for Hierarchy Variable (6)

Now, click on ‘OK’ button highlighted in the below screen to continue.

Choosing the Default Hierarchy for Hierarchy Variable (7)

The following screen appears:

Saving the Hierarchy Variable (1)

Click on ‘OK’ button highlighted in the above screen to save the variable. The following screen appears:

Saving the Hierarchy Variable (2)

Click on ‘OK’ button highlighted in the above screen to proceed.

Saving the Hierarchy Variable (3)

You can now see that we have chosen the hierarchy variable that was just created. Click on ‘OK’ highlighted in the above screen to continue. The name of the hierarchy variable appears in the variable hierarchy section as follows:

SAP BW Hierarchy Variable

This completes the creation of SAP BW Hierarchy Variable.

SAP BW Hierarchy Node Variable

Let’s now continue to create SAP BW Hierarchy Node Variable by clicking on highlighted in the below screen.

Creating Hierarchy Node Variable

The following screen appears:

Hierarchy Node Variable Properties (1)

Enter technical name and description as follows:

Hierarchy Node Variable Properties (2)

Now, go to ‘Details’ tab and change the variable representation if needed. Click on ‘OK’ highlighted in the below screen to proceed.

Hierarchy Node Variable Properties (3)

The following screen appears:

Saving the Hierarchy Node Variable

Hierarchy Node Variable gets saved with the above technical name and description. Click on ‘OK’ highlighted in the above screen to get the following screen:

Selecting the Hierarchy Node Variable (1)

Select the Hierarchy Node Variable ‘Ship-To Party Hierarchy Node’ to the right pane under Selection as follows:

Selecting the Hierarchy Node Variable (2)

The following screen appears:

Selecting the Hierarchy Node Variable (3)

Now, click on ‘OK’ highlighted in the above screen to proceed.

Query Definition

Let us now go to Query Properties to change the variable sequence by clicking on highlighted in the below screen.

Query Designer: Toolbar (Properties)

Below given is the variable sequence:

Query Properties: Variable Sequence (1)

Let’s change the variable sequence as per the following screen:

Query Properties: Variable Sequence (2)

Now, click on “Save” button and the report gets saved.

Saving the Query

Executing the Query

Execute the query using BEx Analyzer. This is how it looks like:

Query in BEx Analyzer

Select values for Division and Ship-To Party Hierarchy variables as per the following screen:

Select Values for Variables in BEx Analyzer (1)

Select values for Ship-To Party Hierarchy Node variable as per the following screen:

Select Values for Variables in BEx Analyzer (2)

Now, execute the query using the ‘OK’ button highlighted in the below screen.

Select Values for Variables in BEx Analyzer (3)

The report output is given below:

Report Output

SAP BW Hierarchy Variables and their usage in different contexts can become quite confusing in complex environments. Hence, you have to make sure that you get the basics right!

Did you like this tutorial? Have any questions or comments? We would love to hear your feedback in the comments section below. It’d be a big help for us, and hopefully it’s something we can address for you in improvement of our free SAP BW tutorials.

Navigation Links

Go to next lesson: SAP BW Formula Variable

Go to previous lesson: SAP BW Text Variable

Go to overview of the course: SAP BW Training