Reading Time Dependent Master Data using ‘Read Master Data’
Many a times we use the Rule Type ‘Read Master Data’ to perform a lookup on the master data infoobject to derive the value of one of its attribute.
However what if the attribute that we want to read from the Master data infoobject is time dependent? In such cases we can use the Time Dependent feature of Read master data.
So this is how it goes:
Suppose we have a scenario in which we want to read the Profit Center of a COPA document based on its posting date.The target does not contain the posting date field.
Now profit center (0PROFIT_CTR) is an attribute of 0COSTCENTER and it is time dependent.
What then can be done in this case? We can obviously write a start routine and store the values of the source table in an internal table declared globally and then read these values of posting date in the end routine from the internal table and compare them with the Valid To and Valid From fields from the Q table of the master data infoobject and get the corresponding profit center..
Field routines should not be preferred in such cases because they hit the database for every data record and that affects performance.
Now coming back to our read master data:
First we will map cost center to profit center .
Then under ‘Rule Type’ we will select Read Master data:
In From Attr.of we will insert 0COSTCENTER
Then we will click on the clock next to it which is Key date Determination.
And under Time Dependency Reading Master Data we will select Start
We will select Start and over there under from we will select the Time characteristic which in our case is Posting date.
Once this is done we will do the following changes in IO Assignment:
Once this is done we will check whether our ‘Read master data’ is really working.
Below is our Cost Center master data:
For Cost Center 99991234 the Profit Center is D7209 from 01.01.2007-30.06.2013
and it is E7209 from 01.07.2013-31.12.9999
Now we will test whether our rule is working.For that we will click on Test Rule and enter the following values:
And Voila! this works.As you can see above I added Posting date as 01.07.2007 which falls in the range 01.01.2007-30.06.2013 and its corresponding profit center is D7209.
So go ahead and give this a try.