Sie sind auf Seite 1von 16

Implementation and Usage of Transformation End Routine in SAP BI 7.0

and Usage of Transformation End Routine in SAP BI 7.0 Applies to: This article applies to

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

limited Created on: 15 April 2009 Author Bio Anurag krishna dev is an SAP certified solution

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.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

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

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

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

Following figure depicts the position of these routine in dataflow

figure depicts the position of these routine in dataflow Figure- 1 These routines are the components

Figure- 1

These routines are the components of main transformation program; following figure shows the structure of main transformation program with different components

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

and Usage of Transformation End Routine in SAP BI 7.0 Figure- 2 Start routine The start

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.

new symbol
new symbol

Click here to maintain the Start Routine. After maintaining it, the

will change to

pencil symbol which signifies that Start routine is maintained

Figure- 3

Routine for key figures or characteristics

This routine is available as a rule type; you can define the routine as a transformation rule for a key figure or a characteristic. The input and output values depend on the selected field in the transformation rule.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

and Usage of Transformation End Routine in SAP BI 7.0 Figure- 4 Expert Routine This type

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.

must implement the message transfer to the monitor yourself. Figure- 5 Figure- 6 End routine An

Figure- 5

the message transfer to the monitor yourself. Figure- 5 Figure- 6 End routine An end routine

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.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

and Usage of Transformation End Routine in SAP BI 7.0 Figure- 7 Go here to maintain

Figure- 7

Go here to maintain the End routine. After

maintaining it, the new symbol

change to

signifies that start routine is maintained.While in display mode the existence of the end routine will be signified

in display mode the existence of the end routine will be signified will pencil symbol which

will

pencil symbol which

by the specs symbol

.

End routine parameters

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.

Exception Raising Parameters

CX_RSROUT_ABORT: If a raise exception type cx rsrout_abort is triggered in the routine, the system terminates the entire loading process. The request is highlighted in the extraction monitor as Terminated. The system stops processing the current data package. This can be useful with serious errors.

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.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

The consolidated list of material to be procured from different regions:-

Fiscal Period

Material

Region

Amount

Currency

Quantity

Unit

12008

401

EAST

1000

INR

10

ST

22008

601

WEST

10000

INR

100

ST

32008

801

NORTH

40000

INR

400

ST

Vendor Master Data:-

Table 1.1

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

SAP COMMUNITY NETWORK

Table 1.3

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

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:-

Step 1 - Create the target info cube

In the first step we will create the target info cube to load the detailed information at the vendor level (Figure– 8). Following should be the structure of the Cube:-

8). Following should be the structure of the Cube:- Figure– 8 Step 2 – Create transformation

Figure– 8

Step 2 – Create transformation

In second step we will create the transformation between the data source and our target info cube. We will select the transfer rule ‘Direct assignment’ for the entire field except the vendor which will be left unassigned. As shown in the Figure– 9

which will be left unassigned. As shown in the Figure– 9 SAP COMMUNITY NETWORK Figure- 9

SAP COMMUNITY NETWORK

Figure- 9

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

Step 3 – Maintain end routine

In the step 3 we will implement the end routine in this transformation, in the earlier portion of this document it has been elaborated how to maintain the end routine however it is depicted again in Figure– 10.

maintaining it, the new symbol change to by the specs symbol .
maintaining it, the new symbol
change to
by the specs symbol
.

Go here to maintain the End routine. After

Go here to maintain the End routine. After will pencil symbol which signifies that start routine

will

pencil symbol which

signifies that start routine is Maintained.While in display mode the existence of the end routine will be signified

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.

TYPE /BI0/OIFISCVARNT,

* InfoObject: ZZVENDOR Vendor.

FISCVARNT

/BIC/ZZVENDOR

TYPE /BIC/OIZZVENDOR,

* InfoObject: 0MATERIAL Material.

MATERIAL

TYPE /BI0/OIMATERIAL,

* InfoObject: REGION06 Region.

/BIC/REGION06

TYPE /BIC/OIREGION06,

* InfoObject: 0AMOUNT Amount.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

AMOUNT

TYPE /BI0/OIAMOUNT,

* InfoObject: 0QUANTITY Quantity.

QUANTITY

TYPE /BI0/OIQUANTITY,

* InfoObject: 0CURRENCY Currency Key.

CURRENCY

TYPE /BI0/OICURRENCY,

* InfoObject: 0UNIT Unit of Measure.

UNIT

* Field: RECORD.

TYPE /BI0/OIUNIT,

RECORD OF _ty_s_TG_1.

TYPE RSARECORD,

END

TYPES:

_ty_t_TG_1

TYPE STANDARD TABLE OF _ty_s_TG_1

WITH NON-UNIQUE DEFAULT KEY. *$*$ begin of global - insert your declaration only below this line *-*

***********************************************************************

*

***********************************************************************

*

Global data declaration

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.

Data and TYPE declaration of internal table similar to vendor master data table to load

the vendor master intermittently.

data

data table to load the vendor master intermittently. data *$*$ end of global - insert your

*$*$ 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

*

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

"insert your code here *$*$ end of 2nd part global - insert your code only before 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>

DATA:

MONITOR_REC

TYPE _ty_s_TG_1.

TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line

*-*

 

"insert your code here

 

*--

fill table "MONITOR" with values of structure "MONITOR_REC"

 

*-

to make monitor entries

 

"to cancel the update process

*

raise exception type CX_RSROUT_ABORT.

************************************************************************

********************

 

*

Local data declarartion

 

************************************************************************

********************

 
 

DATA: E_S_RESULT

TYPE _ty_s_TG_1 .

 

DATA: E_T_RESULT

TYPE _ty_t_TG_1 .

DATA: E_T_RESULT TYPE _ty_t_TG_1 . Declaration of Intermediate Variables

Declaration of Intermediate Variables

DATA: AMOUNT

LIKE E_S_RESULT-AMOUNT.

 

DATA: QUANTITY LIKE E_S_RESULT-QUANTITY.

DATA: VAR_AMOUNT

LIKE E_S_RESULT-AMOUNT.

DATA: VAR_QUANTITY LIKE E_S_RESULT-QUANTITY.

 

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

** ********************************************************************** * Read master data of vendor
**
**********************************************************************
*
Read master data of vendor
*************************************************************************
SELECT /BIC/ZZVENDOR /BIC/ZPREFFCT /BIC/REGION06 FROM
/BIC/PZZVENDOR INTO TABLE I_T_VENDOR
WHERE OBJVERS = 'A'
Transfer of vendor master data to
internal table.
AND /BIC/REGION06 <> ''.
IF SY-SUBRC = 4.
RAISE EXCEPTION TYPE CX_RSROUT_ABORT.
ENDIF.
SORT I_T_VENDOR BY REGION.
LOOP AT RESULT_PACKAGE INTO E_S_RESULT.
READ TABLE I_T_VENDOR INTO INT_TAB_VENDOR WITH KEY REGION =
E_S_RESULT-/BIC/REGION06.
VAR_AMOUNT = E_S_RESULT-AMOUNT.
VAR_QUANTITY = E_S_RESULT-QUANTITY.
Loop to fill the result package
calculating the amount and
quantity for vendors based on the
logic described above.
LOOP AT I_T_VENDOR INTO INT_TAB_VENDOR WHERE REGION =
E_S_RESULT-/BIC/REGION06.
AMOUNT =
VAR_AMOUNT * INT_TAB_VENDOR-PREFERENCEFACTOR.
QUANTITY = VAR_QUANTITY * INT_TAB_VENDOR-PREFERENCEFACTOR.
MOVE INT_TAB_VENDOR-VENDOR TO E_S_RESULT-/BIC/ZZVENDOR.
MOVE AMOUNT TO E_S_RESULT-AMOUNT.
MOVE QUANTITY TO E_S_RESULT-QUANTITY.
APPEND E_S_RESULT TO E_T_RESULT.
ENDLOOP.
ENDLOOP.
REFRESH RESULT_PACKAGE.
MOVE E_T_RESULT[] TO RESULT_PACKAGE[].

*$*$ end of routine - insert your code only before this line

ENDMETHOD.

"end_routine

*-*

*----------------------------------------------------------------------*

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

* 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.

ENDCLASS.

"inverse_end_routine "routine IMPLEMENTATION

Step 4 – Create and execute the Data transfer process

In the last step we need to create the DTP to execute the transformation and load data into Data target.

execute the transformation and load data into Data target. Figure– 11 After executing the DTP we

Figure– 11

After executing the DTP we will check the data loaded into target cube whether its up to expectation or not.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com

| BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

List Cube Output for Target Cube ZPROCURE

in SAP BI 7.0 List Cube Output for Target Cube ZPROCURE Figure- 12 As shown in

Figure- 12 As shown in the Figure12 the data loaded in the target cube is as per expectation.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com

| BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

Related contents

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

Implementation and Usage of Transformation End Routine in SAP BI 7.0

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

SAP COMMUNITY NETWORK

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com