Вы находитесь на странице: 1из 13

Using Rule Group in SAP-BI.

Part - 1

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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 1
Using Rule Group in SAP-BI. Part - 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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 2
Using Rule Group in SAP-BI. Part - 1

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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 3
Using Rule Group in SAP-BI. Part - 1

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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 4
Using Rule Group in SAP-BI. Part - 1

Note: Here I’m not displaying all Tabs of DataSource.

Create Transformations.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 5
Using Rule Group in SAP-BI. Part - 1

By default Standard Group will create by system.

Here, I modified the Standard Group based on Movement type and Flag.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 6
Using Rule Group in SAP-BI. Part - 1

See the Rule Details.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 7
Using Rule Group in SAP-BI. Part - 1

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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 8
Using Rule Group in SAP-BI. Part - 1

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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 9
Using Rule Group in SAP-BI. Part - 1

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

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 10
Using Rule Group in SAP-BI. Part - 1

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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 11
Using Rule Group in SAP-BI. Part - 1

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.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 12
Using Rule Group in SAP-BI. Part - 1

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


© 2009 SAP AG 13

Вам также может понравиться