Virtual Characteristics without the use of BADI:
I found a lot of “step by step” documentation on Virtual Characteristics and Key figures in SDN, however all of them pointed towards the use of BADI. I wanted to make use of this functionality but without the use of BADI, in a traditional way of coding in enhancements.
This documentation is for the purpose of basic understanding and I do not have a real time requirement at hand, so I’m creating a simple scenario of my own and realizing it with the use of a Virtual Characteristics. I plan to display the text for the characteristic plant in the report. The easier and best way would have been to make use of the display property for the characteristic 0PLANT in the BEx query. However as my pursuit was to understand Virtual Characteristics I will be realizing this through enhancements.
Step1: Create an info object which you would want to get populated virtually only during the query execution.
Step 2: Insert this characteristic into the infocube and multiprovider. Two things to note here would be as below:
i. Virtual Characteristic will not hold any data at any point of time, so these could be added into any of the dimension tables (except the Package, Time and Unit) and their contribution to the dimension table size is nil.
ii. Map the virtual characteristic to the infocube in characteristic identification of the multiprovider, else the activation of multiprovider will fail.
Running the query without the population logic will fill the Virtual Characteristicswith NOT ASSIGNED values:
Step 4: Coding
The coding part, unlike the other exits used in SAP BW enhancements, is written under different includes for Virtual Characteristics and key figures.
Top / Global declaration:
Under global declarations variables related to the characteristics being used for the calculation and the virtual characteristics have to be declared. It is mandatory to ensure that the variable names being declared have the format G_POS_<INFOPROVIDER NAME>_<CHARACTERISTICS>.
In the actual include the characteristics and their modes are passed. In the present example the characteristic 0PLANT is read from the info provider WOSC_MP and characteristic ZVCHAR_1 is populated into the report. Hence the mode should be “read” for 0PLANT and “no selection” for ZVCHAR_1. If more than one characteristics are read then all of them should have the value MODE populated with “Read”.
Initialization exit is not to be changed or altered. It has to be left as it is.
Population Logic: The population logic will have to be written in the include ZXRSRZZZ.
Execution of the report:
We can find that all the plants have the text values being populated under the characteristic “Virtual Char”.
Navigating to all the exits:
In CMOD choose your project which holds the enhancement RSR00002 and select the components:
Choose any of the exits under the enhancement RSR00002 and double click.
In the exit click on the attributes tab:
Double click on the program name SAPLXRSR, this can also be accessed from transaction SE38 directly.
Hope this document is helpful if you choose to write a virtual characteristic or key figure without using BADI. Writing the individual codes inside an include function will insure your system against collapse of all the reports due to syntax errors in logic of a virtual char related to any info provider.