You are on page 1of 19

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Applies to:
SAP BW 3.5 / SAP 7.0 Consultants have knowledge in SAP CRM 5.0 / SAP CRM 7.0. For more information, visit the EDW Homepage .

Summary
Enhance the SAP CRM Business Activity Transaction using transaction EEWB and extract the enhanced data (Custom Data) to BW using Generic Extraction (Function Module Extraction). Author: Suraj Tigga

Company: Capgemini Consulting Created on: 4 March 2011

Author Bio
Suraj Tigga is a Senior SAP BI / ABAP consultant at Capgemini Consulting, India. Suraj joined Capgemini Consulting in 2008 and has worked on multiple SAP BI implementation and support projects.

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Table of Contents
Scenario .............................................................................................................................................................. 3 Step-by-Step Procedure.................................................................................................................................. 3 Enhancement (EEWB) - Business Activity...................................................................................................... 3
Easy Enhancement Workbench (EEWB) ..................................................................................................................... 7

Generic Extraction (Business Activity) Function Module ........................................................................... 11


Extraction Function Module........................................................................................................................................ 11 Generic Datasource ................................................................................................................................................... 13 Function Module Code ............................................................................................................................................... 14

Related Content ................................................................................................................................................ 18 Disclaimer and Liability Notice .......................................................................................................................... 19

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Scenario
In this document, we would be focusing on the special features involved in enhancement of Business Activity using Easy Enhancement Workbench (EEBW) and extracting the enhanced fields data to SAP BI using Function Module Generic Extraction. In the following, we will pay particular attention to sub areas that make up the special features of SAP CRM Business Activity, enhancement of Business Activity and Extraction. The document does not cover general customizing, for example, the definition of an Infocube or the Creation of a Datasource for storing SAP CRM data in BI.A basic knowledge of CRM is required. Step-by-Step Procedure Above mentioned scenario would consist of primarily two important steps: a) Enhancement (EEWB) Business Activity: Creation of Project and required Extension for EEWB for Bus Object (BUSINESS_ACTIVITY) and Extension Type (ACTIVITY_H).

b) Generic Extraction (Business Activity) Function Module: Creation of Generic Datasource and its concerned Function Module to extract data from the required Database tables relevant to Business Activity. Enhancement (EEWB) - Business Activity Easy Enhancement Workbench is a development tool with which SAP applications can be extended in a simple manner. This tool provides a wizard, allowing the definition of an extension. The Customizing Include is generated according to that definition. Using Easy Enhancement Workbench has the following advantages: No actions in the Data Dictionary are necessary, a wizard guides you through the extension process Tool contains information on all existing Customizing Includes Currently Easy Enhancement Workbench only generates the Customizing Include and its data elements and domains. All UI specific properties are either generated automatically at the application runtime or defined manually.

Object Business Partner

Customizing Include CI_EEW_BUT000

Object Business Transaction Pricing Parameter Set

Customizing Include CI_EEW_PRICING

Business Transaction Business Transaction Item Activity Header

CI_EEW_ORDERADM_H

Transaction Item - Price Business Transaction Item -Schedule Line Transaction Item Service Transaction - Additional Extension

CI_EEW_PRICING_I

CI_EEW_ORDERADM_I

CI_EEW_SCHEDLIN

CI_EEW_ACTIVITY_H

CI_EEW_SERVICE_I

Activity Item

CI_EEW_ACTIVITY_I

CI_EEW_CUSTOMER_H

Opportunity

CI_EEW_OPPORT_H

Transaction Item Additional

CI_EEW_CUSTOMER_I

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Extension

Lead Transaction Item Product Transaction Item Financing Product Business Transaction Sales Set Business Transaction Shipping Set Business Transaction Billing Set Organizational Unit Set

CI_EEW_LEAD_H CI_EEW_PRODUCT_I

SDB - Symptom SDB - Solution

CI_EEW_ISMP CI_EEW_ISOL

CI_EEW_FINPROD_I

Marketing element: Basic data

CI_EEW_MKTPL_BDINC

CI_EEW_SALES

Marketing element: Execution

CI_EEW_MKTPL_CHINC

CI_EEW_SHIPPING

Installed Base (header)

CI_EEW_IBIB

CI_EEW_BILLING

Installed Base Component Addition/Specialization

CI_EEW_IBSP

CI_EEW_ORGMAN

CRM Case

CI_EEW_CRMT_CMG

System Landscape must be set up in order to be able to use system-wide generation. The system landscape must be set up in order to be able to use system-wide generation. Cross-application components General application functions Easy Enhancement Workbench Maintain system landscape

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Subobjects for the business transaction can be enhanced, they offer a customer include structure for new fields:
EEWB Bus Object ACCOUNT_PLAN Extension Type BASIC_DATA (Basic Data) EEWB Bus Object COMPLAINTS Extension Type BILLING(Extend Billing Set) CUSTOMER_H(Extend Transactional Extn) CUSTOMER_I(Extend Item Additional Extn) ORGMAN(Extend Organizational Unit Set) PRICING(Extend Pricing parameter Set) PRICING_I(Extend Item Price) PRODUCT_I(Extend Item Product) SALES(Extend Sales Set) SCHEDLIN(Extend Item Schedule Line)

ADS

ADS (Analytical Data Storage)

COMPLAINTS

BUPA

ADD_NEW_ATTRIBUTES_TAB LE (Add New Attributes) ADD_NEW_FIELDS (Add New Fields) ADD_NEW_ATTRIBUTES_TAB LE (Add New Attributes) ACTIVITY_H(Extend Activity)

COMPLAINTS

BUPA

COMPLAINTS

BUPR

COMPLAINTS

BUSINESS_ACTIVITY

COMPLAINTS

BUSINESS_ACTIVITY

ORGMAN(Extend Organizational Unit Set) ADD_NEW_FIELDS(Add New Fields) ADD_NEW_ITEM_COMPONEN T(New Business Transaction Comps) CUSTOMER_H(Extend Transaction Additional Extension) CUSTOMER_I(Extend Item Additional Extension) ORDERADM_H(Extend Transaction Header) ORDERADM_I(Extend Transaction Item) ADD_ATTRIBUTES(Add Category Attributes)

COMPLAINTS

BUSINESS_TRANSACTION

COMPLAINTS

BUSINESS_TRANSACTION

COMPLAINTS

BUSINESS_TRANSACTION

COMPLAINTS

SHIPPING(Extend Shipping Set)

BUSINESS_TRANSACTION

INDIVIDUAL_OBJECT

ADS(Created Analytical Data Storage) ADDITION(Extend Supplement) INSTALLED_BASE(Exte nd Installed Base) CUSTOMER_H(Extend Transactional Add. Extension) LEAD_H(Extend Lead)

BUSINESS_TRANSACTION

INSTALLED_BASE

BUSINESS_TRANSACTION

INSTALLED_BASE

CATEGORY_ENHANCEMENT

LEAD

CATEGORY_ENHANCEMENT

ADD_OBJECT_LINKS(Category: Add Object Rel.)

LEAD

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

OPPORTUNITY

CUSTOMER_H(Extend Transaction Add Extn) CUSTOMER_I(Extend Item Add Extension) OPPORT_H(Extend Opportunity

LEAD

ORGMAN(Extend Organizational Unit Set) PRODUCT_I(Extend Item Product) SCHEDLIN(Extend Item Schedule Line) BILLING(Extend Billing Set) CUSTOMER_H(Extend Transac. Add. Extn) CUSTOMER_I(Extend Item Add. Extn) ORGMAN(Extend Organizational unit Set) PRICING(Extend Pricing parameter set)

OPPORTUNITY

LEAD

OPPORTUNITY

LEAD

OPPORTUNITY

ORGMAN(Extend Organizational Unit Set PRICING(Extend Pricing Parameter Set) PRICING_I(Extend Item Price)

SALES_TRANSACTIO N SALES_TRANSACTIO N SALES_TRANSACTIO N SALES_TRANSACTIO N SALES_TRANSACTIO N

OPPORTUNITY

OPPORTUNITY

OPPORTUNITY

PRODUCT_I(Extend Item Product) SCHEDLIN(Extend Item Schedule Line)

OPPORTUNITY

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Easy Enhancement Workbench (EEWB) Below are the steps mentioned to create a Project and the required Extension meant for Business Activity. Listed below are the fields which are to be enhanced for the Business Activity Transaction:

Batch / Lot #(CHAR-15) , Date of Interaction(DATS-8), Time(TIMS-6), Product ID(CHAR-40), Product Description(CHAR-40), Sales Order Ref(CHAR-40),Delivery Doc Ref(CHAR-40), Customer PO(CHAR-40), Contact Method(CHAR-40), Product Group(CHAR-40), Contact Method(CHAR-20), Product Group9CHAR20), Product Group(CHAR-30), Product Group(CHAR-50), Product Group(CHAR-10), Contact Method39CHAR-30),Contact Method(CHAR-20), and Product Group3(CHAR-10) Step1: Go to transaction EEWB and create Project ZIRFIELDS as below:

Step2: Right-Click and create Extension ZIINTFIELDS1 for the above mentioned fields using the Wizard: Define Title:

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Select Business Transaction Types:

Define Fields:

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Assign Fields

Define Relevance of Fields for Follow-up Functions

Complete the execution after all the above steps are done successfully

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Step3: Check the Business Activity transaction for the added custom fields:

Custom fields are successfully added.

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Generic Extraction (Business Activity) Function Module To fetch the above custom fields values we would perform the following steps: a) Function Module to extract the Business Activity Custom field Values b) Generic Datasource which would be linked with Function Module Extraction Function Module Step1: Create the Structure ZCRM_ACTIVITY_H which would contain the custom fields values along with the Activity Header GUID

Step2: Create a function module ZBI_CRM_ACTIVITY_H to extract the relevant data Data Flow: CRMD_ORDERADM_H (Business Transaction)
GUID = GUID GUID = GUID

CRMD_ACTIVITY_H (Activity)

CRMD_CUSTOMER_H (Transaction - Customer Extension)

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Pseudo-Code: Fetch all the newly created CRM Business Activity transactions from table CRMD_ORDERADM_H. For all the entries fetched above, fetch the Contact Method3 and Product Group from table CRMD_ACTIVITY_H header table. For the entries fetched from table CRMD_ORDERADM_H, get the Product Group3 from table CRMD_CUSTOMER_H. Based on the above values brought in above three steps, combine the data and populate the extractor output records.

For complete code, refer to section Function Module Code.

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Generic Datasource Step1: Go to transaction RSO2, Create Generic Datasource ZCRM_ACTIVITY_H

Function Module: ZBI_CRM_ACTIVITY_H Extract Structure: ZCRM_ACTIVITY_H Next Steps (Required in SAP BI): a) Map the standard datasource (0CRM_SALES_ACT_1 Activities) and Generic Datasource (ZCRM_ACTIVITY_H) to DSO 0SAL_DS01 (ODS for Activities).

0SAL_DS01
(ODS for Activities)

0CRM_SALES_ACT_1 (Activities Header)

ZCRM_ACTIVITY_H (Generic Extractor)

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Function Module Code Complete Code:


FUNCTION zbi_crm_activity_h. *"---------------------------------------------------------------------*"*"Local Interface: *" IMPORTING *" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR *" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL *" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL *" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL *" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL *" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF *" TABLES *" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL *" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL *" E_T_DATA STRUCTURE ZCRM_ACTIVITY_H OPTIONAL *" EXCEPTIONS *" NO_MORE_DATA *" ERROR_PASSED_TO_MESS_HANDLER *"---------------------------------------------------------------------TABLES zcrm_activity_h. ****** TYPES DECLARATION ***************** * Get the values from CRMD_ACTIVITY_H TYPES : BEGIN OF typ_crmd_activity_h , guid TYPE crmt_object_guid , zzprogrp3 TYPE zeew_dataelement0802 , zzcontactmethod4 TYPE zeew_dataelement0901 , zz_ir_cm TYPE zeew_dataelement1501, END OF typ_crmd_activity_h , * Transaction Customer Enhancement BEGIN OF typ_crmd_customer_h , guid TYPE crmt_object_guid , zzprogrp4 TYPE zeew_dataelement0902 , END OF typ_crmd_customer_h . * Work Area DATA : wa_crmd_activity_h TYPE typ_crmd_activity_h , wa_e_t_data TYPE zcrm_activity_h , wa_crmd_customer_h TYPE typ_crmd_customer_h. * Internal Table DATA: t_crmd_activity_h TYPE STANDARD TABLE OF typ_crmd_activity_h , t_crmd_customer_h TYPE STANDARD TABLE OF typ_crmd_customer_h. * Auxiliary Selection criteria structure DATA: l_s_select TYPE srsc_s_select. * Maximum number of lines for DB table STATICS: s_s_if TYPE srsc_s_if_simple, * counter s_counter_datapakid LIKE sy-tabix, * cursor s_cursor TYPE cursor. * Select ranges

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

RANGES: l_r_objid l_r_ptype

FOR zcrm_activity_h-object_id , FOR zcrm_activity_h-process_type.

* Initialization mode (first call by SAPI) or data transfer mode * (following calls) ? IF i_initflag = sbiwa_c_flag_on. ************************************************************************ * Initialization: check input parameters * buffer input parameters * prepare data selection ************************************************************************ * Check DataSource validity CASE i_dsource. WHEN 'ZCRM_ACTIVITY_H'. WHEN OTHERS. IF 1 = 2. MESSAGE e009(r3). ENDIF. * this is a typical log call. Please write every error message like this log_write 'E' "message type 'R3' "message class '009' "message number i_dsource "message variable 1 ' '. "message variable 2 RAISE error_passed_to_mess_handler. ENDCASE. APPEND LINES OF i_t_select TO s_s_if-t_select. * Fill parameter buffer for data extraction calls s_s_if-requnr = i_requnr. s_s_if-dsource = i_dsource. s_s_if-maxsize = i_maxsize. * Fill field list table for an optimized select statement * (in case that there is no 1:1 relation between InfoSource fields * and database table fields this may be far from beeing trivial) APPEND LINES OF i_t_fields TO s_s_if-t_fields. ELSE. "Initialization mode or data extraction ?

************************************************************************ * Data transfer: First Call OPEN CURSOR + FETCH * Following Calls FETCH only ************************************************************************ * First data package -> OPEN CURSOR IF s_counter_datapakid = 0. * Fill range tables BW will only pass down simple selection criteria * of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'. LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'OBJECT_ID'. MOVE-CORRESPONDING l_s_select TO l_r_objid. APPEND l_r_objid. ENDLOOP.

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'PROCESS_TYPE'. MOVE-CORRESPONDING l_s_select TO l_r_ptype. APPEND l_r_ptype. ENDLOOP. * * * * * Determine number of database records to be read per FETCH statement from input parameter I_MAXSIZE. If there is a one to one relation between DataSource table lines and database entries, this is trivial. In other cases, it may be impossible and some estimated value has to be determined. OPEN CURSOR WITH HOLD s_cursor FOR SELECT * FROM crmd_orderadm_h WHERE object_id IN l_r_objid AND process_type IN l_r_ptype. ENDIF. "First data package ? Fetch records into interface table. named E_T_'Name of extract structure'. FETCH NEXT CURSOR s_cursor APPENDING CORRESPONDING FIELDS OF TABLE e_t_data PACKAGE SIZE s_s_if-maxsize . IF sy-subrc EQ 0 . SORT e_t_data BY guid ASCENDING. Retrieve the values from table CRMD_ACTIVITY_H SELECT guid zzprogrp3 zzcontactmethod4 zz_ir_cm FROM crmd_activity_h INTO TABLE t_crmd_activity_h FOR ALL ENTRIES IN e_t_data WHERE guid EQ e_t_data-guid. IF sy-subrc EQ 0. SORT t_crmd_activity_h BY guid ASCENDING. ENDIF. retreive data from table CRMD_CUSTOMER_H SELECT guid zzprogrp4 FROM crmd_customer_h INTO TABLE t_crmd_customer_h FOR ALL ENTRIES IN e_t_data WHERE guid EQ e_t_data-guid. IF sy-subrc EQ 0. SORT t_crmd_customer_h BY guid ASCENDING. ENDIF. LOOP AT e_t_data INTO wa_e_t_data. Read records from table CRMD_ACTIVITY_H READ TABLE t_crmd_activity_h INTO wa_crmd_activity_h WITH KEY guid = wa_e_t_data-guid BINARY SEARCH. IF sy-subrc EQ 0. MOVE-CORRESPONDING wa_crmd_activity_h TO wa_e_t_data. ENDIF. Read records from table CRMD_CUSTOMER_H READ TABLE t_crmd_customer_h INTO wa_crmd_customer_h WITH KEY guid = wa_e_t_data-guid BINARY SEARCH.

* * *

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

IF sy-subrc EQ 0. wa_e_t_data-zzprogrp4 = wa_crmd_customer_h-zzprogrp4. ENDIF. MODIFY e_t_data FROM wa_e_t_data. CLEAR wa_e_t_data. ENDLOOP. ENDIF . IF sy-subrc <> 0. CLOSE CURSOR s_cursor. RAISE no_more_data. ENDIF. s_counter_datapakid = s_counter_datapakid + 1. ENDIF. ENDFUNCTION. "Initialization mode or data extraction ?

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

Related Content
For more information visit EDW Homepage. Help.sap.com

SAP COMMUNITY NETWORK 2011 SAP AG

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

SAP BW - Enhance SAP CRM Business Activity Transaction and Extract Data to BW

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 2011 SAP AG

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

You might also like