Unit Conversion in SAP BW 3.x at Report Level:

Unit Conversion in SAP BW 3.x at Report Level:

Today i am going to explain about the unit conversion at BW 3.x @ Report Level.

Scenario:

Many times in our support Project we might have seen reports where the user needs to enter the Alt Unit of Measure during the query input selection. Based on the Alt Unit of Measure the output will be populated accordingly. The main benefits of this are

1) Giving Flexibility to the User during the query Run Time.
2) No Need to maintain the quantities in different units at data model end.
3) This is one time implementation for given interface (SAP BW system )
4) Low maintenance

I will explain in detail why and what to be done.

So lets start.....

What do we require to implement unit conversion in Reporting END.

1. You should have 0material or any other custom material.
2. You should have a quantity type key figure. This should be the attribute of the material.
3. 0mat_unit ( i assume that its running prod system and this infoobject is already loaded )
4. Then Variable for Unit entry and Variable to calculate the Conversion Factor.

I have followed the Document ' How to ...Report Data in Alternate Unit of Measure ' Nov 2005 version.

Please check out this section as i will update the details with screen shot. There has been delay due to project constraints....

1) In my case i have created a new material and i have added a new key figure of type quantity in this mateiral as attribute.

YG0AD0516 is the new key figure in this case.
2) 0mat_unit there is already a data load running. 0mat_unit is required because it stores denominator and numerator ( num/den is the conv factor ) different mateirals against different units . if there is no data load scheduled please run the dta load.

3) Now important aspect is the coding. The coding involves in different includes and points. These has to be exactly placed else the logic wont work.

(a)Firstly in Include ZXRSRTOP.

This will act as a global declaration:

Code:

*** Enhancement: Alternate U.o.M.
DATA: g_aunit TYPE /bi0/oimat_unit


(b)Secondly in Include LRRSVF20

( please go through the link http://tleterme.developpez.com/bw/how/Howto_alternate_uom5.pdf and copy paste the code here for include specified above ).

(c)Third in Include ZXRSRU01.

We have included the FM to invoke the coding here.
The coding details of FM are same as given in the above document.

(d)Fourth in Include ZXRSRF01.

The coding details of FM are same as given in the above document.

In Over al the significance of coding is as follows:

(a) we declare the global variable for unit.
(b) Check all the variables in which the variables need to be replaced by attribute value. Formula variable of type replacement path.
      In this section the attribute name will be converted to the variable.
(d) In this section the conversion factors will be calculated using the 0mat_unit.
(c) In this section the factors calculated in section (d) will be used to calculate the variable created in section (b).

Once this coding section is done. Do the following carefully.

1. Create a varaible on 0base_uom . Type of user entry, single value and optional. Maintain default unit as well.

And now i assume we everyone know how to invoke this variable by creating dummy RKF and keeping in it columns and hiding it.

2. Create Calculated key figure :

No dim of the Key figure we want the Unit conversion to apply * formula variable.

Formula variable should be on material with replacement path processing and replaced with quantity key figure.


NOTE: this logic of unit conversion works only with calculated key figure. So creating calculated key figure is mandatory.

Now with this its pretty clear that

when we run the report

The variable for alt unit of measure will be invoked ( provided we invoke it via RKF in column and hide it )
Nex the following coding sequence will occur as explained above and calculates the factor of conversion from 0mat_unit and passed to formula variable.
CKF will give the converted value.

Please check this space for report output.....

Also check the appendix section in the reference doc and it explains the debug techniques.....




2 comments:

  1. Hi

    Great blog,
    Can you explain how you create the include
    ZXRSRTOP in cmod?
    Do I need access_key for that?
    I see the include but it says
    "Changes to LXRSRTOP are forbidden by SAP"

    Regards

    Shlomi Weiss

    ReplyDelete
  2. We have included ZXRSRTOP in the same place and did changes. Did you checked for any access required.

    ReplyDelete