Adding Records In The User Exit
I have a requirement to modify the transactional data user exit 0CO_PC_PCP_01. Currently this datasource extracts cost estimate data and using some complex rules I need to determine the active cost estimate for each month and duplicate the records according.
ie if a cost estimate dated 01.01.2005 is valid for all of 2005 then I need to duplicate all corrsponding records 11 times ie one set of additional records per month.
I have created the ABAP code to do this and for small volumes of data it works perfectly. However if I increase the data volume the exit seems to run and run.
The code is as efficient as it can be and there are no database selects within it.
My questions are:
1)is it acceptable to add a high volume of new data in the user exit or should I be looking at an alternative.
2) Does the user exit get called multiple times during a dataload. ie once per datapackage. If so then am I correct in saying it is dangerous to add records this way because some of the records added could already exist and be processed within another datapackage and therefore records would then be duplicated.
3) One approach I have thought of but not yet tested is to use the function module(s) used by the SAP standard extractor to populate a table on R3 and then use a custome datasource to retrieve the data from this table.
Any thoughts/views/answers on the above would be appreciated.
Gova Mabbu replied
1. Lets say that the datapacket size is 20000 and all of your records are active. Then when it exits the user exit, the size of the datapacket would be 20000 X 12. that is a very large packet. Probably not a good idea to do this.
2. The user exit will be called for each datapacket. That is correct and yes, it would be wrong to do this in a datapaket. If a record exists in two datapackets, then records are generated for this multiple times.
3. Why are you not considering applying the logic in BW rather than doing it in R/3. That should be relatively easy.
This is how you can do it. When loading the data into BW, load it into an ODS object. Add a new Infoobject to the ODS object (ZACTIVE) for example. In the update rules between infosource and ODS, apply the logic that you are using to determine if each record is active or not. Now from this ODS, load it to either INfoCube or ODS, wherver you want to. In the update rules between the two, you can use the "return table" to generate multiple records where ZACTIVE = true, or you can generate in the start routine instead.
By doing this you emilinate the case of generating duplicate records.
Hope that helps.