How to Create and Use Hierarchy Variables and Hierarchy Node Variables in SAP BW/4HANA Queries with Examples
SAP BW/4HANA is a data warehouse solution that allows you to analyze and report on large volumes of data from various sources. One of the features of SAP BW/4HANA is the ability to create and use variables in queries. Variables are placeholders that can be replaced by values at query runtime, depending on the user input or system settings. Variables can help you to make your queries more flexible, dynamic and user-friendly.
In this blog post, we will explain how to create and use hierarchy variables and hierarchy node variables in SAP BW/4HANA queries. Hierarchy variables represent hierarchies and can be used wherever hierarchies can be selected. Hierarchy node variables represent nodes in a hierarchy and can be used wherever hierarchy nodes can be used. You can use hierarchy variables and hierarchy node variables to restrict characteristics on hierarchies or presentation hierarchies.
We will also show you some examples of how to create and use hierarchy variables and hierarchy node variables in different scenarios, such as filtering by product category, displaying the sales region or using the current member of a time characteristic.
Creating Hierarchy Variables and Hierarchy Node Variables in SAP BW/4HANA Queries
To create and use hierarchy variables and hierarchy node variables in queries in SAP BW/4HANA, you need to use the Query Designer tool. The Query Designer allows you to drag and drop InfoObjects or reusable query elements from the InfoProvider screen to the query rows and columns. You can also edit the properties of the variables using the Properties pane.
Here are the steps to create and use hierarchy variables and hierarchy node variables in queries in SAP BW/4HANA:
- Open the Query Designer and select the InfoProvider that you want to use for your query.
- Click on Variables on the toolbar to open the Variables screen.
- Click on Create Variable to create a new variable, or select an existing variable and click on Edit Variable to modify it.
- In the Create Variable or Edit Variable dialog box, enter a name and a description for the variable.
- Select Hierarchy or Hierarchy Nodes as the variable type from the drop-down list.
- Select the reference characteristic from the drop-down list. The reference characteristic determines which hierarchies or hierarchy nodes can be assigned to the variable at runtime.
- Select Replacement Path as the processing type from the drop-down list.
- Depending on the variable type, select one of the following options as the replace variable with option:
- For hierarchy variables, select Hierarchy.
- For hierarchy node variables, select Hierarchy Node.
- Choose the hierarchy or hierarchy node that you want to use as the variable using the input help dialog . For more information on using the input help dialog, see Restricting Characteristics.
- Optionally, enter an offset start and offset length for the replacement.
- Click on OK to save the variable.
Using Hierarchy Variables and Hierarchy Node Variables in SAP BW/4HANA Queries
After creating a hierarchy variable or a hierarchy node variable, you can use it in your query by dragging and dropping it from the Variables screen to the query rows or columns. You can also use it as a filter or a formula element.
Here are some examples of how to use hierarchy variables and hierarchy node variables in SAP BW/4HANA queries:
- To filter by product category using a hierarchy variable called PROD_CAT_VAR that represents a product category hierarchy, drag and drop PROD_CAT_VAR from
Variables screen to Filters screen. In Properties pane, select Single Value as selection
type and Equal To as comparison operator. For example, if you want to filter your query by product category using PROD_CAT_VAR
that represents a product category hierarchy called PROD_CAT_HIER, you can drag
drop PROD_CAT_VAR to Filters screen and select Single Value as selection type
Equal To as comparison operator. - To display the sales region using a hierarchy node variable called SALES_REG_VAR that represents a node in a sales region hierarchy, drag and drop SALES_REG_VAR from
Variables screen to Rows screen. For example, if you want to display sales region using SALES_REG_VAR that represents
node N1000 in sales region hierarchy called SALES_REG_HIER, you can drag and drop
SALES_REG_VAR to Rows screen. - To use the current member of a time characteristic using a hierarchy node variable called CURR_MEM_VAR that is replaced by a predefined variable 0CURMEM_CALMONTH that returns the current member of the calendar month characteristic, drag and drop CURR_MEM_VAR from the Variables screen to the Selections or Formulas screen. In the Properties pane, enter a selection or a formula for the structural component and include the variable name enclosed by & signs (for example, &VAR_NAME&). For example, if you want to use the current member of calendar month using CURR_MEM_VAR that is replaced by 0CURMEM_CALMONTH, you can drag and drop CURR_MEM_VAR to the Selections screen and enter a selection like this:
1 |
Calendar Month = &CURR_MEM_VAR& |
Conclusion
In this blog post, we have shown you how to create and use hierarchy variables and hierarchy node variables in SAP BW/4HANA queries with examples. By using hierarchy variables and hierarchy node variables, you can restrict characteristics on hierarchies or presentation hierarchies and make your queries more flexible, dynamic and user-friendly.
We hope you found this blog post helpful and informative. If you have any questions or feedback, please feel free to leave a comment below.
Disclaimer: This content is generated by AI.