You are on page 1of 12

How To Use ABAP Classes Instead of CMOD for BW Datasource Enhancements

Applies to:
SAP BW source systems (e.g. ECC and CRM) as of SAP_BASIS 6.20 and PI_BASIS 2004_1. For more information, visit the EDW homepage.

Summary
The following document describes the steps required to achieve BW datasource enhancements in an SAP source system using classes (Object Oriented Programming) instead of the function modules EXIT_SAPLRSAP_00* (* = 1 to 4) via transaction CMOD. It meets the key requirement of modularization to facilitate the promotion of developments specific to a developer on a project team. Author: Marvin Perumal

Company: SAP South Africa Created on: 6 June 2011

Author Bio
Marvin is an SAP Principal BI Solution Consultant with more than 8 years experience in the Mining, Banking, Automotive, Consumer Products, Public Sector, Freight Logistics, Healthcare, Oil and Gas and Chemical industries, assuming responsibilities of team lead, project manager, integration manager and solution architect.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

Table of Contents
1. 2. 3. 4. Background ............................................................................................................................................ 3 Prerequisites .......................................................................................................................................... 3 Limitations .............................................................................................................................................. 3 Procedure .............................................................................................................................................. 4 4.1. Create the BADI Implementation with the Decision Method ................................................................. 4 4.2. Create the Datasource-Specific Class................................................................................................... 6 4.3. Test the Datasource .............................................................................................................................. 8 Appendix A.......................................................................................................................................................... 9 A.1. Code for DATA_TRANSFORM Method in Implementing Class ZCL_IM_RSU5_SAPI_BADI ........... 9 A.2. Sample Code for DATA_TRANSFORM method in datasource-specific class ZPERSON_ATTR ..... 9 Related Content ................................................................................................................................................ 11 Copyright........................................................................................................................................................... 12

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

1. Background
To understand the proposed solution, a basic understanding of BADIs and classes is required. Business Add-ins (BADIs) are provided by SAP that may be used to customize the BW extraction from source systems. A Business Add-in needs to be implemented by an Implementation. That implementation is assigned to an Implementing Class. The Implementing Class contains interfaces and methods.

BADI

BADI Implementation

Implementing Class

The proposed solution uses the following architecture based on the SAP provided BADI RSU5_SAPI_BADI which contains two methods: DATA_TRANSFORM HIER_TRANSFORM Execution of all implementations for multiple use BADI RSU5_SAPI_BADI Only one Implementation of BADI RSU5_SAPI_BADI

Datasource execution

Execution of datasourcespecific class

The above architecture has the following advantages: Usage of object oriented programming techniques. Modularisation of implementation classes per datasource facilitating development promotion (transports). Execution of a single BADI implementation and only the related datasource-specific class during execution of a datasource. Creation of a template for future enhancements of datasources.

2. Prerequisites
Developer key on the SAP ECC system that you are extracting data from. Create an append structure with ZZ fields that will be filled by the datasource-specific class implementation. The BADI-definition RSU5_SAPI_BADI (SE18) exists in your system. Include LRSAPF06 includes call interfaces of the BADI-methods.

3. Limitations
Creation of the append structure for the datasource that is to be enhanced is not demonstrated as mentioned in the prerequisites. Coding logic for the decision method in the case of a hierarchy datasource is not provided this does not differ significantly from the same decision method for transaction and master data discussed below (refer to SAP Note 691154). Steps for linking (e.g. via transformations) the enhanced datasource to objects (e.g. DSOs or InfoCubes) in SAP BW are not explained.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

4. Procedure
All the steps below should be performed in the BW source system (e.g. ECC or CRM) 4.1. Create the BADI Implementation with the Decision Method 4.1.1. Go to transaction SE18 Select the radio button for BAdI Name Enter BADI RSU5_SAPI_BADI Select Create from the Enhancement Implementation menu item

4.1.2.

Enter an Implementation Name"

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

4.1.3.

Enter a description for the implementation class and activate

4.1.4. Go to transaction SE80, select your development package and you will find the implementation that you just created under the Enhancements folder.

4.1.5. Double click on the implementation ZRSU5_SAPI_BADI and select the Interface tab. You will find the following two methods listed for interface IF_EX_RSU5_SAPI_BADI in the implementing class ZCL_IM_RSU5_SAPI_BADI:

DATA_TRANSFORM HIER_TRANSFORM

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

4.1.6.

Double click on the DATA-TRANSFORM method and click on the mode.

icon to go into Change

This method will be used as a decision-method to identify the correct datasource-specific class to call. Insert the code from Appendix A.1 into the method and activate (method and class).

4.2.

Create the Datasource-Specific Class

4.2.6. Next, we will need to create the datasource-specific class. Right-click on the Classes folder within your development package and select Create

4.2.7. Enter a Class name similar to the datasource for which you are creating the class, but replace the first character with a Z. For example, the class that will be created to enhance the datasource 0PERSON_ATTR would be named ZPERSON_ATTR. This naming convention is important as it is the basis for the coding logic in the decision method created in step 4.1.6 above. If you decide to change this naming convention, the coding logic in the decision method must be adjusted accordingly. Future datasource specific classes can be copied from this initial example and adjusted as required.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

4.2.8.

Select the Methods tab and add a method called DATA_TRANSFORM.

4.2.9.

Click on the Parameters button.

4.2.10. Capture the following parameters (these may be copied from the decision method created in step 4.1.6 above).

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

4.2.11. Click on the Methods button

4.2.12. Double click on the DATA-TRANSFORM method and click on the icon to go into Change mode. This is where the coding logic will defer depending on datasource for which the class has been created. Appendix A.2 provides sample code that extracts two customized fields (ZZ_INITS and ZZRUFNM) from table PA0002. N.B. Change the coding logic (and align with the append structure) as required by your datasource enhancement requirement. 4.2.13. Activate method DATA_TRANSFORM.

4.2.14. Click on the Previous Object button and activate the implementation class ZPERSON_ATTR.

4.3. Test the Datasource 4.3.6. You are now ready to test your datasource, enhanced by object oriented programming techniques, in transaction RSA3.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

Appendix A
A.1. Code for DATA_TRANSFORM Method in Implementing Class ZCL_IM_RSU5_SAPI_BADI
Data: ClassName Type SEOCLSNAME. ClassName = I_DATASOURCE. Shift ClassName Left By 1 Places. Concatenate 'Z' ClassName Into ClassName. Select Into From Where Single CLSNAME ClassName SEOCLASS CLSNAME = ClassName.

Case Sy-SubRC. When 0. When Others. Return. EndCase. Call Method (ClassName)=>DATA_TRANSFORM EXPORTING I_DATASOURCE = I_DATASOURCE I_UPDMODE = I_UPDMODE I_T_SELECT = I_T_SELECT I_T_FIELDS = I_T_FIELDS CHANGING C_T_DATA = C_T_DATA C_T_MESSAGES = C_T_MESSAGES.

A.2. Sample Code for DATA_TRANSFORM method in datasource-specific class ZPERSON_ATTR


DATA: L_TABIX TYPE SY-TABIX, PA0002_WA TYPE PA0002, C_T_DATA_TAB TYPE TABLE OF HRMS_BW_IO_PERSON, C_T_DATA_WA TYPE HRMS_BW_IO_PERSON. CASE I_datasource. WHEN '0PERSON_ATTR'. WHEN OTHERS. RETURN. ENDCASE. REFRESH C_T_DATA_TAB. C_T_DATA_TAB = C_T_DATA. LOOP AT C_T_DATA_TAB INTO C_T_DATA_WA.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

L_TABIX = SY-TABIX. SELECT SINGLE * FROM PA0002 INTO PA0002_WA WHERE PERNR = C_T_DATA_WA-RFPNR AND ENDDA = '99991231'. IF SY-SUBRC = 0. C_T_DATA_WA-ZZINITS = PA0002_WA-INITS. C_T_DATA_WA-ZZRUFNM = PA0002_WA-RUFNM. TRANSLATE C_T_DATA_WA-ZZINITS TO upper case. TRANSLATE C_T_DATA_WA-ZZRUFNM TO upper case. MODIFY C_T_DATA_TAB FROM C_T_DATA_WA INDEX L_TABIX . ENDIF. ENDLOOP. C_T_DATA = C_T_DATA_TAB.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

Related Content
Note 691154 - SAPI with BADI: User exits in SAPI with BADI-interfaces Enhancing DataSources with BAdI RSU5_SAPI_BADI. How to Implement BAdI for Enhancing the Datasource in ECC . 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 11

How ToUse ABAP Classes Instead of CMOD for BW Datasource Enhancements

Copyright
Copyright 2011 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

SAP COMMUNITY NETWORK 2011 SAP AG

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

You might also like