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:

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:

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:

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

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

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

The following screen appears:

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

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

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

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

The following screen appears:

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

The following screen appears:

Enter technical name and description as per the following screen:

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

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

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

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:

The following screen appears:

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

The following screen appears:

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

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

The following screen appears:

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

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

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:

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.

The following screen appears:

Enter technical name and description as follows:

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

The following screen appears:

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:

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

The following screen appears:

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

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

Below given is the variable sequence:

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

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

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

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

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

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

The report output is given below:

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