You are on page 1of 49

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Applies to:
SAP NetWeaver Business Warehouse (Formerly BI), Will also work on SAP BW 3.5/SAP BI 7.X. For more information, visit the EDW homepage

Summary
This Article tells about, How to write a Start Routine in Update Rules, Transformations and How to Debug the Routines. Here I taken one example i.e., needs to delete the unwanted data in Start Routine of Update Rules/Transformations based on Customer number.

Author:

Surendra Kumar Reddy Koduru

Company: ITC Infotech India Ltd. (Bangalore/INDIA) Created on: 20 June 2011

Author Bio
Surendra Kumar Reddy Koduru is a SAP BI Lead Consultant currently working with ITC Infotech India Ltd (Bangalore/INDIA). He has got rich experience and worked on various BW/BI Implementation/Support Projects and he is the author for various Articles and Blogs (SAP-BW/BI) in SAP Community Network.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Table of Contents
How to Write a Start Routine in Update Rules: .................................................................................................. 3 Introduction: ........................................................................................................................................................ 3 Live Scenario: ..................................................................................................................................................... 3 InfoCube Details: ............................................................................................................................................. 3 Create Start Routine: ...................................................................................................................................... 4 Code before Start Routine: ............................................................................................................................. 5 Code After Start Routine: ................................................................................................................................ 6 Data Loading: .................................................................................................................................................. 9 Monitor the Data Load:.................................................................................................................................. 10 Request Details: ............................................................................................................................................ 12 Display Data in InfoCube: ............................................................................................................................. 13
Data in PSA : ............................................................................................................................................................. 13 Data in Source Flat File: ............................................................................................................................................ 14

How to Debug the Start Routine in Update Rules: ........................................................................................... 14 Change Start Routine:................................................................................................................................... 14 Data Loading: ................................................................................................................................................ 16
InfoPackage Settings: ................................................................................................................................................ 16

Monitor the Data Load:.................................................................................................................................. 17 Manual Update/Simulation: ........................................................................................................................... 18 Debugger Window:........................................................................................................................................ 19 Our Code: ...................................................................................................................................................... 19 Data Package: ............................................................................................................................................... 20 How to Write Start Routine in Transformations: ............................................................................................... 22 Introduction: ...................................................................................................................................................... 22 Live Scenario: ............................................................................................................................................... 22 InfoCube Details: ........................................................................................................................................... 22 Create Start Routine: .................................................................................................................................... 23 Code Before Start Routine: ........................................................................................................................... 24 Code After Start Routine: .............................................................................................................................. 27 Data Loading: ................................................................................................................................................ 31 Monitor the Data Load:.................................................................................................................................. 33 Request Details: ............................................................................................................................................ 36 Display Data in InfoCube: ............................................................................................................................. 37
Data in PSA: .............................................................................................................................................................. 37 Data in Source Flat File: ............................................................................................................................................ 38

How to Debug Start Routine in Transformations: ............................................................................................. 38 Introduction: ...................................................................................................................................................... 38 Live Scenario: ............................................................................................................................................... 38 Change Start Routine:................................................................................................................................... 38 Data Loading: ................................................................................................................................................ 40
InfoPackage Settings: ................................................................................................................................................ 40

Monitor the Data Load:.................................................................................................................................. 41 DTP and Settings for Debug: ........................................................................................................................ 42 Debugger Window:........................................................................................................................................ 45 Related Content ................................................................................................................................................ 48 Disclaimer and Liability Notice .......................................................................................................................... 49

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 2

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

How to Write a Start Routine in Update Rules: Introduction:


How to write a Start Routine in Update Rules. Here I taken one example i.e., needs to delete the unwanted data in Start Routine of Update Rules based on Customer number. Live Scenario: We are loading the data to InfoCube, the Source system is Flat File (the logic, code and execution is same for even any SAP Source systems also) and we need to delete the unwanted records/data in Update rules at the time of data loads based on some Customer numbers. InfoCube Details: See the below screens, which will give the details of the InfoCube ZIC_DEMO2.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 3

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Note: I taken ZIC_DEMO2 InfoCube, which is having just simple Transfer rules and Update Rules (in BW 3.5)

Create Start Routine: Click on Create Start Routine like below.

It opens the below code window.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 4

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Code before Start Routine:

PROGRAM UPDATE_ROUTINE. *$*$ begin of global - insert your declaration only below this line * TABLES: ... * DATA: ... *$*$ end of global - insert your declaration only before this line * The follow definition is new in the BW3.x TYPES: BEGIN OF DATA_PACKAGE_STRUCTURE. INCLUDE STRUCTURE /BIC/CSZIS_DEMO2. TYPES: RECNO LIKE sy-tabix, END OF DATA_PACKAGE_STRUCTURE. DATA: DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE WITH HEADER LINE WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

*-*

*-*

FORM startup TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n DATA_PACKAGE STRUCTURE DATA_PACKAGE USING RECORD_ALL LIKE SY-TABIX SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update * *$*$ begin of routine - insert your code only below this line *-* * fill the internal tables "MONITOR" and/or "MONITOR_RECNO", * to make monitor entries * if abort is not equal zero, the update process will be canceled ABORT = 0. *$*$ end of routine - insert your code only before this line * ENDFORM. *-*

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 5

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Code After Start Routine: Write the below code in code window, here I written Customer is equal to 000000C100 or C100, because 0CUSTOMER length is 10 and so if record will come with or without leading zeros the code will work.

PROGRAM UPDATE_ROUTINE. *$*$ begin of global - insert your declaration only below this line * TABLES: ... * DATA: ... *$*$ end of global - insert your declaration only before this line * The follow definition is new in the BW3.x TYPES: BEGIN OF DATA_PACKAGE_STRUCTURE. INCLUDE STRUCTURE /BIC/CSZIS_DEMO2. TYPES: RECNO LIKE sy-tabix, END OF DATA_PACKAGE_STRUCTURE. DATA:

*-*

*-*

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 6

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE WITH HEADER LINE WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0. FORM startup TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n DATA_PACKAGE STRUCTURE DATA_PACKAGE USING RECORD_ALL LIKE SY-TABIX SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update * *$*$ begin of routine - insert your code only below this line *-* * fill the internal tables "MONITOR" and/or "MONITOR_RECNO", * to make monitor entries ***Start Rt, Begin****Surendra Kumar Reddy Koduru******* DATA: WA_DATA_PACKAGE LIKE DATA_PACKAGE, ZINDEX LIKE SY-TABIX. LOOP AT DATA_PACKAGE INTO WA_DATA_PACKAGE. CLEAR ZINDEX. ZINDEX = SY-TABIX. If WA_DATA_PACKAGE-CUSTOMER = '000000C100' OR WA_DATA_PACKAGE-CUSTOMER = 'C100' OR WA_DATA_PACKAGE-CUSTOMER = '000000C101' OR WA_DATA_PACKAGE-CUSTOMER = 'C101' OR WA_DATA_PACKAGE-CUSTOMER = '000000C102' OR WA_DATA_PACKAGE-CUSTOMER = 'C102' OR WA_DATA_PACKAGE-CUSTOMER = '000000C103' OR WA_DATA_PACKAGE-CUSTOMER = 'C103'. DELETE DATA_PACKAGE INDEX ZINDEX. CONTINUE. ENDIF. ENDLOOP.

***Start Rt, End******Surendra Kumar Reddy Koduru*******

* if abort is not equal zero, the update process will be canceled ABORT = 0. *$*$ end of routine - insert your code only before this line * ENDFORM. *-*

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 7

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

After that Check the Syntax then Save, and come back.

In above screen, you can fine the message called No Syntax Errors Found. So our code is correct and now we can Save, Activate the Update Rules.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 8

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Data Loading: After activation, load the data form Flat File.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 9

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Monitor the Data Load: After Load, go to Monitor, see the below screen.

See the number of records; in Flat file we have only Five records, so it is displaying only Five records.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 10

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Click on Header Tab and then click on Termination if records occur, see below screen.

It opens the detailed window about the status of records updating, see below screen, totally we have 5 records in Flat file and 5 sent and 5 received, PSA got 5 records, but finally updated only One record in InfoCube, because Start Routine in Update rules worked properly.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 11

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Request Details: See the Request in InfoCube using Manage

In above screen, we can find One request with 5 Transferred and 1 Added records.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 12

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Display Data in InfoCube: See the Data In the InfoCube using Display Data

See one single record which is Customer = C104, other records are deleted. Data in PSA :

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 13

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Data in Source Flat File:

How to Debug the Start Routine in Update Rules:


Change Start Routine: Click on Change Start Routine like below.

It opens the below code window like below, keep break point i.e. BREAK-POINT.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 14

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 15

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Data Loading: InfoPackage Settings:

See the above screen, Open the InfoPackage and then go to Processing Tab and then choose Only PSA. The reason is after PSA Load we will load the data into InfoCube, in between we will debug the Start Routine. After PSA Settings then open Schedule tab and then Start Data Loading.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 16

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Monitor the Data Load: After Load, go to Monitor, see the below screen.

See the number of records; in Flat file we have only Five records, so it is displaying only Five records. In addition that you can see the Process Manually, because we loaded up to PSA.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 17

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Manual Update/Simulation: Open Details Tab and select the Data Package 1 and right Click and Choose Simulate Update.

Select the Activate Debugging in Update Rules, because we written Start Routine in Update Rules and click on Perform Simulation button.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 18

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Debugger Window: It opens the debugging window like below.

Press F7, till it will reach our Code. Our Code: See our code and BREAK-POINT, from now onwards press F5, it will go line by line.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 19

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Data Package: Double click on DATA_PACKAGE, it will come and appear in Right side, see below screen.

Double click on Small Icon before DATA_PACKAGE in right side, it will show the actual Data in that Data Package like below.

Click on Desktop1 tab and then press F5, it will debug line by line.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 20

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

We have 5 records in Flat File, so it deleted all 4 records which will satisfy our Condition in Start Routine and the rest of the records i.e. only one will appear in DATA PACKAGE, see below screen.

Then press F8.

Close the above window it will display the details of the records updated. After that Load data manually from PSA to InfoCube then see the Request/Data in InfoCube.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 21

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

How to Write Start Routine in Transformations: Introduction:


How to write a Start Routine in Transformations. Here I took one example i.e., needs to delete the unwanted data in Start Routine of Transformations based on Customer number. Live Scenario: We are loading the data to InfoCube, the Source system is Flat File (the logic, code and execution is same for even any SAP Source systems also) and we need to delete the unwanted records/data in Transformations at the time of data loads based on some Customer numbers. InfoCube Details: See the below screens, which will give the details of the InfoCube ZIC_DEMO1.

Note: I had taken ZIC_DEMO1 InfoCube, which is having just simple Transformations.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 22

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Create Start Routine: Click on Start Routine like below.

It opens the below code window.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 23

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Code Before Start Routine:


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_SC_1, Field: MATERIAL Material. MATERIAL TYPE C LENGTH 18, Field: PLANT Plant. PLANT TYPE C LENGTH 4, Field: CUSTOMER Customer. CUSTOMER TYPE C LENGTH 10, Field: CALDAY Calendar Day. CALDAY TYPE D, Field: AMOUNT Amount. AMOUNT TYPE P LENGTH 9 DECIMALS 2, Field: CURRENCY. CURRENCY TYPE C LENGTH 5, Field: QUANT_B Qty in OUn. QUANT_B TYPE P LENGTH 9 DECIMALS 3, Field: BASE_UOM. BASE_UOM TYPE C LENGTH 3, Field: RECORD Record Number. RECORD TYPE RSARECORD, END OF _ty_s_SC_1. TYPES: _ty_t_SC_1 TYPE STANDARD TABLE OF _ty_s_SC_1 WITH NON-UNIQUE DEFAULT KEY. *-*

* * * * * * * * *

*$*$ begin of global - insert your declaration only below this line ... "insert your code here

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 24

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

*$*$ end of global - insert your declaration only before this line METHODS start_routine IMPORTING request type rsrequest datapackid type rsdatapid EXPORTING monitor type rstr_ty_t_monitors CHANGING SOURCE_PACKAGE type _ty_t_SC_1 RAISING cx_rsrout_abort. METHODS inverse_start_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 ... "insert your code here *$*$ end of 2nd part global - insert your code only before this line

*-*

* *

*---------------------------------------------------------------------* * CLASS routine IMPLEMENTATION *---------------------------------------------------------------------* * *---------------------------------------------------------------------* CLASS lcl_transform IMPLEMENTATION. *----------------------------------------------------------------------* * Method start_routine *----------------------------------------------------------------------* * Calculation of source package via start routine *----------------------------------------------------------------------* * <-> source package *----------------------------------------------------------------------* METHOD start_routine. *=== Segments === FIELD-SYMBOLS: <SOURCE_FIELDS> DATA: MONITOR_REC

TYPE _ty_s_SC_1.

TYPE rstmonitor. *-*

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

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 25

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

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

*$*$ end of routine - insert your code only before this line *-* ENDMETHOD. "start_routine *----------------------------------------------------------------------* * Method inverse_start_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_start_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_start_routine "routine IMPLEMENTATION

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 26

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Code After Start Routine: Write the below code in code window, here I written Customer is equal to 000000C100 or C100, because 0CUSTOMER length is 10 and so if record will come with or without leading zeros the code will work.

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'

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 27

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

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_SC_1, Field: MATERIAL Material. MATERIAL TYPE C LENGTH 18, Field: PLANT Plant. PLANT TYPE C LENGTH 4, Field: CUSTOMER Customer. CUSTOMER TYPE C LENGTH 10, Field: CALDAY Calendar Day. CALDAY TYPE D, Field: AMOUNT Amount. AMOUNT TYPE P LENGTH 9 DECIMALS 2, Field: CURRENCY. CURRENCY TYPE C LENGTH 5, Field: QUANT_B Qty in OUn. QUANT_B TYPE P LENGTH 9 DECIMALS 3, Field: BASE_UOM. BASE_UOM TYPE C LENGTH 3, Field: RECORD Record Number. RECORD TYPE RSARECORD, END OF _ty_s_SC_1. TYPES: _ty_t_SC_1 TYPE STANDARD TABLE OF _ty_s_SC_1 WITH NON-UNIQUE DEFAULT KEY. *-* *-*

* * * * * * * * *

*$*$ begin of global - insert your declaration only below this line ... "insert your code here *$*$ end of global - insert your declaration only before this line METHODS start_routine IMPORTING request type rsrequest datapackid type rsdatapid EXPORTING monitor type rstr_ty_t_monitors CHANGING SOURCE_PACKAGE type _ty_t_SC_1 RAISING cx_rsrout_abort. METHODS inverse_start_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

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 28

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

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 ... "insert your code here *$*$ end of 2nd part global - insert your code only before this line *---------------------------------------------------------------------* * CLASS routine IMPLEMENTATION *---------------------------------------------------------------------* * *---------------------------------------------------------------------* CLASS lcl_transform IMPLEMENTATION. *----------------------------------------------------------------------* * Method start_routine *----------------------------------------------------------------------* * Calculation of source package via start routine *----------------------------------------------------------------------* * <-> source package *----------------------------------------------------------------------* METHOD start_routine. *=== Segments === FIELD-SYMBOLS: <SOURCE_FIELDS> DATA: MONITOR_REC * *

TYPE _ty_s_SC_1.

TYPE rstmonitor. *-*

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

************Begin of Start Rt**Surendra Kumar Reddy Koduru************** DATA : WA_SOURCE_PACKAGE TYPE _ty_s_SC_1, ZINDEX LIKE SY-TABIX. LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE. CLEAR ZINDEX. ZINDEX = SY-TABIX. If WA_SOURCE_PACKAGE-CUSTOMER WA_SOURCE_PACKAGE-CUSTOMER WA_SOURCE_PACKAGE-CUSTOMER WA_SOURCE_PACKAGE-CUSTOMER WA_SOURCE_PACKAGE-CUSTOMER WA_SOURCE_PACKAGE-CUSTOMER WA_SOURCE_PACKAGE-CUSTOMER = = = = = = = '000000C100' 'C100' OR '000000C101' 'C101' OR '000000C102' 'C102' OR '000000C103' OR OR OR OR

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 29

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

WA_SOURCE_PACKAGE-CUSTOMER = 'C103'. DELETE SOURCE_PACKAGE INDEX ZINDEX. CONTINUE. ENDIF. ENDLOOP. ************End of Start Rt**Surendra Kumar Reddy Koduru****************

*-- fill table "MONITOR" with values of structure "MONITOR_REC" *to make monitor entries ... "to cancel the update process * raise exception type CX_RSROUT_ABORT.

*$*$ end of routine - insert your code only before this line *-* ENDMETHOD. "start_routine *----------------------------------------------------------------------* * Method inverse_start_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_start_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_start_routine "routine IMPLEMENTATION

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 30

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

After that Check the Syntax then Save, and come back. So our code is correct and now we can Save, Activate the Transformations.

Data Loading: After activation, load the data form Flat File. We are working in BI 7.X, so there are only Transformations in between DataSource and InfoSource (in this example). So in BI 7.X once you create Transformations and DTP, InfoPackage is only used to load the data up to PSA, after that we need to use DTP (to load the data from PSA to Data Targets). In below InfoPackage, see the Processing Tab and Data Targets Tab.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 31

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 32

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Monitor the Data Load: After Load, go to Monitor, see the below screen.

See the number of records; in Flat file we have only Five records, so it is displaying only Five records.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 33

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

See the above screen, the data is loaded only up to PSA, from there we need to execute DTP to load the data into InfoCube.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 34

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 35

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Request Details: See the Request in InfoCube using Manage.

In above screen, we can find One request with 5 Transferred and 1 Added records.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 36

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Display Data in InfoCube: See the Data In the InfoCube using Display Data

See one single record which is Customer = C104, other records are deleted. Data in PSA:

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 37

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Data in Source Flat File:

How to Debug Start Routine in Transformations: Introduction:


How to Debug the Start Routine in Transformations, before this article you please reads/go through the content called How to Write a Start Routine in Transformations. Here I taken one example i.e., needs to delete the unwanted data in Start Routine of Transformations based on Customer number and we will debug the same Live Scenario: We are loading the data to InfoCube, the Source system is Flat File (the logic, code and execution is same for even any SAP Source systems also) and we need to delete the unwanted records/data in Transformations at the time of data loads based on some Customer numbers. So in scenario we will how to debug the start routine Transformations. Change Start Routine: Click on Change Start Routine like below.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 38

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

It opens the below code window like below, keep break point i.e. BREAK-POINT.

In above screen, you can see the code that we written in How to write Start Routine in Transformations. Check the Syntax Check, Save and Activate the Transformations.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 39

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Data Loading: InfoPackage Settings: After activation, load the data form Flat File. We are working in BI 7.X, so there are only Transformations in between DataSource and InfoSource (in this example). So in BI 7.X once you create Transformations and DTP, InfoPackage is only used to load the data up to PSA, after that we need to use DTP (to load the data from PSA to Data Targets). In below InfoPackage, see the Processing Tab and Data Targets Tab.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 40

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

After PSA Settings then open Schedule tab and then Start Data Loading.

Monitor the Data Load: After Load, go to Monitor, see the below screen.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 41

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

See the number of records; in Flat file we have only five records, so it is displaying only five records.

DTP and Settings for Debug: See the above screen, the data is loaded only up to PSA, from there we need to execute DTP to load the data into InfoCube. Here we are trying to Debug the Start Routine, so we need to set some settings in DTP, right click on DTP and select Change and go to Execute Tab give Processing Mode is equal to Serially in the Dialog Process (for Debugging).

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 42

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 43

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

After above settings to DTP, then simulate.

Once you click on Simulate button then it will open the Debug screen, and it will go to our Code there we put BREAK-POINT, then press F5 for line by line debug.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 44

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Debugger Window:

Press F5 till the Break Point indicator cross the line ZINDEX = SY-TABIX, after that double click on SOURCE_PACKAGE, it will show in Right Side under Variable. See the below screen.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 45

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Double click on SOURCE_PACKAGE , and then see the original data in that.

Then click on Desktop 1 and then Press F5 for 3 to 4 times and then again see the data in SOURCE_PACKAGE. First record is deleted, because it satisfied our condition in Start Routine i.e. Customer = C100, so it is deleted.

So like that you click on Desktop 1 and then press F5, till it completes the 5 cycles i.e. it need to come out th from Loop condition. After 4 Cycle , if you see the data in SOURCE_PACKAGE, you can find only one record.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 46

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

After that Press F8 it will come out from Debug and show the below screen, in this way we can debug.

After the above Simulation, you remove the BREAK-POINT in Start Routine, Save and Activate the Transformations. And Execute the DTP, it will load the data to InfoCube and then check the Request and Data in InfoCube.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 47

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

Related Content
For all Articles and Blogs by Surendra Kumar Reddy, Please visit this URL Using Customer Exit Variables in BW Reports Part - 5 Using Customer Exit Variables in BW Reports Part - 6 Using Customer Exit Variables in BW Reports: Part - 8 Using Customer Exit Variables in BW Reports: Part - 9 Using Customer Exit Variables in BW Reports: Part - 10 Using Customer Exit Variables in BW Reports: Part - 11 Using Customer Exit Variables in BW Reports: Part - 12 Using Customer Exit Variables in BW Reports: Part - 13 Using Customer Exit Variables in BW Reports: Part - 14 Using Customer Exit Variables in BW Reports: Part - 15 Using Customer Exit Variables in BW Reports: Part - 16 Using Customer Exit Variables in BW Reports: Part - 17 Using Customer Exit Variables in BW Reports: Part - 18 Using Text Variables with Customer Exits in Report Headings Using Text Variables with Customer Exits in Report Headings Variables of Type Customer Exit For more information, visit the EDW homepage

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 48

How to Write Start Routine in Update Rules, Transformations and How to Debug the Routines

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 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 49

You might also like