Using OOPS ABAP (Class Concept) in Transformations in SAP BI

Applies to:
BI 7.0. For more information, visit the EDW homepage

Summary
This article explains a step by step procedure on how to use OOPS ABAP in BI Transformations with an example. Author: Hemant Khemani
th

Company: Wipro Technologies Created on: 06 January 2011

Author Bio
Hemant Khemani is a SAP BI Consultant with Wipro Technologies. He has more than 4 years of experience in SAP BI.

SAP COMMUNITY NETWORK © 2011 SAP AG

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

..............uac.............com | BPX ........................... 6 Step 4: Declaring Method Parameters ..................................................................................................................................................... 8 Step 7: Save and Activate the Class. ..................................................................................................................................................Using OOPS ABAP (Class Concept) in Transformations in SAP BI Table of Contents Introduction ........................................................................................................................................... 7 Step 5: Declaring Exceptions (if any) ................ 7 Step 6: Defining Class Methods ...................................................................................................................................................................................................................... 5 Step 1: Go to SE24 -> Give the Class Name and click on Create.... 3 Scenario ................com 2 .........................................................................................................................................................................................sap........................................................................................................................................................sap.................com | UAC .............................................................................bpx................boc........................................................................ ............................................................................ 8 Using the Class in Transformation ....sap.......................sdn........................................................ 10 Related Content ........................................................................................................................ 5 Creating Class .....sap..... 9 Checking the Data....... 11 Disclaimer and Liability Notice .............................................. 3 Step by Step Procedure ............................................................................................................................... 5 Step 2: Creating Class Attribute ............................................. 5 Step 3: Declaring Class Methods .....................................................................com | BOC .......... 12 SAP COMMUNITY NETWORK © 2010 SAP AG SDN ...........................................................................................................

uac. ZPO_CUBE -> Target Cube SAP COMMUNITY NETWORK © 2010 SAP AG SDN .Using OOPS ABAP (Class Concept) in Transformations in SAP BI Introduction Now-a-days.com | BPX .boc. The objects involved in the scenario are listed below: 1. most clients demand that routines in various transformations in SAP BI must be coded using OOPS ABAP methodology.com | UAC . We can create generic method and use it at multiple places.sdn.sap.com | BOC .sap.bpx.  Similar routine logic need not to be written again. The main advantage of using OOPS ABAP methodology in transformations is given below.sap. Scenario We will be loading purchasing related information to BW.com 3 .sap.

com | BOC .com 4 .sap. ZMAT_DSO -> LOOKUP DSO Dataflow The purchasing data will be loaded from PO Details DSO ZPO_DSO to purchasing Infocube ZPO_CUBE.com | BPX .com | UAC .sdn.sap.sap.Using OOPS ABAP (Class Concept) in Transformations in SAP BI 2. amount) which is not present in the source DSO ZPO_DSO will be populated by reading data from DSO ZMAT_DSO in the transformation from DSO ZPO_DSO -> Cube ZPO_CUBE.bpx.uac.boc. ZPO_DSO -> Source DSO 3. Some of the information (vendor. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . currency.sap.

sap.sdn.com | BPX .com | UAC . Create Structure SAP COMMUNITY NETWORK © 2010 SAP AG SDN .uac.com | BOC .boc.Using OOPS ABAP (Class Concept) in Transformations in SAP BI Step by Step Procedure Creating Class Step 1: Go to SE24 -> Give the Class Name and click on Create. For this we will follow steps: a.bpx.com 5 .sap.sap.sap. Step 2: Creating Class Attribute Create an internal table (in our example) as an attribute of the class.

Using OOPS ABAP (Class Concept) in Transformations in SAP BI b. Go to Method tab and declare the methods as shown below.com 6 . Step 3: Declaring Class Methods a.sap. Create Table Type c.boc.com | BPX .sdn. We have used 2 methods as shown above in our example Method 1 .sap.uac.com | UAC .com | BOC .sap.FILL_ITAB Method 2 .bpx. Create attribute MT_FILL_ITAB with associated type as ZBW_T_MAT_DETAILS The above attribute MT_FILL_ITAB can now be used as an internal table in the class methods.sap.GET_FIELD_VALUE SAP COMMUNITY NETWORK © 2010 SAP AG SDN .

RV_RESULT (structure) – Returning parameter – this will send required data to the caller.bpx. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.boc. Method 2 . Step 5: Declaring Exceptions (if any) We are not using any exception for the methods in our example.uac.com | BOC .com | UAC .com | BPX .sap. IT_PACKAGE – Importing parameter .com 7 .sap.FILL_ITAB This method will be called from the Start routine in the transformation. IT_MATERIAL – Importing parameter – this will receive material value from the caller.sdn.is a standard table which will receive the data from the caller.GET_FIELD_VALUE This method will be called from field routines in the transformation.sap.Using OOPS ABAP (Class Concept) in Transformations in SAP BI Step 4: Declaring Method Parameters Method 1 .

b.bpx.uac.sap.com | UAC .com | BOC . SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com 8 .sap. Method GET_FIELD_VALUE --. Method FILL_ITAB --. Step 7: Save and Activate the Class.sap.Using OOPS ABAP (Class Concept) in Transformations in SAP BI Step 6: Defining Class Methods a.boc.com | BPX .In this method we will read the required data from the Look up DSO ZMAT_DSO and fill it into the internal table MT_FILL_ITAB.In this method we will read the required data based on the material value from the internal table MT_FILL_ITAB and will send the corresponding details back to the caller in structure RV_RESULT.sdn.sap.

com | UAC . For 0VENDOR For 0AMOUNT Next. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . Method 2 – GET_FIELD_VALUE This method is called in the field routines for 0VENDOR and 0AMOUNT.sap.bpx.sap. The input passed to the method is 0MATERIAL. As we can see below. Method 1 – FILL ITAB This method is called in the start routine.boc.com | BOC .com 9 . The method then populates the internal table with the required information from DSO ZMAT_DSO.sap. we will run the DTP to load the data.sap. Global data type to receive values returned from the method GET_FIELD_VALUE. Creating class object Calling Methods a.Using OOPS ABAP (Class Concept) in Transformations in SAP BI Using the Class in Transformation Global Declaration In start routine we will first declare the class under global declaration so that we can use the class in the start routine and field routines.com | BPX .uac.sdn. b. SOURCE_PACKAGE is passed to this method.

Using OOPS ABAP (Class Concept) in Transformations in SAP BI Checking the Data Source Data – DSO ZPO_DSO LOOKUP Data – DSO ZMAT_DSO Target data – Infocube ZPO_CUBE SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.bpx.uac.sap.com | BPX .com 10 .sap.com | BOC .sdn.boc.com | UAC .sap.

visit the EDW homepage SAP COMMUNITY NETWORK © 2010 SAP AG SDN .uac.com 11 .Using OOPS ABAP (Class Concept) in Transformations in SAP BI Related Content SAP help on Routines in Transformations Beginner's Guide to BI .ABAP For more information.com | BPX .sap.com | UAC .sap.sdn.sap.sap.boc.com | BOC .bpx.

uac.com | UAC .com | BOC . 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. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .bpx.boc. SAP will not be held liable for any damages caused by using or misusing the information. Changes made based on this information are not supported and can be overwritten during an upgrade.sap.com 12 . or seek to hold. and anyone using these methods does so at his/her own risk. including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP.sap.com | BPX . SAP responsible or liable with respect to the content of this document.sap.Using OOPS ABAP (Class Concept) in Transformations in SAP BI 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. You agree that you will not hold. code or methods suggested in this document.sap.sdn.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.