Routines in SAP BW 7.x
There are different types of Routines available to write (ABAP) in SAP BW for data modification/population at different levels. Routines helps us to implement Business Rules or setup better Data Model which is not available in standard way.
This document will cover below routines in SAP BW (7.x).
(Covering “when to write” examples however “how to write” is kept on exploring mode)
- Transfer Routine
- Start Routine
- End Routine
- Expert Routine
- Field Routine
Transfer Routine will be available at Infoobject level whereas Start, End, Field & Expert Routine will be available at Transformation level.
In Transformation, the execution sequence either will be Start Routine -> Field Routine -> End Routine or only Expert Routine. Options for Start, End & Field Routine will be disabled once Transformation with Expert Routine is created.
- Transfer Routine : Available for Char/Currency/Unit infoobjects.
This routine is available at Infoobject level and executes only when data from DataSource is transferred to immediate infoprovider.
Purpose : Data transformation at Infoobject level. Data will be Refined as soon as it enters BW Infoprovider (data model).
Example : Suppose a BW is connected to 2 different ECC. One of the ECC stores unit for Litre as “L” and other as “LT”. In this case BW wants to maintain a single unit for Litre as “L” then Transfer Routine will ensure this process is followed and “LT” is converted to “L” using ABAP.
- Start Routine : Can be written in Transformation.
Start Routine executes first when a DTP is executed and can be created in a transformation as shown in the below screenshot. Start Routine processes whole bunch of data at a time (DTP Package size).
Purpose : Modify the source data (SOURCE_PACKAGE) i.e source DS, DSO or Cube etc. Before the data is reached to target.
- Deletion of record during data loads (Similar to DTP filter but Hard-Coded).
- Populating Internal Table (Global) which can be used further.
- Sorting of source data before sending to target.
- End Routine : Can be written in Transformation.
End Routine executes last when a DTP is executed and can be created in a transformation as shown in the below screenshot. End Routine processes whole bunch of data at a time (DTP Package size).
Purpose : Modify the target data (RESULT_PACKAGE) i.e. target DSO or Cube etc i.e. once data is processed in transformation and ready to store in infoprovider at that time modification can be done.
- Population/Modification of target fields.
- Populating Internal Table which can be used again in End Routine.
If multiple fields (Target) need to be populated/modified then End Routine should be used as all the fields can be populated/modified at one go in that data package instead of Field Routine which will work on individual field at a time.
- Expert Routine : Can be written in Transformation.
Expert Routine is alternate approach to Start, Field & End Routine and can be created using below screenshot.
After above screenshot, confirm the change. Once confirmed, below are the options.
Purpose : To handle complex requirement when standard approach for Start Routine & End Routine does not satisfy. In this routine SOURCE_PACKAGE and RESULT_PACKAGE both can be used at the same time for data modification.
- Transpose of data i.e. source has 12 records (Monthly) for a year and in target only single record is required with all the months as columns for that year.
- Field Routine : Can be written in Transformation.
Field Routine is written for single field in the transformation where complex modification/derivation is required. Can be created as shown in the below screen shot.
Purpose : To modify/derive a individual field value.
- Modification/Population of single field where the internal table is populated in Start Routine and read in Field Routine.
Note : If all the source fields are not mapped 1:1 in target then only Field Routine should be used else End Routine would be best option, as all the required fields are mapped and available in target for bulk processing.
- Concatenate of 2 or more fields in to the single target field.
- String modifications on the source fields and storing that in to target field.
Point (a) from example is explained :
Consider an example where Future Joiner’s Period, Quarter & Year needs to be calculated using Future Joiner field value as TRUE or FALSE. Below is the screenshot for the same.
As mentioned, if the fields used in the logic/calculation are available in the target and then End Routine will be best option as only single if will suffice to calculate all the fields falling under same condition. In this scenario, End Routine will improve the performance of the transformation.
If Future Joiner and Start Date are not available in Target then Field Routine should be used.