Virtual Key Figures and Characteristics Values Filling via BADI Implementation

Scenario

Virtual Characteristic / Key Figures are used when Info Object values determination in runtime of SAP BEx Query execution is required. Virtual Characteristics/Key Figures are used when no transformation rule exists to populate them in SAP Cube/DSO. Virtual Caracteristic/Key Figure values are calculated using either SAP BADI (RSR_OLAP_BADI) or SAP Enhancement (RSR00002).

Business Case

To update SAP BI Reports for SAP Solution Manager (SOLMAN) the external engine for data collection in the cubes/DSO is used. There is no SAP standard BI data flow under SOLMAN cubes, the data are loaded via customizing inside SOLMAN and modules. It this case BI cubes enhancement with additional attribute can not be done easily and quickly.

Based on the customer requirements it was necessary to build the report with two additional columns: Reporter Name and Processor Name. So, for each IT incident or Service request it was necessary to show Reporter Name and Processor Name in the same line as the ticket number.

But in standard SOLMAN info cubes there is one characteristic ‘0SPRBPNO’ Business Partner for all roles of business process participants (Payer, Customer, Processor, Sold-To-Party, Reporter, etc.). The roles of every Business Partner are defined in characteristic ‘0SPRBPROLE’ Business Partner Role. So, it was not technically possible to show two Business Partners for the same ticket number, because there is only one characteristic  ‘0SPRBPNO’ Business Partner in the cube.

The solution was found via enhancement of Multiprovider with one additional characteristic with Role 0SPRBPROLE = SLFN0004 “Processor”. The Processor was filled in run time of BEx query execution.

The procedure of setup run-time update of virtual characteristic value is shown below. The values are determined using BADI (RSR_OLAP_BADI)

Step 1

The creation of a Virtual Characteristic ‘ZPRCSSR’ Processor and filling it with the value ‘#’ Not Assigned: every Message has Reporter, but Processor can not be assigned for some period of time. A new created characteristic was added to ‘0SPRDUMMY’ Dummy Cube:

sap_bi_virtual_char_01

Multiprovider ‘0SPRMDAT2’ Incident Management Reporting – Message Reporting is built on InfoSet ‘0SPRLAST’ Incident Management Reporting – Messages (complete data) and Infocube ‘0SPRDUMMY’ Dummy Cube. The Virtual Characteristic ‘ZPRCSSR’ was added the the Multiprovider as well:

sap_bi_virtual_char_02

Step 2

Query ‘ZGMC_SPR_WTQ_IN_T_OVERVIEW_01’ GMC: Total Number of Incidents – This and Last Week is built on Multiprovider (0SPRMDAT2).

The Virtual Characteristic ‘ZPRCSSR’ was added to this query:

sap_bi_virtual_char_03

Step 3

To determine the values for virtual characteristic the following steps were taken:

Navigate to BADI Definition ‘RSR_OLAP_BADI (Virtual Characteristics and Key Figures in Reporting)’ through transaction SE18 or SE19 and creation of Implementation ‘ZITSM_ADD_CHARACTERS’ for BAdI RSR_OLAP_BADI:

sap_bi_virtual_char_04

and assigning Infoprovider (Filter) as ‘0SPRMDAT2’:

sap_bi_virtual_char_05

Step 4

At the tab page “Interface” a new class creation should be done.

The Name of implementing class was ZCL_IM_ITSM_ADD_CHARACTERS. There are 3 methods in this class: DEFINE, INITIALIZE and COMPUTE. To generate ABAP code for the method INITIALIZE the following was done:

sap_bi_virtual_char_06

Step 5

Declare the variables for Characteristics and Key Figures in the Class Interface ZCL_IM_ITSM_ADD_CHARACTERS:

Key Figure Name: P_KYF_<Key Figure Infoobject>

Characteristic Name: P_CHA_<Characteristic Infoobject>

Level: Instance Attribute, Visibiltiy: Public

sap_bi_virtual_char_07

Attribute Infobject
P_CHA_ZPRCSSR Characteristic: ZPRCSSR (Processor)
P_CHA_0SPRMGNO Characteristic: 0SPRMGNO (Message Number)

The next step is the creation of the ABAP Codes for the methods IF_EX_RSR_OLAP_BADI~DEFINE, IF_EX_RSR_OLAP_BADI~INITIALIZE and IF_EX_RSR_OLAP_BADI~COMPUTE.

Method IF_EX_RSR_OLAP_BADI~DEFINE

The Method is used to append the internal tables for the Characteristic (c_t_chanm) and Key Figures (c_t_kyfnm).

sap_bi_virtual_char_08

METHOD IF_EX_RSR_OLAP_BADI~DEFINE .

DATA: l_s_chanm   TYPE rrke_s_chanm,
l_kyfnm     TYPE rsd_kyfnm.
FIELD-SYMBOLS:
<l_s_chanm> TYPE rrke_s_chanm.

CASE i_s_rkb1d-infocube.

WHEN ‘0SPRMDAT2’.

*     characteristic
l_s_chanm-chanm = ‘ZPRCSSR’.
l_s_chanm-mode  = rrke_c_mode-no_selection. ” rrke_c_mode-read / rrke_c_mode-no_selection
APPEND l_s_chanm TO c_t_chanm.
CLEAR l_s_chanm.

l_s_chanm-chanm = ‘0SPRMGNO’.
l_s_chanm-mode  = rrke_c_mode-read. ” rrke_c_mode-read / rrke_c_mode-no_selection
APPEND l_s_chanm TO c_t_chanm.
CLEAR l_s_chanm.

l_s_chanm-chanm = ‘0SPRCRMGUID’.
l_s_chanm-mode  = rrke_c_mode-read. ” rrke_c_mode-read / rrke_c_mode-no_selection
APPEND l_s_chanm TO c_t_chanm.
CLEAR l_s_chanm.

**     key figure
*     l_kyfnm = ‘…’.
*     APPEND l_kyfnm TO c_t_kyfnm.

ENDCASE.

ENDMETHOD.

Method IF_EX_RSR_OLAP_BADI~INITIALIZE

The Method is used to dynamically assign random numbers to the Characteristic and Key Figure Variables. It is filled in as a result of Step 4.

sap_bi_virtual_char_09

METHOD IF_EX_RSR_OLAP_BADI~INITIALIZE .

DATA: l_global_name TYPE string.
FIELD-SYMBOLS:
<l_global>    TYPE i,
<l_s_sfc>     TYPE rrkg_s_sfc,
<l_s_sfk>     TYPE rrkg_s_sfk.

* there’s no need to change this method
* Just create attributes for each charactersitic
* with name P_CHA_<characteristic> TYPE i.
* and constants for each key figure with name
* P_KYF_<key figure> TYPE i.

CLASS cl_exm_im_rsr_olap_badi DEFINITION LOAD.

* get field postions for characteristics in structure
LOOP AT i_th_sfc ASSIGNING <l_s_sfc>
WHERE user_exit NE rrke_c_mode-none.
* field name in structure is keyreturnnm
* name of the global variable
CONCATENATE ‘P_CHA’ <l_s_sfc>-chanm
INTO l_global_name
SEPARATED BY ‘_’.
* fill the global variable
UNASSIGN <l_global>.
ASSIGN (l_global_name) TO <l_global>.
CHECK <l_global> IS ASSIGNED.
<l_global> = cl_exm_im_rsr_olap_badi=>get_field_position_d(
i_fieldnm = <l_s_sfc>-keyreturnnm
i_s_data  = i_s_data ).
ENDLOOP.

* get field positions for key figures in structure
LOOP AT i_th_sfk ASSIGNING <l_s_sfk>
WHERE value_returnnm IS NOT INITIAL.
* name of the global variable
CONCATENATE ‘P_KYF’ <l_s_sfk>-kyfnm
INTO l_global_name
SEPARATED BY ‘_’.
* fill the global variable
UNASSIGN <l_global>.
ASSIGN (l_global_name) TO <l_global>.
CHECK <l_global> IS ASSIGNED.
<l_global> = cl_exm_im_rsr_olap_badi=>get_field_position_d(
i_fieldnm = <l_s_sfk>-value_returnnm
i_s_data  = i_s_data ).
ENDLOOP.

ENDMETHOD.

Method IF_EX_RSR_OLAP_BADI~COMPUTE

It is used for defining business logic for assigning the values to the characteristics or KeyFigures.

sap_bi_virtual_char_10

METHOD if_ex_rsr_olap_badi~compute .

DATA lv_system TYPE string.

CASE i_s_rkb1d-infocube.

WHEN ‘0SPRMDAT2’.

FIELD-SYMBOLS <fs_0sprmgno> TYPE any.
FIELD-SYMBOLS <fs_zprcssr> TYPE any.
FIELD-SYMBOLS <fs_0sprcrmguid> TYPE any.

ASSIGN COMPONENT p_cha_0sprmgno OF STRUCTURE c_s_data TO <fs_0sprmgno>.
ASSIGN COMPONENT p_cha_zprcssr OF STRUCTURE c_s_data TO <fs_zprcssr>.
ASSIGN COMPONENT p_cha_0sprcrmguid OF STRUCTURE c_s_data TO <fs_0sprcrmguid>.

SELECT SINGLE sprbpno FROM /bi0/asprdatb00 INTO <fs_zprcssr> WHERE sprcrmguid = <fs_0sprcrmguid> AND sprbprole = ‘SLFN0004’.

ENDCASE.

Step 6: Execute

To see the result of Virtual Characteristic ZPRCSSR “Processor” filling the query, the following SAP transaction was executed: RSRT -> ZGMC_SPR_WTQ_IN_T_OVERVIEW_01 -> Execute

sap_bi_virtual_char_11

Leave a Comment

Contact Us

Please do not hesitate to contact us, so one of our experts will get back to you asap!

Not readable? Change text.

Start typing and press Enter to search