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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 1 How To…Use ABAP Classes Instead of “CMOD” for BW Datasource Enhancements Table of Contents 1. Background ............................................................................................................................................ 3 2. Prerequisites .......................................................................................................................................... 3 3. Limitations .............................................................................................................................................. 3 4. 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 2 How To…Use 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 Only one Execution of Datasource implementations for Implementation of datasource- execution “multiple use” BADI BADI specific class “RSU5_SAPI_BADI” “RSU5_SAPI_BADI” 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 3 How To…Use 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 4 How To…Use 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 5 How To…Use ABAP Classes Instead of “CMOD” for BW Datasource Enhancements 4.1.6. Double click on the “DATA-TRANSFORM” method and click on the icon to go into “Change” mode. 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 6 How To…Use 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 7 How To…Use 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 8 How To…Use 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 Single CLSNAME Into ClassName From SEOCLASS Where 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 9 How To…Use 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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 10
Description: