Applies to: SAP BW 7.X. Summary This article gives clear picture about how to use Rule Group (s) using Rule Type Routine in SAP-BI. Author: Surendra Kumar Reddy Koduru Company: ITC Infotech India Ltd. (Bangalore/INDIA) Created on: 06 July 2009 Author Bio Surendra Kumar Reddy Koduru is a SAP BI consultant currently working with ITC Infotech India Ltd (Bangalore/INDIA). He has got rich experience and worked on various BW/BI implementation/support projects. 2009 SAP AG 1
Table of Contents Introduction:... 3 Live Scenarios:... 3 Steps:... 3 Code - 1:... 8 Code - 2:... 10 Related Content... 12 Copyright...Error! Bookmark not defined. 2009 SAP AG 2
Introduction: This article describes about the Rule Group using Rule Type Routine in SAP-BW. A Rule Group is a group of transformation rules. It contains one transformation rule for each key field of the target. A transformation can contain multiple rule groups. Live Scenarios: In some cases the requirement is like below. Based on some Characteristics values, we need to populate/load the data into different Key Figures in InfoCube. Eg: Here I m explaining one simple scenario using Flat File DataSource. The data in Flat File is like below Based on Movement Type and Flag, I want to load the data into two Key Figures in InfoCube. The conditions are: 1. If Movement Type = 101 or 102 AND Flag = A then load the data into 0AMOUNT KeyFigure in InfoCube. 2. If Movement Type = 101 or 102 or 103 AND Flag = Q then load the data into 0BUDGETPROP KeyFigure in InfoCube. Steps: Create InfoCube with following Objects. 2009 SAP AG 3
Create Flat File DataSource like below. Here in the following screen, in Fields tab we have only Amount Key Figure only. Because we are getting data from DataSource for AMOUNT Field only. But our requirement is, based on the above two conditions we need to split and load the data into Two different Key Figures in InfoCube. 2009 SAP AG 4
Note: Here I m not displaying all Tabs of DataSource. Create Transformations. 2009 SAP AG 5
By default Standard Group will create by system. Here, I modified the Standard Group based on Movement type and Flag. 2009 SAP AG 6
See the Rule Details. 2009 SAP AG 7
Here the Rule type is Routine. Based on Movement type and Flag, we need to load the data to 0AMOUNT Key Figure in InfoCube. Select Rule Type Routine and it will open the Code window, write the following code. Code - 1: Write the following Code. See the routine Code: (Marked in Violet color) DATA: MONITOR_REC TYPE rsmonitor. *$*$ 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.... "to skip a record * raise exception type CX_RSROUT_SKIP_RECORD.... "to clear target fields * raise exception type CX_RSROUT_SKIP_VAL. 2009 SAP AG 8
IF ( SOURCE_FIELDS-MOVETYPE EQ '101' OR SOURCE_FIELDS-MOVETYPE EQ '102') AND SOURCE_FIELDS-/BIC/FLAG EQ 'A'. RESULT = SOURCE_FIELDS-AMOUNT. ENDIF. *$*$ end of routine - insert your code only before this line *-* Create New Rule Group with name RG2, and map Amount Field from DataSource to 0BUDGETPROP InfoObject, for reference please look into the following figure. And see the details of the Rule Group RG2. 2009 SAP AG 9
Select Rule Type Routine and it will open the Code window, write the following code. Code - 2: Write the following Code. See the routine Code: (Marked in Violet color) DATA: MONITOR_REC TYPE rsmonitor. *$*$ 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.... "to skip a record * raise exception type CX_RSROUT_SKIP_RECORD.... "to clear target fields * raise exception type CX_RSROUT_SKIP_VAL. IF ( SOURCE_FIELDS-MOVETYPE EQ '101' OR SOURCE_FIELDS-MOVETYPE EQ '102' OR SOURCE_FIELDS-MOVETYPE EQ '103') AND 2009 SAP AG 10
SOURCE_FIELDS-/BIC/FLAG EQ 'Q'. RESULT = SOURCE_FIELDS-AMOUNT. ENDIF. *$*$ end of routine - insert your code only before this line *-* If you see the two Rule Groups, i.e. Standard and RG2, you can find the Fields and InfoObjects mapping differences In Standard Rule Group, we mapped Amount field to 0AMOUNT, and in Rule Group RG2, Amount Field is mapped to 0BUDGETPROP. Create Data Transfer Processes Create InfoPackage and then execute. ( i.e. InfoPackage & Data Transfer Processes). After successful data load, check the data in InfoCube. 0CALMONTH and 0CALYEAR InfoObejcts are not mapped in Transformations, so it is showing blank in the InfoCube Note: For newly created/modified objects please follow the steps: Check. Save. Activate. 2009 SAP AG 11
Related Content How to use Customer Exit Variables in BW Reports: Part 2 How to use Customer Exit Variables in BW Reports Part - 1 Triggering the Process Chains at particular Date using Events Calculating the Ageing of the Materials How to trigger the Process Chains in BW from ECC How to transfer the Data from SAP-System to Non-SAP system without additional Cost/License For more information, visit the Business Intelligence homepage. 2009 SAP AG 12
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. 2009 SAP AG 13