Author Bio: Sourav is having more than 6 years of experience in SAP BI, worked on a number of support and enhancement projects throughout his career. He is currently working with IBM India Pvt Ltd.


Introduction: Normally Bex queries runs out of either multiprovider/infoset which again consists of cubes, DSO and master data. Based on the business demand sometimes it is needed to change the characters values (contained in the query) using a different table or using a complex logic which is impossible to determine during the data load process. Meaning is when we don’t want to read a character from the infoprovider during the query execution, we go for a virtual character which would be included in the query but the value of which would not come from the infoprovider.

Precaution: While using a virtual character, please note that the query performance would be very slow as aggregates won’t be used for that character and all those which are used to derive that virtual character. Exit code would run for all the queries in the infoprovider.

Process: Let us assume that there is a DSO which contains Employee (ZEMPLOYEE), company code (0COMP_CODE) and Amount (0AMOUNT). The business scenario is that query should not show company code from the DSO, rather it should read ZEMPLOYEE master data to get the attribute company code. Please find the screenshot below –



ZEMPLOYEE master data:


In the report based on the DSO, we would like to see company code as GB01 whereas DSO stores company code as GB40. We would write the exit code using a standard BADI. Steps are given below –

Step1: Go to Tcode SE19 and create an implementation for BADI . Under section ‘create implementation’ give Classic Badi name as RSR_OLAP_BADI. Press create and give the implementation name.


Step2: When implementation is created, in the next screen the following information are visible –

1. Interface name – IF_EX_RSR_OLAP_BADI.

2. Name of the implementing class – This is editable.

3. Method – Define, Initialize and Compute.

4. Define filter (This is available under the Attributes tab)  – Give the name of the infoprovider.



Step3: We need to write the codes only under define and compute methods. Select from menu Goto -> Sample code -> Copy. This would fill the Initialize method.

Step4: Now open the Define method. Here we need to define which character we are going to use as virtual and which character we want to use only for read purpose. In our example, ZEMPLOYEE should be read from the infoprovider and the virtual character should be 0COMP_CODE. This identification should be based on the read mode –

1. Mode = ‘1’, this is referred as ‘No selection’ which makes this a virtual character.

2. Mode = ‘0’, this is referred as ‘Read access’, is not a virtual character.


Step5: The next step is to add the availability of the characters in the attribute section of the implementing class (ZCL_IM_TEST_VCH). Please note that we need to add all the characters here in the format P_CHA_<Character name>. For example, 0COMP_CODE should be P_CHA_0COMP_CODE and the associated type should be Integer (I).


Sample code for the Compute method is given below –

METHOD if_ex_rsr_olap_badi~compute.
   FIELD-SYMBOLS: <l_comp_code> TYPE /bi0/oicomp_code,
                               <l_zemployee>  TYPE /bic/oizemployee.

   DATA: w_employee TYPE /bic/pzemployee,
             _th_actcp1   TYPE STANDARD TABLE OF /bic/pzemployee.

*Check if Company code exists in the report
   IF p_cha_0comp_code > 0.
     ASSIGN COMPONENT p_cha_0comp_code OF STRUCTURE c_s_data TO <l_comp_code>.

*Check if Employee exists in the report
   IF p_cha_zemployee > 0.
     ASSIGN COMPONENT p_cha_zemployee OF STRUCTURE c_s_data TO <l_zemployee>.

*Fill records from Employee master data into internal table
   IF _th_actcp1[] IS INITIAL.
     SELECT * FROM /bic/pzemployee INTO TABLE _th_actcp1.

*Read the internal table using the employee number in the report
   READ TABLE _th_actcp1 INTO w_employee WITH KEY /bic/zemployee = <l_zemployee>
                                                                                     objvers             = ‘A’.

*If an entry found in the master data, then assign the company code from employee master data

*in the report else use the value from the info provider
   IF sysubrc = 0.
     <l_comp_code> = w_employeecomp_code.
     CLEAR <l_comp_code>.


Step6: Now execute the report which is based on the DSO’s data. Still it should show the company code value from Employee master data (attribute).


*******************************************************Thank You*************************************************************

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

Leave a Reply