7 Reporting and Analytics
Reporting and analytics are key processes in business intelligence, and several SAP and third-party tools are available to support different analysis needs. In this chapter, we’ll discuss SAP BW/4HANA’s high-performance tools and connectors that enable reporting and analytics in different visualization systems.
Reporting and analytics are crucial functions in business intelligence that collect and organize data available in your EDW landscape into different data visualizations. These visualizations can be used to understand certain key performance indicators (KPIs) and establish actions to improve them.
SAP BW/4HANA provides significant performance improvements by pushing OLAP operations and complex reporting calculations down to the database. In previous SAP BW systems, these reporting calculations and OLAP operations were processed in the application server layer by the OLAP engine.
This ability to process data in the database layer is one of the key factors that contributes to the efficiency in using advanced analytics methods, such as complex statistics functions, scenarios simulation, and predictive analysis.
There are several tools within SAP HANA that can be used together for complex analytic reporting, including SAP HANA analysis process, Application Function Library, Predictive Analysis Library, R scripts for statistical computing and data mining, and text analysis.
In this chapter, we’ll examine important available resources for reporting in SAP BW/4HANA, including its core component, the SAP BW/4HANA query, its integration with SAP BusinessObjects and third-party business intelligence tools, and its ability to make queries available as SAP HANA calculation views to be used as data sources in SAP HANA native developments.
Simple query examples will be used throughout the chapter to illustrate some of the capabilities from each tool presented.
7.1 SAP BW/4HANA Queries
SAP BW/4HANA queries are objects that contain several functions and properties to help you to perform multidimensional analyses on multi-scale datasets and to address different business requirements.
In SAP BW/4HANA, the component responsible for retrieving, processing, and formatting data requested by a query from its InfoProvider is called analytic manager. This is the main interface between you and the database and it makes multidimensional data available to different frontend tools via special integration protocols and components tailored for each of them.
Queries are defined and linked to a specific InfoProvider that contains the data you want to report on. The performance of the query execution is directly related to the precision of the query definition and the query size. A query with several calculation levels, few filters, or with a large number of fields may have longer runtime during its first execution and navigation.
Queries in SAP BW/4HANA have the following main parts:
-
Query properties
A combination of settings to define the query execution procedures and visibility to third-party tools. These query properties are subdivided into general properties and runtime properties. -
Sheet definition
A combination of query elements to form a worksheet that provides a mechanism to organize data according to your reporting needs. -
Query elements
These are characteristic InfoObjects; basic, restricted, and calculated key figures; structures; formulas; and selections. -
Filters
A combination of restrictions that affects the data reported, allowing you to restrict the data volume retrieved from the InfoProvider and used in the report. -
Variables
Objects that can be defined and associated with InfoObjects to help make filters and selections flexible and incorporate complex rules. -
Conditions
A combination of rules to further restrict the information displayed, such as top N records according to a specific key-figure. -
Exceptions
A combination of rules and alerts to highlight certain figures on the report.
Before we examine these elements in more detail, it’s important to highlight the process of creating new queries in SAP BW/4HANA and how it differs from previous SAP BW systems.
7.1.1 Creating a Query with Eclipse-Based Query Designer
SAP BW reporting users will be familiar with the SAP Business Explorer (SAP BEx) query designer tool. SAP BEx queries have been the main reporting feature for all previous versions of SAP BW. In SAP BW/4HANA, this feature was migrated from the SAP BEx toolset to the Eclipse platform.
Figure 7.1 shows the well-known SAP BEx query designer. The InfoProvider panel is where all available InfoObjects for reporting from the InfoProvider linked to the query are listed and ready for drag and drop to the desired section of the report. The central section, called Rows/Columns, is reserved to build the query sheet definition, the Properties panel shows all properties related to a certain query element, and the Messages panel shows all messages related to the query being designed.
Figure 7.1 SAP BEx Query Editor Sheet Definition Screen
Note
During SAP BW migration, existing SAP BEx queries are migrated via the SAP BW/4HANA Starter Add-On for SAP BW 7.5 powered by SAP HANA. After the migration, you need to Open each query using the Eclipse-based query designer, fix any inconsistencies, and Save it.
Figure 7.2 shows the new SAP BW/4HANA query editor based in Eclipse. The elements of the query in this editor are divided into tabs; each tab contains the different query design elements.
Figure 7.2 SAP BW/4HANA Query Editor in Eclipse
Note
Functions described in this chapter require the installation of the following add-ons in SAP HANA Studio or Eclipse:
- ABAP Development Tool (ADT)
- Modeling Tools for SAP BW Powered by SAP HANA
- SAP HANA Tools
For installation links to use in the Eclipse installation path, visit https://tools.hana.ondemand.com.
You can create a query in SAP HANA Studio in the BW modeling perspective in the Project Explorer panel in two ways:
- Select the node that has the BW project name or an InfoProvider and select the menu path File • New • Query…, as shown in Figure 7.3.
-
Right-click the selected node and select New • Query....
Figure 7.3 Creating Query via Context Menu from SAP BW Project Node
Also, you can create a new query as a copy of an existing one by right-clicking an existing query and selecting Copy… from the context menu, as shown in Figure 7.4.
Figure 7.4 Creating Query via Context Menu from Existing Query as Copy
The first pop-up screen in the query creation, shown on Figure 7.5, asks for the main general properties of the query.
These main general properties are as follows:
-
BW Project
Shows the name of the SAP BW/4HANA project that identifies the SAP BW/4HANA system ID, client, username, and language to in which you’re creating the query. -
Package
Allows you to select which development package this query belongs to. The $TMP package is used for local developments. Transporting queries is discussed in Section 7.1.9.Figure 7.5 Create New Query Initial Screen
-
InfoProvider
Shows the technical name of the InfoProvider that will be used as the basis of the query. -
Name
Stores the technical name of the query. -
Description
Stores a meaningful description of the query. -
Copy From
References the technical name of a query that will be used as a template for this new one.
Note
The query used as a copy from when creating a new query must be from the same InfoProvider.
7.1.2 Query Properties
Query properties are organized into two groups: general properties and runtime properties. We’ll discuss each group in turn.
General Properties
The General tab shown in Figure 7.6 is the first tab viewed when creating a new query. It contains the general settings and properties of the query.
Figure 7.6 New SAP BW/4HANA Query: General Tab
This screen is divided into the following sections:
-
Output Settings
Select options to modify the default format of the report when the query result is shown. -
Result Location
Select the default location of the total and subtotal columns and rows. -
Zero Suppression
Hide rows or columns either when their result values are equal to zero or when all individual values for that row or column are zero. -
Remote Access
Use the following options in this section if you want to run your query using a different frontend:-
By OLE DB for OLAP
Enable the query to be accessed by MDX-enabled frontends, such as SAP BusinessObjects tools. -
External SAP HANA View
Enable the query to be accessed by SQL-based ODBC third-party tools, such as Tableau. SAP BW/4HANA queries automatically generate SAP HANA calculation views when this property is selected. The generated SAP HANA View hyperlink will sit beside this property. You can get the location of the SAP HANA view by hovering your cursor over the link or open it by clicking the hyperlink. The SAP HANA view is displayed in the SAP HANA Studio modeling perspective. -
OData
Enable the query to be accessed by applications based on Representational State Transfer (REST), such as Qlik.
-
By OLE DB for OLAP
-
Universal Display Hierarchy
Limits the hierarchy levels that are read from the database when you design your query to have characteristics displayed in a hierarchical mode. For example, if you have a report with country, state and city arranged hierarchically and you set this property to Up to level 2, then the query only retrieves data up to the state level. -
Variables Order
View and configure the screen order of the variables used in the query. When the query is executed, the system generates a variable input window, which displays the variables in the order specified in this section. -
Extended
Manage data selection parameters for backend processing, particularly when you use near-line storage for cold data storage and you want to incorporate archived data with current data in your query. Also allows you to enable links to documentation created for values in master data, InfoProvider and to the query metadata. Near-line storage solutions are discussed in Chapter 9. -
Planning
This section lets you change planning mode options for queries.
Note
The External SAP HANA View option is only enabled for the query if the InfoProvider has also the External SAP HANA View option enabled.
You can save the query by following the menu path File • Save.
Runtime Properties
In the Runtime Properties tab (see Figure 7.7), you can override settings from the InfoProvider to provide specific values needed for the query. This tab is divided into two sections:
-
Common Runtime Properties
-
Process Key Figure with High Precision
This property is used to set the precision level for the calculations in the query. Two levels are possible: 16 places (short decimal floating) and 34 places (long decimal floating). Short decimal floating is used by default in SAP BW/4HANA to minimize main memory usage when data is stored in the OLAP cache. -
No Parallel Processing
When the query is executed, it can be split into several subqueries internally. This happens according to the complexity of the objects and formulas, especially when the query contains calculated or restricted key figures and hierarchy conditions. With this property, you can set the processing of these subqueries to be either sequentially or in parallel. For parallel processing, if you have an InfoProvider with non-cumulative key figures, the query processing happens in two stages: subqueries that are not related to the non-cumulative key figures are processed in parallel first and then the remaining ones which are related to non-cumulative key figures are processed sequentially to avoid extensive memory consumption. -
Calculating Commutative Formulas After Aggregation
Commutative formulas, such as addition and subtraction, can be calculated before or after aggregation, returning the same result. The before aggregation option ensures that the formula calculation is executed for every record in the dataset transferred from the InfoProvider to the OLAP engine. If the formula is calculated after aggregation, the number of calculations depends on the granularity level of the formula in your query. -
Query Is used as InfoProvider
This setting allows the query to be used as an InfoProvider in data flows. -
Generation Log
This property is set to store the log created during query generation. -
OLAP Effort
This property is used for setting the OLAP effort expectations and limits for queries that have InfoProviders with a high volume of data. It is also used when the query structure is extensive or has complex calculations that result in a large result set to be processed by the OLAP engine.Figure 7.7 Query Runtime Properties in Query Editor
-
Process Key Figure with High Precision
-
Runtime Profile Properties
-
Data Integrity Profile
Allows you to specify the method of retrieving data from the InfoProvider either via predefined available profiles or via expert mode for custom settings. -
Query Read Mode
Defines how the OLAP processor acquires data from the InfoProvider during the initial query execution and navigation of the query results. -
Query Cache Mode
Defines different options and algorithms for using the SAP BW/4HANA cache to optimize the query runtime by saving OLAP calculation results in the cache highly-compressed by default in SAP BW/4HANA. You can maintain cache compression parameters for the query via Transaction RSRCACHE. It is recommended the query cache compression size to be close to 2GB and with compression threshold greater than 5000 rows in the cache. -
Cache Usage Mode
Defines whether the cache entries are used to display the query results. -
Update Cache Objects in Delta Process
Specifies that new data retrieved in a query is added to the cache; also called delta caching. -
Type of SP Grouping for Delta Caching
Helps optimize the behavior of the delta cache. For example, if a query is based on a CompositeProvider with several InfoProviders, you can set it so that data from each InfoProvider is stored separately in the cache. The advantage of this option is that when you execute the query, only InfoProviders with changed data are read again. On the other hand, it consumes more memory to store these individual datasets. -
Operations in SAP HANA/BWA
This is the setting that allows you to push complex calculations normally performed in the OLAP engine down to SAP HANA database. SAP Note 2063449: Push down of BW OLAP functionalities to SAP HANA contains the available functions that will be executed in SAP HANA database. -
Materialize Intermediate Query Result
SAP BW/4 HANA offers an option to materialize intermediate query results and it is used in conjunction to the property Operations in SAP HANA/BWA; when Operations in SAP HANA is set to Exception Aggregation or Formulas Calculated in SAP HANA, a large part of query processing takes place in the SAP HANA database. This way, intermediate results of queries are calculated and materialized to be reused during drill-down operations and providing a better performance for queries with large datasets. Although, for cases of smaller datasets or depending on the level of performance optimizations used when creating the query, it might be quicker to keep recalculation of intermediate results each time the query is executed. -
Use Selection of Structure Elements
This property ensures that only elements present in the structure and their selections are passed to the database for retrieving the query dataset. For example, if you have records with amounts in January and February, and you display only January column in your query structure. This property ensures that only records with values in January are processed. This way, you might have improvement in performance if you have many selections or restricted key figures that either are not displayed initially during the initial query execution or used in several operations, such as Filter and Drill Down by. -
Also Read Child Members
This setting complements the property Use Selection of Structure Elements when it is active. It automatically incorporates all hierarchical successors in a filter of a hierarchy-type structure element for the data retrieval. -
Optimization Mode
Defines the frequency with which the OLAP processor memory is optimized for existing queries. By default, this optimization happens on the first execution of the query and subsequently 31 days after the last optimization. It can also happen according to the Optimization Periods property definition. -
Optimization Periods
Defines the period to be used in the optimization of the OLAP processor if you’ve set the Optimization Mode to Query Optimization with Individual Period in Days. This setting can be used if the InfoProvider is consistently fully dropped and reloaded. -
Stat. Detail Level
displays the detail level for statistic details of the query runtime, as defined in Transaction RSDDSTAT (Maintenance of Statistic Properties) for the query object type (see Figure 7.8).Figure 7.8 Maintenance of Statistics Properties
-
Data Integrity Profile
7.1.3 Filters
Query filters are mechanisms to restrict the data selection for the query. They can be defined locally in the query or globally in the InfoProvider to be used in multiple queries. The following subsections describe the properties and use of filters and creation of global filters.
Query Filters
Filters are restrictions on the data selection for the entire query. These filters are sent to the database to reduce the volume of data retrieved and sent to the OLAP processor during the query execution.
The Filter tab (see Figure 7.9) allows you to create fixed-value filters and default-value filters for the characteristics available for the InfoProvider selected for the report. Fixed-value and default-value filters differ as follows:
-
Filters with fixed values
The characteristic values used as the filter selection can’t be changed after the query result is displayed. -
Filters with default values
The characteristic values are used as the filter selection in the background; they aren’t displayed on the selection screen, but you can change or remove these values after the query result is displayed.Figure 7.9 SAP BW/4HANA: Filter Tab
In both sections, you can associate variables with query filters, allowing them to receive flexible values during query execution (see Section 7.1.4).
Special Feature: Query Definition without Key Figures
Say that you want to define a query that only contains characteristics in the query structure (rows/columns), but every query must contain at least one key figure. In this case, you can add a key figure to the Filter: Fixed Values panel and, if required, add filters to it. For example, you can create a list of customer details with individual sales order amounts greater than $10,000.
Global Filters
Global filters are reusable elements created to be present in different queries sharing the same InfoProvider. This allows you to have a group of queries with the same filter logic. When a change in logic is needed, you won’t need to change each query individually; instead, you only need to change the logic in the global filter and regression test the queries involved.
If you have a filter collection in your report and you want to make it a global filter to be reusable for different queries sharing the same InfoProvider, right-click any filter element in the filter area and choose Save as Global Filter…, as shown in Figure 7.10.
Figure 7.10 Context Menu of Filter with Save as Global Filter Highlighted
A create Filter screen will appear, in which you can enter the technical name and the description of the filter (see Figure 7.11).
Figure 7.11 Input Screen for Creating Global Filter
After clicking Finish, you’ll see the new global filter created in your query, with all filter elements associated with your query (see Figure 7.12).
Figure 7.12 Global Filter and Its Definition Created from Existing Query Filters
You can clean up the filter area by removing the local filters made into global filters. You also may want to change the global filter definition, which you can find under the InfoProvider associated with it, as shown in Figure 7.13.
Figure 7.13 Modeling Perspective Showing InfoProvider’s Associated Elements, Including Global Filters
The global filter modification screen has the same features as the Filter screen in the query designer (see Figure 7.14).
Figure 7.14 Global Filter Details Screen
Using the same process, you can create global filters by right-clicking an InfoProvider and choosing New… • Global Filter….
7.1.4 Variables
Variables are used as query parameters for different types of query elements. Unlike fixed-value filters, a variable is filled with values only once the query is executed.
Query elements are often associated with InfoObjects in SAP BW/4HANA; therefore, each InfoObject type restricts the variable types that can be used. When the variables are linked to InfoObjects, these variables become available for use in all queries linked to InfoProviders which contain these InfoObjects.
The following subsections describe the process of creating variables and variable exits (SAP exit, customer exit, and SAP HANA exit) to be used in SAP BW/4HANA queries.
Creating Variables
You can create a variable either via the menu path File • New • Variable or by right-clicking a characteristic, key figure, time, unit info object, or query node and selecting New • Variable.
The New BW Variable screen shown in Figure 7.15 allows you to enter the properties of this new variable.
Figure 7.15 SAP BW/4HANA: New Variable Properties Screen
When you create a variable, you must select a variable type and processing type, as follows:
-
The variable type (Type of Variable) indicates for which types of objects the variable can be used. The supported variable types are as follows:
-
Characteristic Value
Contains or restricts SAP BW/4HANA characteristics values—for example, current date in date-type characteristics. -
Hierarchy
Contains or restricts hierarchy names—for example, cost center hierarchies that define different groupings for cost center analysis, which may share the same cost centers. -
Hierarchy Nodes
Contains or restricts hierarchy nodes relevant for the query execution—for example, specific cost centers. -
Text
Contains a text that can be used in query elements descriptions—for example, in formula descriptions. -
Formula
Contains numeric values that can be used in formulas, exceptions, and conditions. For example, you can create a formula variable for currency exchange rates that will be processed after you’ve executed the query.
-
Characteristic Value
-
The processing type (Processing By) indicates the method the variable is filled with values during the query runtime. The supported processing types are as follows:
-
Manual Input/Default Value
Allows you to manually enter values in variables when executing the query. You can also enter default values in variables using this processing type on the Default Values tab in the variables editor. Default values are shown in input fields associated with the variables in the query selection screen during the query runtime for ready-for-input variables. For variables not input-ready, the default value is used as defined in the variable. -
Replacement Path
Allows you to specify a value or a reference characteristic that automatically replaces the variable when executing the query. For example, you have dynamic columns for last 12 months depending on the current month and you can use replacement path to set the month names used. -
Authorization
Allows you to make SAP BW/4HANA populate variables of this process type with values defined in the user authorization objects generated when selecting the property Authorization-Relevant in the characteristic linked to the variable. It can be used with characteristic and hierarchy node variables. -
Variable Exits
Allows you to set up complex rules and logic to determine the final values of a variable to be used in a query at runtime. The types of variable exits are Customer Exit, SAP Exit, and SAP HANA Exit.
-
Manual Input/Default Value
-
Ref. Characteristic
The InfoObject technical name associated with the variable. When creating the variable via the InfoObject context menu, this field is prepopulated with the InfoObject’s technical name. -
Var. Represents
Depending on the type of variable selected, this option allows you to set the variable to represent a single value, multiple single values, an interval, or Selection-Options (a group of complex conditions involving single values and intervals).
Variable Exits: SAP Exits
SAP exits are variables delivered by SAP within BI Content that contain predefined sets of the most commonly used rules associated with different types of InfoObjects. You can use them according to your needs, but you may need to import them from the BI Content and activate them to be used in queries.
Tip
You can find the variables provided by SAP by searching for them using object type ELEM with subtype VAR. The technical names of SAP-delivered objects always begin with a number. For example, to retrieve the current calendar month/year, you can use the SAP-delivered variable Current Month (technical name: 0CMONTH), which is referenced to the characteristic Calendar Year/Month (technical name: 0CALMONTH) in the query filter.
Restriction
Note that the SAP exit processing type can’t be used with external SAP HANA views. The SAP HANA exit processing type must be used instead when the query is created with the External SAP Hana View setting.
Variable Exits: Custom Exits
You can create variables with specific coding to meet your requirements’ rules and complexity. Custom exits allow you to generate default values, populate variable values automatically, and perform validations on all variables after they’re populated.
To use a custom exit variable, you need to create a Business Add-In (BAdI) enhancement implementation for the enhancement spot RSROA_VARIABLES_EXIT; it must include the BAdI definition RSROA_VARIABLES_EXIT_BADI. You can find this enhancement spot in the ABAP package RSROA_VAR either via the ABAP Development Tools perspective in Eclipse or via Transaction SE80. The RSROA_VARIABLES_EXIT_BADI enhancement spot is called several times when the query is executed, and the I_STEP parameter identifies the event processed. Table 7.1 lists the purposes of and actions performed in each step.
Step | Description |
---|---|
I_STEP = 0 | The step isn’t called from the variables screen, but from the authorization check or query monitor. |
I_STEP = 1 | The step is called before the variables screen is shown. |
I_STEP = 2 | This step is only used for non-input-ready variables and triggered after proceeding from the variables screen. |
I_STEP = 3 | The step is called after proceeding from the variables screen. If any exception is triggered, the variables screen appears again. |
Table 7.1 Custom Exit Processing Steps and Their Triggering Events
If a query contains multiple variables with customer exits, when the enhancement spot is called, the system passes all variables values in the internal table I_T_VAR_RANGE, allowing you to create complex logic combining values from several variables of the query.
Restriction
The customer exit processing type can’t be used with external SAP HANA views. The SAP HANA exit processing type must be used instead when the query is created with the External SAP Hana View setting.
Variable Exits: SAP HANA Exits
This processing type is used when you need to implement complex rules in variables and you also want to generate an SAP HANA calculation view linked to the query. The creation of an SAP HANA view is possible because this processing type allows you to use an ABAP-Managed Database Procedures (AMDP) class implementation to determine values for variables.
You can use this processing type with characteristic value variables and formula variables. For formula variables, the variable Entry Type must be set to mandatory.
Unlike customer variables, which allow multiple values and intervals on the variable, SAP HANA exit variables always represent a single value.
The enhancement implementation of an SAP HANA exit is executed during the query runtime and it is either called before the selection screen is shown for processing and populating the input-ready variables, or after proceeding the query execution from the selection screen for processing non-input-ready variables.
Note
You can read up to 20 variable contents from the other variables on the screen if you need to reference their contents during processing.
Since this processing type has SAP HANA database procedures associated with its implementation, you can only create the enhancement implementation for the enhancement spot RSROA_VARIABLES_HANA_EXIT in the ABAP Development Tools perspective in Eclipse.
The RSROA_VARIABLES_HANA_EXIT enhancement spot is also contained in the package RSROA_VAR. The BADI implementation class requires an AMDP class and must contain the following interfaces: IF_BADI_INTERFACE, IF_AMDP_MARKER_HDB, and IF_RSROA_VAR_HANA_EXIT.
Figure 7.16 shows the enhancement spot for the SAP HANA exit variable implementation with the methods to be used: GET_PROPERTIES and PROCESS. After the method name, you must enter the addition by database procedure for hdb language SQLSCRIPT and your code must comply with SQLScript syntax.
Figure 7.16 Enhancement Spot in Package RSROA_VAR for SAP HANA Exit
There are two methods to consider, as follows:
-
IF_RSROA_VAR_HANA_EXIT~GET_PROPERTIES
Use this method to setup the mapping from variables and their values to the input parameters of the method IF_RSROA_VAR_HANA_EXIT~PROCESS. For this to be possible, the parameter C_IS_ACTIVE must be set to “X”. This mapping is stored in the C_TS_VNAM_INDEX parameter, which maps each variable value from the query to the parameter I_VAR_VALUE_<n>. For example, the {0CYEAR, 1} record in the C_TS_VNAM_INDEX parameter indicates that the value of the variable 0CYEAR is assigned to the parameter I_VAR_VALUE_1. -
IF_RSROA_VAR_HANA_EXIT~PROCESS
You can use this method to set the new value of the variable. The C_VALUE parameter is used to receive the new value of the variable. Also, you can use the I_VAR_VALUE_1 to I_VAR_VALUE_20 parameters collections to retrieve any content from other variables from the variables screen for this process.
Tip
The CL_RSROA_HANA_EXIT_FALLBACK class can be used as a template to create the customized class for this enhancement spot. It has all the methods and interfaces defined according to the prerequisites listed previously.
Once the implementation is active, as shown in Figure 7.17, access the ABAP Development Tools perspective in SAP HANA Studio via the menu path Window • Open Perspective • Others….
Figure 7.17 ABAP Development Tools Perspective Icon in List of Available Perspectives
Once the ABAP Development Tools perspective is connected to SAP BW/4HANA via a project, you can search for your class and open it in SAP HANA Studio, as shown in Figure 7.18.
Figure 7.18 Coding for AMDP Class in SAP HANA Studio
This code processes variables at the moment the query is executed before displaying the variables screen. Then, default values are shown as filter suggestions for the query data selection (see Figure 7.19).
Figure 7.19 Query Execution Showing Prompt Screen, with Reporting Year Populated with Last Year per Rule
7.1.5 Query Sheet Definition
Use the Sheet Definition tab shown in Figure 7.20 to create the structure of your query. Add collections of characteristics, key figures, formulas, structures, and restrictions to help you navigate in the report, perform different analyses, and create significant information for your business. These elements can be placed in Rows or Columns, or be set as Free characteristics.
Free characteristics are objects that won’t be shown in the default view of the report immediately after executing it. They’re available in the report to be added during runtime, helping you create dynamic analyses.
Figure 7.20 Query Sheet Definition Tab
The object types available to be added to the query are defined as follows:
-
Characteristics
These are InfoObjects or fields available in the InfoProvider that give context to the amounts and results on the report. These characteristics can be of the following types:- Time characteristics are characteristics with references in time format, such as date, month, fiscal year, fiscal period.
- Master data characteristics are characteristics that may contain master data attributes, texts, and hierarchies. Master data is data that doesn’t change frequently and it isn’t present physically in a transaction but referenced via a pointer called SID (Surrogate ID).
- Hierarchy characteristics are characteristics that represent the master data in a tree structure contained in the InfoObject it references—for example, a product hierarchy.
- Unit characteristics are master data characteristics with currencies or units of measure. They’re frequently associated/linked to key figures to give context to the amount the key figure represents.
- Non-master data characteristics are attributes within the transaction data itself—for example, sales order number.
-
Basic key figures
These are InfoObjects that usually represent numbers. They may be associated with a unit type characteristic in cases of currency amounts or quantities. -
Calculated key figures
These are reusable elements; they’re created with an association to an InfoProvider and can be used in multiple queries that share the same InfoProvider. With calculated key figures, you can define formulas and aggregations. If you need a special calculation in a query, you can create a local element in the query referenced to the calculated key figure definition and apply the changes to this new element. -
Restricted key figures
These, like calculated key figures, are reusable elements. With restricted key figures, you can define filter selections to further restrict the records that will be used for the key figure. For example, in an InfoProvider with planned and actual amounts in the same basic key figure, you may want to create two separate restricted key figures to show the planned and actual amounts split in the report into two columns, without adding a navigation level to your report that might contain many characteristics. -
Structures
These are groups of characteristics or key figures that allow a restriction to be applied for multiple elements with a central rule. You can create a maximum of two structures per query, and only one of these can contain key figures. You can use these structures in either rows or columns in the query. -
Global structures
These are structures that were created linked to an InfoProvider directly and can be reused in multiple queries that share the same InfoProvider; changes to these structures are replicated to those queries.
You can add objects in each section of the report sheet by right-clicking the area in which you want to add the objects and selecting the desired option from the context menu, as shown in Figure 7.21.
Figure 7.21 Context Menu with Options to Add Objects to Report Sheet
7.1.6 Query Elements
Query elements are objects added to the query sheet definition to form the structure of the query. The following subsections will describe the properties and use of characteristics, key figures, and formulas.
Characteristics
When you add characteristics to the query sheet definition, they inherit properties defined in the InfoObject as default settings for reporting. However, you can override some of them for the specific needs of your query, along with adding extra options.
Figure 7.22 shows the options you can specify for query characteristics. All properties that you can override have a Toggle Default Value/Manual Entry button (pencil icon) beside them; the ones for which you can use variables to determine their contents during query execution have an Add Text Variable button icon beside them.
Figure 7.22 Properties of Query Characteristics
Let’s examine these properties and some important details of each:
-
General: Description
Shows the description defined in the InfoObject or InfoProvider field by default. You can change the description for this query as shown in Figure 7.22, in which the description was changed to Country for the InfoObject Business Unit (ZBUS_UNIT). -
Value Output Format
For an InfoObject that contains text master data, this property allows you to show the key (code associated with the transaction data) and/or text (associated with the code via master data). For example, as shown in Figure 7.22, we configured to display only the text in the property Display As for the country object. In the property Text Output Format, you can also choose the size of the text you want to display in case you have different text sizes (short, medium, or large) stored in the master data texts of the InfoObject. -
Sorting
Allows you to define the default sorting for this characteristic when shown in the report. -
Result Output Format
Allows you to define the how the result rows are displayed for the data grouped by this characteristic. As shown in Figure 7.22, we selected to Never display the subtotals to make this query a single list of values. -
Display Level
Allows you to create tailored views of your query for certain groups of end-users. If you have filters created on characteristics in your query, you can set such filters to In Detailed Overview Only and they’ll only be shown to end users when the detailed view is selected in the frontend. When In Normal Overview is selected, as in Figure 7.22, the filter will be shown in both normal and detailed query views. -
Extended: Access Type for Result Values
Allows you to define data access options for the query results:-
Master data
Always displays a row of data even without transaction data if values for this characteristic are maintained in the master data. -
Posted Values
Only shows data rows when transaction data is present for the selected characteristic values. -
Characteristic Relationships
Restricts the posted data to be shown only for allowed combinations of the characteristics with this attribute—for example, compounded characteristics, hierarchies, or in planning areas.
-
Master data
-
Extended: Filter Value Selection
Allows you to define how filter values are selected and displayed during query execution. With this option, you can set the filter values to come from the master data table so that the user can select values applicable to the query execution, instead of coming from the transactional data, which may provide better filter performance. -
Extended: Refresh Variables
Allows you to define how variables that you use in default values or for a hierarchy’s presentation behave:-
Dynamically
Uses the current settings of the navigation view during query runtime. -
As Designed
Uses the query filter and hierarchy definition settings for refreshing these variables.
-
Dynamically
If your characteristic has hierarchies associated with it, the Hierarchy tab allows you to select specific hierarchies and levels to be used in the query, as shown in Figure 7.23.
Figure 7.23 Hierarchy Properties for Characteristics in Query Design
The hierarchy properties are as follows:
-
General
In this section, you can enable the use of a hierarchy for navigating and drilling down through data in the query runtime and for selecting filter values to be used for data selection. You can also use variables to determine the name of the hierarchy to be used via automatic calculation or via input from the user in the prompt screen for selection variables. -
Display Nodes
Allows you to define how the nodes will be displayed in the report and up to what level of the hierarchy the data will be selected and displayed when the hierarchy is expanded. -
Sorting
Defines the sorting method for the hierarchy. It can be based on the key or text of nodes.
Key Figures
Key figures also have specific properties that can be customized for specific query needs. Figure 7.24 shows the following general properties:
-
General: Description
Shows the description defined in the InfoObject or InfoProvider field by default. You can change it for this query via clicking the Toggle Default Value/Manual Entry button (pencil icon) and you can define a text variable to determine its value. -
Constant Selection
When this option is selected, it ignores the query filters and navigation during runtime by setting a constant filter in a characteristic or structure of your report. This helps you create comparison of key-figures in different granularities. For example, a plan and actual comparison, when you have yearly plan amounts and monthly actuals amounts. -
Display
Allows you set how the key figure is displayed during query execution. You can define the scaling factor, sign position, decimal places displayed, a highlight or normal display, and whether it’s permanently hidden during query execution. -
Selection Details
Allows you to define additional restrictions to the key figure. For example, in an InfoProvider with both planned and actual data stored or calculated in the same key figure, you can add to the Selection Details panel of that specific key figure the characteristic that defines actual or planned and add a restriction to it to filter the data to the specific key figure that needs to be displayed.Figure 7.24 Properties of Key Figures in Query Designer
-
Unit and Currency Conversions
You can also perform conversions of currency and quantity units. The Conversion tab, shown in Figure 7.25, contains the parameters you need to enter to perform these conversions. As an example, we set a currency conversion from USD to EUR.Figure 7.25 Conversion Properties in Query Designer
-
Conversion Type
This is an SAP BW/4HANA modeling object that defines how the conversion is performed. You must create the conversion types beforehand in SAP BW/4HANA using Transaction RSUOM for unit conversion and Transaction RSCUR for currency conversion. -
Variables in Conversion Types
If you want to use variables in the currency translation type, you must create them beforehand. You can create these variables in the Eclipse modeling perspective by right-clicking the InfoObject in which you need the variable created and choosing New… • Variable…. -
InfoObject Types for Variables
You can use the following object types for variable creation, depending on the conversion type, as follows:- Currency Conversion: Exchange Rate Type (example: 0RTYPE), Currency (example: 0CURRENCY), or Date (example: 0DATE).
- Unit Conversion: Unit (example: 0UNIT).
-
Conversion Type
-
Local Calculations
You can predefine local calculations for a formula or key figure as shown in Figure 7.26. These calculations are performed on the frontend tool and they only change how the values are displayed. If you have other calculations or formulas that use these values, the frontend tool uses the original value provided by the SAP BW/4HANA system. The options available to customize the local calculations are as follows:-
Calculate Result As
Allows you to select a rule to be used to recalculate the results of a report locally—for example, to calculate results based on values displayed rather than from original values. -
Calculate Single Value As
Allows you to select a rule to be used to recalculate individual values of a report locally—for example, to display the rank position instead of the amount. -
Calculation Direction
Always from the top towards the drilldown direction. For example, if characteristics are in rows and key figures in columns, you can choose the calculation direction to be from top to bottom.
-
Calculate Result As
Figure 7.26 Local Calculation Properties in Query Designer
Recommendation
Because local calculations are performed on the client side, for large datasets, these local calculations may significantly affect the performance of the query. Therefore, we recommend using exception aggregations or calculated key figures, because they’re pushed down to be executed on the SAP HANA database instead.
Formulas
You can create specific calculations using key figures in a structure in the query by using a formula. You can include basic key figures, restricted key figures, calculated key figures, reusable key figures, and variables in the formula definition.
To add a formula, open the context menu of the structure that contains the key figures and select New Formula…. Figure 7.27 shows the formula definition screen in which you define your formula. The properties shown are as follows:
-
Technical Name
Define a technical name for the formula. -
Description
Edit the description of the formula, or use variables to define the description at runtime. -
Formula
This is where you define your formula. You can use the calculator buttons and available formula elements arranged in groups. These groups and formula elements are accessible in the panels at the bottom of the screen.
Figure 7.27 Formula Definition Screen in Query Editor
Note
Some operations, such as % of the Grand Total, aren’t available in SAP HANA views. For such operations, you should develop these calculations on the frontend tool for which the SAP HANA view is used as the source of data.
7.1.7 Query Conditions
You can use query conditions to formulate different sets of rules to narrow down your analysis and filter the query data so that only part of the data retrieved is displayed in the query results—for example, to display only the top 10 countries with the largest volumes of sales items delivered.
On the General tab (see Figure 7.28), you can define the following:
-
Description
Stores a short description of the condition. -
Active
Marks whether the condition is active or not. -
Condition Parameters
The rules defined to filter the data to be displayed. They can be of two types:-
Threshold Value
Limits the data displayed according to range of values of a key figure—for example, to limit quantity delivered to greater than 100,000 units. -
Ranked List
Limits the data displayed according to certain ranking options—for example, to show the top five countries in revenue.
-
Threshold Value
Figure 7.28 Conditions Definition Screen in Query Editor
On the Assignments tab, you can define characteristics that will be used to apply the conditions. You can apply the conditions independently on each characteristic or on the most detailed characteristic used in the drill-down.
Note
You can add more than one condition parameter and more than one active conditions. When you have multiple active conditions rules, the system displays only data that satisfies all conditions rules.
However, if you have multiple condition parameters in one condition rule, the system shows a union of the data retrieved using each of the condition parameters.
7.1.8 Query Exceptions
Query exceptions allow you to define different limits for query results. Deviations from these limits are highlighted in different colors, which helps you quickly identify areas that require attention. In the General tab shown in Figure 7.29, you can define the following:
-
Description
Stores a short description of the exception. -
Active
Marks whether the condition is active. -
Exception Parameters
Define the ranges, colors, and intensities of the colors. There are three colors available, with three intensity levels for each.Figure 7.29 Exceptions: General Tab in Query Editor
In the Definition tab, you can define in which cells or group of cells the alerts will be displayed. For example, in Figure 7.30, we set the alerts defined on the quantity column, performing the evaluation of the amounts before list calculation, and display the alerts in data cells of quantity column and also display in characteristics cells on the row linked to the quantity amount being alerted.
In the Cell Restrictions tab, you can define restrictions to apply to alerts. For example, in Figure 7.31, we selected to show alerts on individual rows but not on result cells.
Figure 7.30 Exceptions: Definition Tab in Query Editor
Figure 7.31 Exceptions: Cell Restrictions Tab in Query Editor
A visual example of the alerts settings described in the previous paragraphs is shown in Figure 7.32. There, we can see that the Quantity column and the characteristics present in the report have different alerts; the totals remain set in their standard colors.
Figure 7.32 Example of Query Alerts in Transaction RSRT
Note
Alerts aren’t transferred to the SAP HANA views associated with the SAP BW/4HANA query. Therefore, you can see alert colors by using an ABAP BICS interface via Transaction RSRT or in a frontend tool such as SAP Lumira Designer.
7.1.9 Query Transport
When queries or other SAP BW/4HANA objects will be transported to an environment for quality testing and then to a productive environment, best practice is to create these queries under a package that requires a transport request to collect all the query elements, ensuring that you transport the intended version of all developments to the upper environments.
When creating a query, as described in the Section 7.1.1, you had to link the query to a package. In SAP BW/4HANA, we have a package with the technical name $TMP for local developments, package delivered by SAP, and custom client development packages. If you enter a package name other than $TMP, a new pop-up window will open, asking for the transport request to be used (see Figure 7.33).
In the Selection of Transport Request window, you can do one of the following:
- Select a transport request from the list of open transports you are involved you’re assigned to (Choose from requests in which I am involved)
- Create a New Request, in which case you must enter a brief description of the transport request in the Request Description field
- Directly Enter a Request Number
Figure 7.33 Selection of Transport Request for Queries
Note
You can access transport requests associated with your user via ADT Perspective • Transports or via Transaction SE09.
To help organize the transport list and verify that the dependent objects for the query are selected, go to the Dependency Structure tab of the SAP BW/4HANA query editor. This tab shows all global elements associated with and used in the query. As shown in Figure 7.34, the Dependency Structure tab shows that the calculated key figure ZCK_PRICEAVG is used in the selected query.
Figure 7.34 Dependency Structure Tab in Query Editor