Monday, November 5, 2007

How To get the Master Data Attribute Value in UR's

Very often you need to read the characterstic attribute value during data transformation process. Most of the times you simply select "Master Data Attribute Value of" option and select your Characterstic IO.

Some times it is not possible to select Master Data attributes directly using the "Master Data Attribute Value of" option. If this is your requirement, you can get the master data attribute values by writing a simple ABAP Routine in your UR's.

There is a standard Function Module(FM) :RSAU_READ_MASTER_DATA to read master data attributes directly.

Click here to see the example code.

Apart from using the above FM you can directly read master data table using SELECT statement. See the below example.

Example: I am trying to load data from an ODS to Cube & I have 0COSTCENTER as an attribute of ZCUSTOMER. In my ODS I have only ZCUSTOMER Number, But in cube I have ZCUSTOMER as well as 0COSTCENTER. To update 0COSTCENTER in Cube, I have to write a ABAP Routine in UR's for ZCUSTOMER lookup.


*---------- Code to be written in Start Routine of UR's--------
DATA: t_/bic/pzcustomer TYPE STANDARD TABLE OF /bic/pzcustomer WITH HEADER LINE.

DATA: v_cost_center LIKE /bic/pzcustomer-costcenter.

*$*$ begin of routine - insert your code only below this line *-*
* fill the internal tables "MONITOR" and/or "MONITOR_RECNO",
* to make monitor entries

CLEAR: t_/bic/pzcustomer.
REFRESH: t_/bic/pzcustomer.

SELECT * FROM /bic/pzcustomer APPENDING TABLE t_/bic/pzcustomer
WHERE objvers = 'A'.

SORT t_/bic/pzcustomer BY /bic/zcustomer.

* if abort is not equal zero, the update process will be canceled
ABORT = 0.
*--- End of Start Routine in UR's-----------------------------

Now write below in your Update Routine

READ TABLE t_/BIC/PZCUSTOMER WITH KEY /BIC/ZCUSTOMER =
COMM_STRUCTURE-/BIC/ZCUSTOMER BINARY SEARCH.

V_COST_CENTER = t_/BIC/PZCUSTOMER-COSTCENTER.

* result value of the routine
RESULT = V_COST_CENTER.

No comments: