Beruflich Dokumente
Kultur Dokumente
Applies to:
This article applies to SAP BI 7.0. For more information, visit the Business Intelligence homepage.
Summary
This document provides the overview of all the routines available in transformation in BI 7.0 with
special focus on the possible scenarios for usage of end routine and how to implement the same.
Author: Anurag krishna dev
Company: Infosys technologies limited
Created on: 15 April 2009
Author Bio
Anurag krishna dev is an SAP certified solution consultant and working at Infosys Technologies. He
has been involved in SAP BI consulting practice for 3 years now. He has expertise in executing
implementation and support projects for multiple clients.
Table of Contents
Routines in transformation..................................................................................................................................3
Start routine.....................................................................................................................................................4
Routine for key figures or characteristics........................................................................................................4
Expert Routine ................................................................................................................................................5
End routine......................................................................................................................................................5
End routine parameters...................................................................................................................................6
Import Parameters .......................................................................................................................................................6
Export Parameters .......................................................................................................................................................6
Change Parameters.....................................................................................................................................................6
Exception Raising Parameters.....................................................................................................................................6
Business Scenario ..............................................................................................................................................6
Technical solution ...............................................................................................................................................8
Step 1 - Create the target info cube .............................................................................................................................8
Step 2 – Create transformation ....................................................................................................................................8
Step 3 – Maintain end routine ......................................................................................................................................9
Step 4 – Create and execute the Data transfer process ............................................................................................13
Related contents...............................................................................................................................................15
Disclaimer and Liability Notice..........................................................................................................................16
Introduction
This article explains about the different routines available in transformation in BI 7.0 and how they are
structured in main transformation program. The document also elaborates the business scenarios
where these routines can be leveraged to implement complex transformation rules. Special focus is
given on end routine with an example business scenario.
Routines in transformation
Routines are local ABAP classes that consist of a predefined definition area and an implementation
area. The TYPES for the inbound and outbound parameters and the signature of the routine (ABAP
method) are stored in the definition area. The actual routine is created in the implementation area.
ABAP object statements are available in the coding of the routine. Upon generation, the coding is
embedded in the local class of the transformation program as the method.
As of Net weaver release 2004s following four types of routines are available in transformation
1. Start routine
2. Routine for key figures and characteristics (Transfer rule – routine)
3. End routine
4. Expert routine
Figure- 1
These routines are the components of main transformation program; following figure shows the
structure of main transformation program with different components
Figure- 2
Start routine
The start routine is run for each data package at the start of the transformation. The start routine has a
table in the format of the source structure as input and output parameters. It is used to perform
preliminary calculations and store these in a global data structure or in a table. This structure or table
can be accessed from other routines. You can modify or delete data in the data package.
Figure- 3
Figure- 4
Expert Routine
This type of routine is only intended for use in special cases. You can use the expert routine if there are
not sufficient functions to perform a transformation. The expert routine should be used as an interim
solution until the necessary functions are available in the standard routine.
You can use this to program the transformation yourself without using the available rule types. You
must implement the message transfer to the monitor yourself.
Figure- 5
Figure- 6
End routine
An end routine is a routine with a table in the target structure format as input and output parameters.
You can use an end routine to post process data after transformation on a package-by-package basis.
For example, you can delete records that are not to be updated, or perform data checks. As described
in the Figure- 1, The End Routine is executed at End of the main transformation Program.
Import Parameters
● REQUEST: Request ID
● DATAPAKID: Number of current data package
Export Parameters
● MONITOR: Table for user-defined monitoring. This table is filled using row structure
MONITOR_REC (the record number of the processed record is inserted automatically from the
framework).
Change Parameters
● RESULT_PACKAGE: Contains all data that has been processed by the transformation.
Business Scenario
To elaborate the usage of transformation end routine we will take the example of ABC Company which
is having different vendors in different sales region (East West North and South).For new production
the ABC Company needs to procure the raw material from different region. The management has
decided how much material will be procured form different regions over next quarter (Table 1.1). The
company has selected some of the vendors to whom the purchase orders will be raised from different
region; however the total PO amount and quantity will be distributed to different vendors based on
their “Preference Factor”.
The ABC Company maintains this “Preference factor” for vendors based on its business relationship and
it has been maintained in the Master data of vendors (Table 1.2). The same is exemplified below.
Table 1.1
Vendor Master Data:-
Vendor Region Preference factor
8000 EAST 0.4
8001 EAST 0.3
8002 EAST 0.3
8003 WEST 0.3
8004 WEST 0.3
8005 WEST 0.4
8006 NORTH 0.4
8007 NORTH 0.3
8008 NORTH 0.3
Table 1.2
As we can see in the source we have the procurement information aggregated at the region level. For
reporting purpose we need more granular information at the vendor level so our task is to distribute
this aggregated information to different vendors based on their “Preference factor” and load it in the
target (Table 1.3). This is depicted below:-
Fiscal Period Material Region Vendor Amount Currency Quantity Unit
12008 401 EAST 8000 1000 * 0.4 = 400 INR 10 * 0.4 = 4 ST
12008 401 EAST 8001 1000 * 0.3 = 300 INR 10 * 0.3 = 3 ST
12008 401 EAST 8002 1000 * 0.3 = 300 INR 10 * 0.3 = 3 ST
22008 601 WEST 8003 10000 * 0.3 = 3000 INR 100 * 0.3 = 30 ST
22008 601 WEST 8004 10000 * 0.3 = 3000 INR 100 * 0.3 = 30 ST
22008 601 WEST 8005 10000 * 0.4 = 4000 INR 100 * 0.4 = 40 ST
32008 801 NORTH 8006 40000 * 0.4 = 16000 INR 400 * 0.4 = 160 ST
32008 801 NORTH 8007 40000 * 0.3 = 12000 INR 400 * 0.3 = 120 ST
32008 801 NORTH 8008 40000 * 0.3 = 12000 INR 400 * 0.3 = 120 ST
Table 1.3
Technical solution
We will see how to leverage the transformation end routine to implement the above mentioned
Business scenario. This process is elaborated step by step:-
Figure– 8
Figure- 9
Figure- 10
In the subsequent window we need to write the end routine, the same is explained below
PROGRAM trans_routine.
*---------------------------------------------------------------------*
* CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
PUBLIC SECTION.
* Attributs
DATA:
p_check_master_data_exist
TYPE RSODSOCHECKONLY READ-ONLY,
*- Instance for getting request runtime attributs;
* Available information: Refer to methods of
* interface 'if_rsbk_request_admintab_view'
p_r_request
TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.
PRIVATE SECTION.
TYPE-POOLS: rsd, rstr.
* Rule specific types
TYPES:
BEGIN OF _ty_s_TG_1,
* InfoObject: 0FISCPER Fiscal year / period.
FISCPER TYPE /BI0/OIFISCPER,
* InfoObject: 0FISCVARNT Fiscal year variant.
FISCVARNT TYPE /BI0/OIFISCVARNT,
* InfoObject: ZZVENDOR Vendor.
/BIC/ZZVENDOR TYPE /BIC/OIZZVENDOR,
* InfoObject: 0MATERIAL Material.
MATERIAL TYPE /BI0/OIMATERIAL,
* InfoObject: REGION06 Region.
/BIC/REGION06 TYPE /BIC/OIREGION06,
* InfoObject: 0AMOUNT Amount.
***********************************************************************
Data and TYPE
* Global data declaration
declaration of internal
*********************************************************************** table similar to vendor
master data table to load
*
the vendor master data
intermittently.
DATA: BEGIN OF INT_TAB_VENDOR,
VENDOR TYPE /BIC/OIZZVENDOR,
PREFERENCEFACTOR TYPE /BIC/OIZPREFFCT,
REGION TYPE /BIC/OIREGION06,
END OF INT_TAB_VENDOR.
DATA: I_T_VENDOR LIKE TABLE OF INT_TAB_VENDOR.
*$*$ end of global - insert your declaration only before this line *-*
METHODS
end_routine
IMPORTING
request type rsrequest
datapackid type rsdatapid
EXPORTING
monitor type rstr_ty_t_monitors
CHANGING
RESULT_PACKAGE type _ty_t_TG_1
RAISING
cx_rsrout_abort.
METHODS
inverse_end_routine
IMPORTING
i_th_fields_outbound TYPE rstran_t_field_inv
i_r_selset_outbound TYPE REF TO cl_rsmds_set
i_is_main_selection TYPE rs_bool
i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
i_r_universe_inbound TYPE REF TO cl_rsmds_universe
CHANGING
c_th_fields_inbound TYPE rstran_t_field_inv
c_r_selset_inbound TYPE REF TO cl_rsmds_set
c_exact TYPE rs_bool.
ENDCLASS. "routine DEFINITION
*$*$ begin of 2nd part global - insert your code only below this line *
*---------------------------------------------------------------------*
* CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.
*----------------------------------------------------------------------*
* Method end_routine
*----------------------------------------------------------------------*
* Calculation of result package via end routine
* Note: All not overwritten field values within the routine
* are transferred from the corresponding source fields. This
* means, all fields not supplied by the transformation source
* are send with initial values to the transformation target.
*----------------------------------------------------------------------*
* <-> result package
*----------------------------------------------------------------------*
METHOD end_routine.
*=== Segments ===
FIELD-SYMBOLS:
<RESULT_FIELDS> TYPE _ty_s_TG_1.
DATA:
MONITOR_REC TYPE rstmonitor.
*$*$ begin of routine - insert your code only below this line *-*
**
**********************************************************************
* Read master data of vendor
*************************************************************************
SELECT /BIC/ZZVENDOR /BIC/ZPREFFCT /BIC/REGION06 FROM
/BIC/PZZVENDOR INTO TABLE I_T_VENDOR
Transfer of vendor master data to
WHERE OBJVERS = 'A' internal table.
AND /BIC/REGION06 <> ''.
IF SY-SUBRC = 4.
RAISE EXCEPTION TYPE CX_RSROUT_ABORT.
ENDIF.
ENDLOOP.
ENDLOOP.
REFRESH RESULT_PACKAGE.
*$*$ end of routine - insert your code only before this line *-*
ENDMETHOD. "end_routine
*----------------------------------------------------------------------*
* Method inverse_end_routine
*----------------------------------------------------------------------*
*
* This subroutine needs to be implemented only for direct access
* (for better performance) and for the Report/Report Interface
* (drill through).
* The inverse routine should transform a projection and
* a selection for the target to a projection and a selection
* for the source, respectively.
* If the implementation remains empty all fields are filled and
* all values are selected.
*
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
METHOD inverse_end_routine.
*$*$ begin of inverse routine - insert your code only below this line*-*
... "insert your code here
*$*$ end of inverse routine - insert your code only before this line *-*
ENDMETHOD. "inverse_end_routine
ENDCLASS. "routine IMPLEMENTATION
Figure– 11
After executing the DTP we will check the data loaded into target cube whether its up to expectation
or not.
Figure- 12
As shown in the Figure12 the data loaded in the target cube is as per expectation.
Related contents
Routines in Transformation
End Routine
Writing Routines in Transformation
http://www.help.sap.com