Routines in Bi
Routines in Bi
Start Routine
Use Preparation of data before transformation Package-based, semantic
packaging possible (see data transfer process for more details)
Example
Deletion of records that are not required for updating Performance: Buffering tables into internal tables that can be used for the Transformation rules (rather than reading the database tables one by one)
TRANSFORMATION CHANGE RULE
This is as in 3.x used for example to avoid single data reads. Although package-based, in SAP NW 2004s we have the possibility to define semantic groups, which means characteristic values belonging together and part of one package. For example, we want all records for one document to be in one package so we define a semantic group on the document level. NOTES: It triggers(Executes) before Transformations. Internal Tables : SOURCE_PACKAGE Structure(header) : <SOURCE_FEILDS> Till 3.x version START ROUTINE has Header but from BI onwards there is no header.
Note: For First loop the record from the Structure (i.e. C100) will be store in Header, similarly 3 records i.e. 3 loops will be All the records will move and store in Header from where we can access the data
My requirement is as follows:
I need to allow only the Customers having Material No. M100.
STEPS : Go to Transformation Change Mode: In the right side upwards u will find a Button START ROUTINE, click on that u will go to A new screen where u will find Start Routine written for all Transformations. Scroll down will find by default the Internal Table and Structure will be defined, Scroll Down u will see a Tag like *insert code here (Note: it will appear above Twice) here start writing the Code as follows : Loop at Source_package assigning <Source_feilds>. If <Source_feilds>-/bic/yg_mno <>m100. {here /bic/yg_mno is the Field name} Delete Source_package. ENDIF. Endloop. Save the Code.
End Routine
Use
Post-preparation of data after transformation Package-based, semantic packaging possible (see data transfer process for more details)
Example
Deletion of records after transformation that are not required for updating (e.g. after determining material category for a particular material, every material of type refund is not updated) Validation Checks of records after transformation (e.g. key figure sales value must be bigger than purchase value) It triggers (executes) after Transformation and before data load to the Data Target. i.e filtering after Transformation before loading data to Cube. Detail: Table is Result_package Header(Structure) is <Result_feilds> IT TRIGGERS AFTER TRANSFORMATION. REQUIREMENT: I LIKE TO DELETE ALL THE CUSTOMER WHO ARE NOT HYDERBAD. Code: Loop at Result_package assigning <Result_feilds>. If <Result_feilds>-/bic/yg_caddr<>hyd. Delete Result_package. Endif. Endloop.
End routine is similar to the start routine. Use it for post-preparation after the data transformation. This is package based semantic packages are possible here. It is recommended if for example you need to delete records after the transformation.
Expert Routine
Use
Transformations that cannot be expressed declaratively for functional or performance reasons
DEFNITION: FEEDING THE REQUIRED INFOOBJECTS IN THE CUBE BY ROUTINE, by deleting the TRANSFORMATION. DETAILS: SOURCE_PACKAGE all records from DATA SOURCE RESULT_PACKAGE TABLE
RESULT_FEILDS STRUCTURE
Example
Performance: reading several database tables can be implemented faster when knowing the application logic (rather than using the generic transformation framework) Pivoting: transpose a wide data record into several smaller records ,can be easily implemented using the expert routine
The expert routine is a means to define a transformation in a non-declarative way. Here you do not have the 1:1 assignments between targets and sources, you are purely coding the transformation.
Using Expert routine we can control priority, which will execute first. Expert Routine is the part of Transformation. Built a Transformation to map Data Source with Info cube using Expert Routine. SCENARIO: I had 3 fields in the Source ( i.e. Flat File) it means that the Data Source will also have 3 fields(customer number, material number, 0calday(for Transaction)) since My Data Source structure is same as my Transfer Structure.
{NOTE: same Sequence should maintain.} I had 4 new fields other than Data Source, so I need to populate the values for that 4 new records.{new fields are (customer address, customer region, material color, material price, material quantity)}
FACT TABLE
source system
STEPS : CREATE 2 MASTER DATA TABLES, 1 for CUSTOMER and 2 for MATERIAL
CREATE CUBE with Info Objects like Customer Number with attributes like Customer name Customer address(Exclusive Attribute, Characteristic in cube). Customer region (EXCLUSIVE ATTRIBUTE). Similarly material number
Material name Material Color Material price (keyfigure) Material Quantity(keyfigure) Create CUBE of type : STANDARD ( include these info objects) create Flat file. create Data Source of Type : Transaction data, and activate the Data source. Built the Transformation to map Data Source to Info cube using EXPERT ROUTINE, NOTE : U can see the EXPERT ROUTINE option in Transformation Change Screen Go to Edit menu EXPERT ROUTINE U will see a Pop up menu (u want to delete Transformation) say YES, U will go to the new SCREEN where u can find all the routines written in Transformations, U will find a comment like : insert code here
NOTE: Here u will find 2 internal tables 1. SOURCE_PACKAGE : it holds data from the source system. Structure is source. 2.RESULT_PACKAGE : it holds the data which we have to send to the CUBE and its STRUCTURE is similar to CUBE. CONCEPT: If I need the value for CUSTOMER REGION which I dont have this field in the source, but the field is available in my Master data, I will write a code which will look up at my source CNO from there It fetch the data to cube.
IN BI we dont have HEADERS to TABLES, so internally we have STRUCTURES like for SOURCE_PACKAGE structure is <SOURCE_FEILDS>, And for RESULT_PACKAGE structure is RESULT_FEILDS. SAY I had 3 records in my SOURCE, that means 3 loops will take place, for every single loop 1 record is placed in Structure<SOURCE_FEILDS>, from there these are assigned to RESULT_FEILDS. Similarly for the case, CUSTOMER REGION, it will go to CNO In the Source _Package Table it will look up the Master data and transfer the value for that info object to STRUCTURE(<SOURCE_FEILDS<) from there to RESULT_FEILDS. CODE : Loop at SOURCE_PACKAGE assigning <source_feilds>. Result_feilds-/bic/cno = <source_feilds>-/bic/cno. Result_feilds-/bic/mno = <source_feilds>-/bic/mno. Result_feilds-calday = <source_feilds>-calday. Select single /bic/caddr from /bic/pcno into result_feilds-/bic/caddr where /bic/pcno = <source_feilds>-/bic/pcno and objvers = A.
//NOTE : similarly write code for all other info objects & to append the structure to table Append result_feilds to result_package. Endloop. Save Activate create infopackage to load data from SOURCE to DATA SOURCE. create DTP ACTIVATE EXECUTE.