Sei sulla pagina 1di 8

2/12/2014

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

0 e Usi ng a BDoc BAdI


Hom e > CRM > Artic les > 6 Steps to Enhance a CRM Data Sourc

More
Share

6 Steps to Enhance a CRM DataSource Using a BDoc BAdI


by Liang Ma, Specialist Mast er, Deloit te Consult ing LLP
July 15, 2007

SAP experts/CRM
Lea rn about a new method you and your BW te am ca n use to report on i nform ation obta ined when you a dd ne w
partner functions to SAP CRM the Business Document Business Add-In. Thi s six -step process a llows you to
col lect data in re al ti me and ena bles you to loa d the data into SAP NetWe aver Business I ntell igence to use for
reporting. You can also use this proce ss to add other customize d fie lds to SAP CRM.
Key Concept
SAP CRM uses BW Adapter to extrac t dat a from SAP CRM and s end it to SAP B usiness Information Warehouse and
SAP NetW eaver Business Intelligence. Y ou us e BW Adapt er when you have Synchronizati on Business Documents
(sBDocs) and Messa ging Business Docume nts (mBDocs). For sB Docs, BW A dapter ext racts objects relevant to
mobile c lient s. For mBDocs, BW Adapter extracts objec ts for CRM business trans actions and CRM billing.

Say you add a new partner function in SAP CRM and you want to be able to report on it us ing S AP NetWeaver Busines s
Int elligence (BI). Youve checked transaction BW A5 and you know that the DataS ource is handled by BW Adapter. You
want to populate t he enhanced fields in real time, which means that the enhanc ed fields are written to the delta at the time
you save the trans action. In this case, you can use a Business Document (BDoc) Business Add-In (BA dI) t o enhance the
CRM DataSourc e. This is a new process many CRM-BW implementat ions still use the t radit ional BAdI or user exit
processes.
Ill show you how to carry out this new process. Firs t, you need to check if t he partner func tion you want t o use is
available in the s tandard ex tract or in transaction RS A6. Then Ill walk y ou through the six s teps you need t o tak e to add a
new part ner function to the SAP CRM sales order extractor and use the BDoc BAdI. I used SAP CRM 2005 for this
process, but it also applies to S AP CRM 4.0. The proc ess in this art icle involves t he BI capabilit ies of SAP NetW eaver
2004s, but you can use this process with earlier vers ions, such as S AP Busines s Informat ion W arehouse (BW) 3.5.
Typically a B W bac k-end developer who has S AP CRM as the DataSource in the BW system performs thes e steps.

Business Scenario
In my ex ample, I want t o add the partner function PLANT Ship-To Party for Returns t o the SAP CRM s ales order. This
tracks returned it ems s o I c an report on them us ing t he BI capabilit ies of SAP NetW eaver 2004s. The standard extractor in
this cas e, 0CRM_SALES_ORDER_I, does not inc lude this partner function.
Figure 1 shows the business-to-consumer (B2C) Internet Sales sc reen after CRM partner function configuration is
complete. In the proces s I describe, Ill explain how SAP NetWeaver BI ex tract s this partner funct ion.

Fi gure 1

The CRM Sales Orde r has a va lue 4444444444 for partne r function PLANT Shi p-To Party

http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

1/8

2/12/2014

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

for Returns

Check Partner Function Availability


In this example, I chec ked t he st andard ext ractor using transac tion code RSA6 first (Figure 2). In this screen you can see
the list of all of the activated DataS ources in the s ource syst em. Click on the Dat aSource 0CRM_SALES_ORDER_I to
bring up the screen in Figure 3. As you can see, the partner function PLANT Ship-To Party for Returns is not included.

Fi gure 2

Cli ck on the DataS ource 0CRM_SALES_ORDER_I to vi ew al l of the fields in the ex traction


structure

http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

2/8

2/12/2014

Fi gure 3

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

Fie lds i n the standard extra ctor for CRM Sa les Order extra ctor
CRMT_BW_SALES _ORDER_I

Now that I know that the partner funct ion I need is not st andard, I will show you s tep by step how to add it .

Add a New Partner Function


Follow t hese six s teps to add the new partner function to the S AP CRM sales order:
Step 1. Creat e an append structure for the 0CRM_SALES _ORDER_I
Step 2. Check if t he busines s content is ac tive for t he SA P CRM sales order DataSource
Step 3. Check the extraction structure and the B Doc mapping
Step 4. Creat e a new BA dI implementation to fill the enhanced field in the append s truct ure
Step 5. Activate t he new BAdI implementation
Step 6. Test the new BA dI implementation in the extractor check er
Ste p 1. Create an append structure for 0CRM_SALES_ORDER_I. In t he append struc ture you add an enhanced field
that contains the partner function. Double-click on t he st ructure CRMT_BW _SALES_ORDER_I in Figure 3. The Display
Append S tructure s creen appears. Selec t Goto>Append S tructure t o create a new or select an ex isting append
structure. In my example, I selec ted t he ex isting append s truct ure ZBW_SALE_ITEM. A dd the enhanced field as a new
component in the append structure and call it something meaningful, such as ZZPLANT_PARTNER (Figure 4).
http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

3/8

2/12/2014

Fi gure 4

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

ZZP LANT_PARTNER added i n the appe nd structure

Ste p 2. Check if the business content is active for the SAP CRM sale s order Da taSource. Follow IMG menu path
SBI W>Data Tra nsfer to the SAP BIW >Settings for Application-Specific DataS ource s (CRM). In this example, I have a
Mes saging Bus iness Document (mBDoc) because I am not dealing with mobile clients. For mB Docs, BW A dapter ext racts
objects for CRM busines s transact ions and CRM billing use the B AdI CRM_BW A_MFLOW. B W Adapter calls the mBDoc
BAdI CRM_BWA_MFLOW to enhanc e the part ner function PLANT S hip-To Party for Returns.
In SAP CRM 2005, use transac tion code BWA5 to check if the business content is active for your CRM DataSourc e in
my example, t his is 0CRM_SALES_ORDER_I (Figure 5). In SAP CRM 2005, the business content should be active
aut omatically . However, in releas es prior t o SAP CRM 2005, after using transac tion code RSA5 to ac tivat e bus iness
content in SA P CRM, you must use trans action code BWA5 to activate t he busines s content for t he BW Adapter.

Fi gure 5

Tra nsaction BWA5: The DataSources in CRM ma rked as Active for BW Ada pter

Ste p 3. Check the extra ction structure and the BDoc m apping. Us e transact ion c ode BWA1 (creat e or enhance new
CRM-spec ific DataS ources using the BW Adapt er). Enter the CRM DataSource you want t o check in my example, this
is 0CRM_SALES_ORDER_I(Figure 6). Clic k on the Displa y but ton t o see the extract st ructure and confirm that it
mat ches your CRM DataSource (Figure 7).

Fi gure 6

Che ck the 0CRM_SALES_ORDER_I Data Source

http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

4/8

2/12/2014

Fi gure 7

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

The extract structure i n thi s screen m atche s 0CRM_SALES_ORDER_I

Figure 7 shows that the BW A dapter knows about t he additional field, but it does not yet know how to fill it . In the
following steps you show BW Adapt er how to fill these fields. The Ma pping tab contains t he mapping of B Doc fields to t he
ext ract struc ture fields, but you dont need to take any action here.
Ste p 4. Create a new BAdI im pleme ntati on to fill the enhanced field in the append structure. The Object -Oriented
(OO) ABA P code in a BAdI is based on t he concept of c lasses, methods , and inheritance, but you do not have t o
understand this fully t o implement a B AdI. Simply think of methods as a function module with the s ame import and export
parameters and follow t he simple instructions below t o implement the BDoc BAdI.
In trans action SE19 (BA dI implementations), in t he Create Imple menta tion section, s elect Classic BAdI and enter
CRM_BWA_MFLOW as t he BAdI Na me (Figure 8). Click on t he Create Impl. butt on and name the new implementation
ZBI_EXT_ORDITM.

http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

5/8

2/12/2014

Fi gure 8

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

Enter CRM_BWA_MFLOW as the BAdI Name to cre ate a new imple menta tion

Aft er you create ZBI_EX T_ORDITM, click on t he Interfa ce tab to see t he BA dI implementation with the Interface Name
IF_EX_CRM_BWA_MFLOW (Fi gure 9). The sy stem assigns the met hod ENHANCE_DATA_SOURCE, which cont ains the
logic to populate the enhanc ed field.

Fi gure 9

BAdI implementation with interface nam e IF_EX_CRM_BWA_MFLOW and method


ENHANCE_DATA_SOURCE

Double-c lick on ENHANCE_DATA_SOURCE and ent er the coding for the met hod between the methodand endmethod
statements (Figure 10). You can download the code for this from the Downloads section at the end of this art icle.
http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

6/8

2/12/2014

Figure 10

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

Add the code in the BAdI method

Ste p 5. Activate the ne w BAdI implementation. In transaction SE19, c lick on Enhancement Imple menta tion> Activate
to activate ZBI_EX T_ORDITM. After you implement this BAdI, you can also display your implementation by using
transact ion c ode S BIW and following IMG menu pat h Data Tra nsfer to the SAP Business Informati on Wa rehouse>
Settings for Appli cation-Spe cific Data Sources (CRM)>S ettings for BW Adapter>BAdI BW Adapter: Enhancement of
DataSource in the Messa ging Flow.
Ste p 6. Test the new BAdI im pleme ntati on in the extra ctor checker. A fter you add the new implement ation
ZBI _EXT_ORDITM, run transact ion RSA3. Youll see the screen in Figure 11 (without t he De bug Mode c heck box
selected). Ex ecute the extractor check er. If you filt er the value to this sales order, y ou see the result shown in Figure 12
(ZZ_PLANT_PARTNER populated with partner number 4444444444).

Figure 11

Test the new BAdI imple menta tion

Figure 12

The enha nced field show s the expe cted value 4444444444

http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

7/8

2/12/2014

SAPexperts | 6 Steps to Enhance a CRM DataSource Using a BDoc BAdI

If the value is not what you expected in this example 4444444444 select De bug Mode in Figure 11 and run the
ext ractor checker again. Set the BAdI break point for debugging at the first st op when you run transaction RS A3, as shown
in Figure 13.

Figure 13

Set the breakpoint at the me thod you w ant to debug

Now that you have the enhanc ed field in the extract s truct ure and have populat ed the value with the BDoc BAdI, it is ready
for the BW team to extract t o SAP NetW eaver BI. Follow the same proc ess t hat y ou would for any other enhancements :
Replicat e the enhanced DataS ource in S AP BW
Add the enhanced InfoObject in the dat a container: DataStore Object or InfoCube
Map the enhanced fields in t he transformation or InfoSourc e
Load the data

Liang Ma
Liang Ma is a spec ialis t mas ter in Deloittes SA P BI/ BW practic e, specializing in B I and data
warehous e solutions in the S AP platform. She has more than 10 y ears of SA P experience
inc luding SAP NetW eaver BW, SAP B usinessObjects, and ABAP. Liang rec ently spok e at the
SAP conferenc es SA P CRM 2011, SAP Reporting, Planning and Analy tics 2010, SAP CRM
2009, S AP CRM 2010 and SAP Business Object s User 2009. In addition, she has also
published art icles in t he following SA Pexperts hubs: BI, CRM, and Financials.
Deloitte shall not be responsible for any loss s ustained b y any pers on who relies on this
pub licat ion. As us ed in this document, Deloitte means Deloitt e Consulting LLP, a subsidiary
of Deloitte LLP. P lease see www.deloit te.com/us/ about for a det ailed desc ription of the legal
structure of Deloitte LLP and its subs idiaries.
See more by t his author
If you have c omments about t his article or publication, or would lik e to submit an artic le idea,
please c ontac t the edit or.

http://sapexperts.wispubs.com/CRM/Articles/6-Steps-to-Enhance-a-CRM-DataSource-Using-a-BDoc-BAdI?id=E2188DA12ED64A35AA0C4AA0E068D12C

8/8

Potrebbero piacerti anche