How to Create and Use Structures in Queries in SAP BW/4HANA

How to Create and Use Structures in Queries in SAP BW/4HANA

Structures are a way to group and organize key figures or characteristics in queries in SAP BW/4HANA. They help you to define the layout of the query for the rows or columns, and to create complex calculations or selections. Structures can also improve the performance and readability of your queries.

In this blog post, we will explain what structures are, how they work, and how to create and use them in queries in SAP BW/4HANA. We will also show you some examples of queries with structures and how to link structures across queries using the linked components feature.

What are structures in SAP BW/4HANA?

A structure is a combination of InfoProvider key figures and characteristics that are used to define the layout of the query for a row or column. A structure can have one or more components, which can be either key figures or characteristics.

There are two types of structures that can be created in a query:

  • Key figure structures: These are structures that contain only key figures or key figure-based components, such as basic key figures, formula key figures, restricted key figures, or calculated key figures. Each component in a key figure structure must include a key figure. A key figure structure is automatically created in the query when you add any key figure to the rows or columns of the query.
  • Characteristic structures: These are structures that contain only characteristics or characteristic-based components, such as basic characteristics, selection with characteristics, or formula with characteristics. Each component in a characteristic structure must include a characteristic. A characteristic structure can be created manually in the query by selecting New Structure from the context menu of the rows or columns.

You can create up to two structures in a query: one for the rows and one for the columns. You can also use both structures in the rows or in the columns.

How to create and use structures in queries in SAP BW/4HANA?

To create and use structures 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 structures and their components using the Properties pane.

Here are the steps to create and use structures in queries in SAP BW/4HANA:

  1. Open the Query Designer and select the InfoProvider that you want to use for your query.
  2. Drag and drop any key figure from the InfoProvider screen to the rows or columns of the query. This will create a default key figure structure named Key Figures.
  3. To add more components to the key figure structure, drag and drop any key figure-based element from the InfoProvider screen or from the Reusable Components screen to the Key Figures structure.
  4. To create a new key figure structure, right-click on Key Figures and select New Structure. Then, drag and drop any key figure-based element to the new structure.
  5. To create a characteristic structure, right-click on Rows or Columns and select New Structure. Then, drag and drop any characteristic-based element from the InfoProvider screen or from the Reusable Components screen to the new structure.
  6. To edit the properties of a structure or a component, select it and use the Properties pane on the right side of the Query Designer. You can change the name, description, aggregation type, display options, filters, formulas, conditions, exceptions, etc.
  7. To execute the query and see the results, click on Execute Query on the toolbar.

Here is an example of a query with two structures: one key figure structure and one characteristic structure.

The query uses an InfoProvider named Sales Data that contains the following fields:

  • Sales Organization
  • Material
  • Customer
  • Quantity
  • Revenue

The query has two structures:

  • A key figure structure named Revenue Analysis that contains two components:
  • A basic key figure named Revenue
  • A calculated key figure named Revenue per Unit that divides Revenue by Quantity
  • A characteristic structure named Customer Analysis that contains two components:
  • A basic characteristic named Customer
  • A selection with characteristic named Top Customers that filters Customer by Revenue

The query result will look something like this:

Revenue AnalysisCustomer Analysis
RevenueCustomer
Revenue per UnitTop Customers
100000All Customers
10
60000C01
12C01
40000C02
8C02

You can see that the data is displayed according to the structures and their components. You can also use filters, variables, formulas, exceptions, and conditions on structures to further customize your query.

How to link structures across queries using the linked components feature?

One of the new features introduced in SAP BW/4HANA is the linked components feature. This feature allows you to link structures or components across queries, so that any changes made in the source query are automatically reflected in the target query. This can help you to maintain consistency and avoid duplication of structures or components.

To link structures or components across queries, you need to use the Linked Components screen in the Query Designer. Here are the steps to link structures or components across queries:

  1. Open the Query Designer and select the source query that contains the structure or component that you want to link.
  2. Click on Linked Components on the toolbar to open the Linked Components screen.
  3. Select the structure or component that you want to link and drag and drop it to the Linked Components pane on the right side of the screen.
  4. Click on Save and Close to save the changes.
  5. Open the target query that you want to link the structure or component to.
  6. Click on Linked Components on the toolbar to open the Linked Components screen.
  7. Select the structure or component that you want to link from the Linked Components pane on the right side of the screen and drag and drop it to the rows or columns of the query.
  8. Click on Save and Close to save the changes.

Now, the structure or component is linked across the queries. If you make any changes to the structure or component in the source query, such as adding, deleting, or modifying a component, those changes will be automatically reflected in the target query.

Here is an example of linking a key figure structure named Revenue Analysis from a source query named Q1 to a target query named Q2.

The source query Q1 has a key figure structure named Revenue Analysis that contains two components:

  • A basic key figure named Revenue
  • A calculated key figure named Revenue per Unit that divides Revenue by Quantity

The target query Q2 has no structures.

To link the Revenue Analysis structure from Q1 to Q2, follow these steps:

  1. Open Q1 and click on Linked Components.
  2. Drag and drop Revenue Analysis to the Linked Components pane.
  3. Save and close Q1.
  4. Open Q2 and click on Linked Components.
  5. Drag and drop Revenue Analysis from the Linked Components pane to the columns of Q2.
  6. Save and close Q2.

Now, Q2 has a key figure structure named Revenue Analysis that is linked from Q1. If you make any changes to Revenue Analysis in Q1, such as adding a new component or changing a formula, those changes will be automatically reflected in Q2.

Conclusion

Structures are a way to group and organize key figures or characteristics in queries in SAP BW/4HANA. They help you to define the layout of the query for the rows or columns, and to create complex calculations or selections. Structures can also improve the performance and readability of your queries.

You can create and use structures in queries in SAP BW/4HANA using the Query Designer tool. You can also link structures or components across queries using the linked components feature.

We hope that this blog post has helped you to understand how to create and use structures in queries in SAP BW/4HANA. If you have any questions or feedback, please leave a comment below.

Disclaimer: This content is generated by AI.