Common Enhancements in CRM Analytics and Reporting

  • by Stephen Johannes, SAP CRM Developer
  • July 12, 2013

SAP CRM: Technical Principles and Programming,” is by Stephen Johannes. It provides developers and consultants with the technical foundation to be more effective on CRM projects and to increase the success of CRM implementations. For more information about the book, visit its page at

A common requirement in many SAP CRM implementations is to transfer information to the SAP NetWeaver Business Warehouse (BW) system for analytics and reporting. For most SAP CRM customers, business transactions make up the primary information transferred for reporting. Until SAP made the interactive reports available in the newer releases of SAP CRM, there were no other methods to build reports on SAP CRM data without writing a custom ABAP program.

You can enhance the SAP CRM system to add custom attributes to the business transactions. If you use the standard SAP tools such as the Application Enhancement Tool (AET) or Easy Enhancement Workbench (EEWB), the custom fields can be automatically added to the BW data source in SAP CRM. However, there are many situations in which you might want to add information to the data source that is either not a custom field or for which you did not check the option in the EEWB or AET to add the custom attribute. To get around this limitation, you can manually enhance the data source. By enhancing the data source, the new attribute will be made available to your SAP NetWeaver BW system and can be used in reports that you create on that system.


To manually enhance the data source, it must be installed on your SAP CRM system for use by SAP NetWeaver BW. This process typically involves installing the data source using Transaction RSA5 in the SAP CRM system.

We won’t cover the installation of the data source in this chapter. The SAP best practices available at contain guides that detail how to install the SAP NetWeaver BW data sources on your SAP CRM system.

After the data source has been installed, you’re ready to enhance the data source. This process generally requires two different steps. The first step is to enhance the data source structure. The second is to implement the BAdI CRM_BWA_MFLOW to enhance the extractor program for the data source. We’ll discuss these steps in the next subsections.

Enhance the Data Source Structure

To enhance the structure of the data source, there are several steps that you’ll need to follow.

Go to Transaction RSA6, and locate the data source that needs to be enhanced as shown in Figure 1. For this chapter, we’ll examine enhancing the data source 0CRM_SALES_ACT_1, which is used to transfer data from SAP CRM to BW for activity transactions. If you recall from Chapter 2, you created a new business transaction called a social media call report. For this social media call report, you added a new field called ZZHASHTAG via the EEWB. During that enhancement, you didn’t choose to add that field to the BW source structure via the EEWB tool.

Figure 1
Transaction RSA6

Now you’ll need to manually add the field because you don’t want to regenerate your EEWB extension. To do this, follow these steps:

1. Select the 0CRM_SALES_ACT_1 data source, and drill into the display.

2. Click on CRMT_BW_DS_ACTIVITY to pull up the data source structure in a Transaction SE11 view as shown in Figure 2.

Figure 2

3. Click on the Append Structure button. Your structure doesn’t contain any append structures, so you’ll be prompted for the name of your new append structure as shown in Figure 3.

Figure 3
Create Append popup window

4. Call the append “ZACRM_BW_DS_ACTIVITY.”

5. Click on the checkmark icon.

6. Define fields in the append structure on the next screen. For this example, enter the description of the structure as “Activity BW Data Source Extension”. In the Component section, add a new field called “ZZHASHTAG” that is of type ZZHASHTAG.

7. Save your work and assign your append structure to a transportable package.

8. You‘ll be prompted for a transport request. After you provide that information, the append structure will be in inactive status.

9. Activate your structure. Your new append structure will contain a single field called ZZHASHTAG and appear as active (Figure 4).

Figure 4
Fields of the New Append Structure

After the structure is activated, the fields show up in Transaction RSA6. By default, all custom fields added to a data source via the append structure are hidden in the data source definition as shown in Figure 5 (at the bottom of the screen, the new field has the Hide field checkbox selected).

Figure 5
New field hidden

Enable Data to Be Transferred

To allow that data to be transferred to SAP NetWeaver BW, remove the Hide field flag, and the SAP NetWeaver BW system will be able to see that those fields are part of your data source definition (Figure 6). Now that you’ve extended the structure of the data source, you’ll need to build logic that will enhance the extractor programs to put values in your fields.

Figure 6
New fields unhidden

Extractor Program Logic

Now you’re ready for the second step of the process. For SAP NetWeaver BW data sources, the traditional method of enhancing the extractors has been through user exits. In the SAP CRM system, those user exits are available but not used. Instead, SAP CRM has a specific BAdI for enhancements of the extractors for SAP CRM-specific data sources. This BAdI is called CRM_BWA_MFLOW. If you were using the EEWB or AET, an implementation of this BAdI would be automatically generated in your system.

However, in this example, because you decided not to use the tools provided by SAP and instead chose to work manually, you must implement this BAdI manually. A benefit of manually implementing this BAdI is that you can implement virtual attributes that don’t correspond to physical values stored on the SAP CRM database or attributes that cross business objects. A great example is that you might want to transfer the country of the sold-to party in the data source; however, it isn’t stored on your business transaction. You can then instead populate the

attribute virtually by using the CRM_BWA_MFLOW BAdI. In the following subsections, we’ll walk you through the steps to create the BAdI implementation and test your work. We’ll also provide a quick overview of how to accomplish this with AET for your comparison.

Creating the BAdI Implementation

Follow these steps to implement the BAdI:

1. Go to Transaction SE18, and open up the BAdI definition for CRM_BWA_MFLOW.

2. Choose Implementation _ Create from the menu; you’ll then see a popup window as shown in Figure 7.

Figure 7
Create a New BAdI implementation for CRM_BWA_MFLOW

3. Fill in the Implementation Name field; for this example, enter “ZCRM_TPP_BOOK_MFLOW.”

4. Click the Checkmark button. On the next screen, you‘ll need to enter a description for your BAdI implementation. For this example, enter “Activity Data Source Enhancement” as shown in Figure 8.

Figure 8
Implementation Definition ZCRM_TPP_BOOK

5. Click Save. You can now code the method ENHANCE_DATA_SOURCE of your BAdI implementation.

6. On the next tab, double-click on the method. The resulting screen allows you to add code to populate or change values that will be sent to the SAP NetWeaver BW system as shown in Figure 9.

Figure 9
Signature of the ENHACE_DATA_SOURCE Method

The code for the ENHANCE_DATA_SOURCE method follows a general pattern, which is very straightforward. You first must check to see if the data source name matches the data source you want to enhance. This is provided by the I_DATASOURCE parameter.

Next, transfer the data to a local typed copy so you can change the fields. To do this, take the CT_DATA structure, and move the internal table to a local internal table. Finally, loop on the internal table. For each entry, use the GUID provided to find any other information on the business transaction, and then update the corresponding field.

In this example, ZZHASHTAG is stored on the CRMD_CUSTOMER_H table. You’ll use the CRM_CUSTOMER_READ_OW function module to find the value of the ZZHASHTAG for each activity transaction extracted.

As the last step, you’ll transfer your local copy of the data extract back to the CT_DATA parameter. Listing 9.1 shows the completed code to populate the ZZHASHTAG field through the  ENHANCE_DATA_SOURCE method.

Listing 1
Example Code to Populate ZZHASHTAG via ENHANCE_DATA_SOURCE

Testing Your Work

To test your work, use Transaction RSA3. This is the extractor checker transaction that allows you to see if your BAdI is properly populating the new data source structure. As you can see from Figure 10, you can specify the name of your data source and pass selection parameters in to execute a test run of the extractor logic. For this example, enter “0CRM_SALES_ACT_1” as the data source name.

Figure 10
Extractor Checker

Now follow these steps:

1. Scroll down under Selections (Internal Format), and enter “ZSCR” as the From value in the row with the key field of “PROCESS_TYPE”.

2. Click the Extraction button to run the extractor. After the extraction, another screen appears that allows you to display your results as shown in Figure 11.

Figure 11
Transaction RSA3 screen after the extraction completes

3. Click the ALV Grid button to get an ALV grid display of your results. This grid, as shown in Figure 12, allows you to verify that the extractor is now executing your BAdI logic to fill in the additional attribute to the extract structure.

Figure 12
ALV Grid display of extracted records

You can use the DETAIL display button to open a popup as shown in Figure 13 that will show all of the columns of the extract structure in a listing. You can see that your new Hash Tag field is indeed being populated by your extract logic.

Figure 13
Detail display of the extracted record

Comparison Against AET

For the purpose of this example, we walked through the steps of adding your custom field manually. Understanding this manual technique allows you to add fields to the extractor data source that may not be available via the AET. This could include values from related transactions

instead, such as follow-up activities or tasks. However, if you had created your field using the AET, then none of the coding would be required that we just described. Instead, SAP has automatically included exits in the standard extractors to bring in the AET fields, provided that

you checked the BW Reporting checkbox when you created the field in the AET (see Figure 14).

Figure 14
AET Field definition for BW relevant

Final Steps

After you’ve validated that the data source is properly enhanced, you’ll need to work with your BW configurator/developer to enhance the SAP NetWeaver BW data structures to include your new field. This work is beyond the scope of this book; if you’re interested in these steps, review the book Data Modeling in SAP NetWeaver BW by Frank K. Wolf and Stefan Yamada (SAP PRESS, 2011).

If you look at the standard extractor function module CRM_SALES_ACT_1_MAP, there is a call to the method MAP_EXT_FIELDS_FROM_BDOC of the class CL_CRM_1O_EXTENSIBILITY_TOOLS. This method takes a reference GUID, reference GUID type, objects, and bdoc structure. It then returns the changed extract structure. In the CRM_SALES_ACT_1_MAP function module, it looks for extensions in three key areas: ORDERADM_H, CUSTOMER_H, and ACTIVITY_H.

The method first finds the includes that are normally used to extend the object. These are predefined as part of the AET metadata model. Next, the tool determines if any of these includes have been implemented in the system. If the include has been implemented, which means that it contains an actual new field and not just the default dummy field, the tool then calls a mapper that moves the data from the passed in bdoc structure to the extract structure.

Tips and Tricks
You need to make sure that the fields in the extract structure are named exactly identical to the fields in the extension of the program.

The BDoc that is used is the source data provided by the SAP CRM Middleware being sent to the SAP NetWeaver BW system. SAP CRM uses an outbound BDoc when transactions are saved to send data to the SAP NetWeaver BW system.

“SAP CRM: Technical Principles and Programming,” by Stephen Johannes. To order the book or for more information, visit its page on

For more information, visit

Stephen Johannes

Stephen Johannes has worked with SAP CRM as a developer since 2001, providing enhancements to the standard platform for SAP customers in both consulting and application support roles. He currently supports a large, specialty chemical company in the US and is a moderator for the SAP Community Network.

See more by this author

If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.


No comments have been submitted on this article. 

Please log in to post a comment.

To learn more about subscription access to premium content, click here.