Virtual Characteristics and Key Figures in BW/4HANA
1. Virtual Characteristics and Key Figures in BW/4HANA
This blog covers the usage of virtual key figures and characteristics in BW/4HANA (BW4) utilizing the BAdI RSROA_OLAP_BADI. Virtual key figures and characteristics are InfoObjects that exist in the Composite Provider, but their values are not read from the included InfoProvider; instead, they are determined at the execution time of the query dynamically using ABAP coding.
I used the predecessor of this BAdI a long time ago (likely BW 2.1c) and came across it again during a recent BW4 InPlace Migration project. In the migrated system a specific report did not display any information for certain key figures. It turned out that the old version of the BAdI (RSR_OLAP_BADI) was used, but it no longer worked in BW4. The BW4 Conversion checks did not highlight this. However, the latest version of the BAdI made it to BW4 and can still be used.
What are potential scenarios for the usage?
- Custom calculations or logic based on specific conditions.
- Applying complex algorithms or logic that require custom implementation.
- Adding logic that depends on dynamic time-based logic or validity intervals.
- Tailoring data displayed in reports based on user-specific preferences.
- Enriching reports with data from external systems during runtime.
- Identifying anomalies or exceptions in data during runtime.
- Testing new logic or calculations without modifying the underlying data model.
- Avoiding data redundancy and reducing storage costs by not persisting data that can be calculated dynamically.
However, this functionality has one disadvantage: every calculation performed at this stage impacts query performance, especially when dealing with many dimensions and key figures. This is the reason why this functionality should only be applied in specific use cases.
The SAP help for this topic can be found here. Additional information can be found in the following note: 1717880 – Virtual Key Figures & Characteristics in BW Queries.
The following demo will demonstrate how we use this BAdI to calculate virtual key figures in BW Reporting based on a dedicated scenario.
2. Implementation Scenario
For demonstration purposes we created two ADSOs, ZPEMPADSO (Employee with Starting Date) and ZPSALADSO (Employee Salary and status if the employee is still active in the Company).


We only use the ZPEMPADSO (Employee with Starting Date) in our Composite Provider

The fields Employee Salary and Employee Total Year Experience, which we add to the Composite Provider without mapping (on-the-fly key figures associated with InfoObjects), will use the BAdI to look up values from another ADSO, ZPSALADSO (Employee Salary and Active), so we don’t need to add these key figures to our Employee ADSO, ZPEMPADSO.
Now we create the RSROA_OLAP_BADI via SE18, then we must add the query name into filter values, in this case ZPDEMOEMP_Q001:

In the implementing class, at least the following methods need to be implemented:
DEFINE: This method is only called during generation of the query; you need to specify the characteristics/key figures (use the technical names, e.g. chanm=’0MATERIAL‘ or kyfnm=’0AMOUNT‘) you would like to use in the exit. In our case we defined the two characteristics and two key figures that we added to the Composite Provider.

For L_S_CHANM-MODE there are 3 options to be considered:
- READ: You can use the values of this InfoObject in the COMPUTE method, but you cannot change them!
- NO_SELECTION: The values of this characteristic can be changed in the query.
- FILTER: You cannot change characteristic values in COMPUTE_TABLE method, but you can delete undesired records from the data table (filter the data).
COMPUTE_SINGLE: Here the changes and calculations are carried out; this method is called once per data record (C_S_DATA).

COMPUTE_TABLE: Here the changes and calculations are carried out; this method is called in table result(C_T_DATA):

3. Query Execution and Result
After the implementation of the BAdI you only add the virtual key figures to the query.

Those key figures are then calculated on the fly using the coding from above:
- The fields ZP Employee Salary and Total Year Employee Experience are calculated virtually using the RSROA_OLAP_BADI with the reference of ADSO ZPSALADSO (Employee Salary and Active).
- Employee 6 and 8 are filtered out.
Tip: If your coding is not being called by the query, ensure that the query was re-generated. Only then the DEFINE Method is being called. If the ABAP coding is still not being processed, I would have another look at the filter.
4. Summary
The functionality of virtual characteristics and key figures in BW/4HANA provides a powerful tool for dynamically enhancing reporting capabilities without altering the underlying data model. While it can be invaluable in scenarios such as validation reports, complex calculations, and runtime data enrichment, it is essential to carefully evaluate the performance impact and suitability of this approach for specific use cases. With proper implementation, leveraging the RSROA_OLAP_BADI can add significant flexibility and efficiency to your reporting landscape.