Excerpt: The SAP CRM Data Model

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

SAP CRM: Technical Principles and Programming,” by Stephen Johannes, 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 on insiderBOOKS.com

SAP has several major data objects that are key to the application: business partners, products, business transactions, and marketing attributes. Every SAP CRM module uses at least one of these four objects to support the business process represented by that module.

Now that you know about the design of the data model, we’ll discuss each of these major objects in SAP CRM in detail.

Business Partners

The primary focus of CRM is on managing the relationship with the customer. In SAP CRM, the business partner is used to model the customer in the software solution. You first need to learn the business definition of the business partner and then understand how this is technically translated into a database model, which we’ll explain in the following sections. Finally, we’ll discuss some common techniques used to retrieve business partner information from the database model.

Business Definition

As we’ve mentioned, the customer is the heart of CRM, and so the business partner is the heart of SAP CRM. It’s impossible to execute any scenario in SAP CRM without a business partner. A business partner is any person, company, or organization that is part of a relationship between a company and its customers. A business partner can be a customer, vendor, contact person, employee, third party, or other entity that needs to be tracked or is involved in a customer interaction. In traditional SAP ERP, customers, vendors, and contact persons are stored separately and act as different entities. In SAP CRM, all business partners are stored centrally and function based on the role provided.

Everything Is a Partner

One of the hardest concepts to understand for new SAP CRM users is that a business partner isn’t just a customer but rather can represent any party involved in an interaction. One complaint or result from this is that if your master data in your SAP ERP system isn’t clean or is set up in a confusing manner, it will be the same in SAP CRM. Keep this in mind when you get requests about eliminating duplicate data from your SAP CRM system.

Technical Definition

The SAP CRM business partner is based on the generic SAP Business Partner concept. In creating the SAP CRM business partner, new extensions to the SAP Business Partner were created that are only found in SAP CRM. This data is normally referred to as SAP CRM-specific data. The SAP Business Partner is used in other applications such as Financial Supply Chain Management (FSCM) within the SAP ERP system. You’ll also find the SAP Business Partner used in SAP Supplier Relationship Management (SAP SRM) due to the fact that SAP CRM and SAP SRM originally shared a common technical foundation.

The SAP CRM overall data model features three technical divisions:

  • General data is primarily part of the Business Partner data model and was traditionally modeled via the Business Data Toolset (BDT).
  • Address data is based on the generic address management services provided by SAP.
  • Relationship data allows connecting and/or relating business partners in the system together.

The four tables illustrated in Table 1 (and discussed in the following subsections) are the primary tables of the business partner in SAP CRM that connect the business partner to each technical division of data.


Table 1
Primary Business Partner Data Tables

General Data

Because the business partner was designed to be an application service not unique to SAP CRM, the design is different in several aspects from other data objects. The SAP CRM business partner is the only major data object in SAP CRM not using a GUID as a primary key.

The business partner consists of several key tables, each starting with Key tables “BUT.”

Table BUT000

Table BUT000 is considered the primary or header table for the business partner. The primary key is the PARTNER, which is a 10-digit alphanumeric field modeled by the data element BU_PARTNER. The table also has a secondary index based on the field PARTNER_GUID, which is used to link the standard business partner data to SAP CRM extension data and business transactions. The PARTNER_GUID field is found toward the end of the table as shown in Figure 1.


Figure 1
Partner GUID on Table BUT000

Other important fields include TYPE, BPKIND, and BU_GROUP, as shown in Figure 2.


Figure 2
Table BUT000 Header Fields

The TYPE field is one of the most misunderstood fields for the business partner. The sole purpose of this field is to determine the form of address for the business partner (i.e., whether the business partner is a person, organization, or group). You have the following options:

  • A person is typically a contact person or employee in SAP CRM.
  • An organization normally represents a company or other legal entity in SAP CRM.
  • The group isn’t normally used in most typical SAP installations.

BPKIND was designed for field control in the BDT. This field isn’t normally used in newer installations, except as a way to classify SAP CRM partners. BU_GROUP is an important field because it’s the technical equivalent of the account group found in SAP ERP. This field controls the number range that will be created for a business partner. Another interesting aspect of Table BUT000 is the storage of the business partner name. The name storage consists of many different fields and varies based on the type of partner (person, organization, or group). These fields are shown in Table 2.


Table 2
Multiple Name Fields in Table BUT000

It’s important to note that NAME_ORG1 is equivalent to NAME_LAST, and NAME_ORG2 is equivalent to NAME_FIRST. In several applications where you search for business partners by name, these fields are typically combined for both search input and output.

The final feature of the table that we’ll mention is the CI include for customer attributes. This include—called CI_EEW_BUT000—is delivered by SAP for enhancing the business partner with new attributes that are of a 1:1 relationship to the business partner. In Chapter 3, we’ll explain how to extend the SAP CRM business partner.

Table BUT100

Table BUT100 describes the role of a business partner in SAP CRM. This originally controlled the tab order for the SAP GUI Transaction BP, and now it’s used primarily for classification of business partners. This differs from the partner function assignment of the business partner in the sales area data.

SAP CRM-specific data for a business partner consists of the segments detailed in Table 3, which are centered on the sales area data of the customer.


Table 3
Data Segment Tables of the Business Partner

The sales area data in SAP CRM corresponds to the sales area data normally found in SAP ERP. This data is normally used to control the creation of sales orders and assign the business partner to particular sales areas. There are two tables per sales area-related table. The tables that start with CRMM_BUT_LNK link a set of attribute data to a business partner. The tables that start with CRMM_BUT_SET contain a unique set of attributes for a given period of time. Each set has a set of Business Application Programming Interfaces (BAPIs) that follows the naming pattern BAPI_BUPA_FRG<number>_*, where <number> is the four-digit number of the attribute set.

The full data model for the SAP CRM business partner can be viewed via Transaction SD11 and looking at the data model PRM_BP.

Business Partner BAPIs

Normally when reading business partner data, you can use the delivered BAPIs. A BAPI is a remote-enabled function module delivered by SAP. These BAPIs normally start with BAPI_BUPA; some of the more commonly used BAPIs are listed here:

  • BAPI_BUPA_SEARCH Common BAPIs
  • BAPI_BUPA_CENTRAL_GETDETAIL
  • BAPI_BUPA_CREATE_FROM_DATA

As a general rule, ABAP programs in SAP CRM should not be created to directly read data from the tables unless performing a search. Instead, we recommend using the business partner BAPIs and API function modules to retrieve any data required. The primary benefit of this method is that you’ll take advantage of the buffering logic built by SAP and the most optimized path to read this data.

We’ll now look at three coding examples for business partner search, retrieving the details of a business partner, and creating a new business by using the business partner BAPIs.

Listing 1 shows a common coding example to search for business partner data.


Listing 1
BAPI_BUPA_SEARCH

Listing 2 shows a typical coding example to retrieve the central details for a business partner. Note we’re using the function module BUPA_CENTRAL_GET_DETAIL instead of the BAPI because the BAPI won’t return whether the business partner is a person, organization, or group. You only need to pass the partner number to retrieve the primary details of the business partner. Also keep in mind that the business partner number should be zero filled, so you may need to call CONVERSION_EXIT_ALPHA_INPUT to properly format the partner number.


Listing 2
BUPA_CENTRAL_GET_DETAIL

Listing 3 shows a common coding example to create a new business partner from scratch. A business partner in SAP CRM only requires that two fields are maintained to be created. The first field is the country of the business partner. The second field will be LAST_NAME for a person, NAME_ORG1 for an organization, or NAME_GRP1 for a group. All other fields are considered optional unless you’ve configured or extended the system to make a field required.


Listing 3
BUPA_CREATE_FROM_DATA

Address Data

Address data for a business partner includes the mailing address and communication data. The mailing address contains all of the necessary fields to support a postal or physical address. The communication data consists of contact information storage such as telephone numbers (including mobile), fax numbers, email address, and URI for web addresses or other Internet resources. The address data for an SAP CRM business partner is maintained using the Business Address Service (BAS) or Central Address Management (CAM) of the SAP NetWeaver ABAP AS. The business partner data model maintains a link to the address management system via Table BUT020. Normally, you don’t read the address data directly from the database tables. Instead, you can use several function modules to handle this:

  • BUPA_ADDRESSES_GET: Gets the list of addresses for a business partner
  • BUPA_ADDRESS_GET_DETAIL: Gets the details for a particular address

For contact persons and the relationship address information, the function modules are different:

  • BUPR_CONTP_ADDRESSES_GET: Retrieves the addresses for a conact person relationship
  • BUPR_CONTP_ADDR_GET_DETAIL: Retrieves the details of a contract persoon relationship address

Listing 4 shows a typical example for retrieving the address data for a given business partner.


Listing 4
Retrieve Address Data for a Business Partner

Relationship Data

Relationship data describes how two business partners in SAP CRM interact. Typical examples of relationships include contact person and employee responsible for a business partner such as a sales representative.

Table BUT050

Table BUT050 stores the relationships between business partners. This is the second-most important table in the SAP CRM business partner data model next to Table BUT000. The primary key consists of RELNR, PARTNER1, PARTNER2, and DATE_TO. PARTNER1 is the parent partner in a relationship that is expressed by PARTNER1 has related PARTNER2. If you look at a contact person relationship, PARTNER1 is the company, and PARTNER2 is the contact person. The table contains a validity date, which means relationships can be time dependent. However, extra configuration work is required to activate this feature for end users of the system.

An important field not included in the primary key of this table is RELTYP, which defines the type of relationship. The most common relationships you’ll see in your SAP CRM system are BUR001 (Has Contact Person) and BUR010 (Has the Employee Responsible). SAP provides two secondary indexes for this table that allow lookup on PARTNER1 and PARTNER2 based on the relationship type.

Table BUT051

Table BUT051 contains specific information for a contact person relationship. In SAP CRM, a contact contains personal and work address information. Table BUT051 contains the work address, which is equivalent to the relationship address for the contact person.

Listing 5 shows how to retrieve all of the contact persons for a given business partner. This is a common requirement for reporting within an SAP CRM system.


Listing 5
Contact Person Retrieval for a Business Partner
 

Attachments

Attachments for business partners are typically files such as pictures, Microsoft documents, or other types of files. They are stored in the SAP CRM Document Management system, and the best way to access them is using the CL_CRM_DOCUMENTS API. We don’t recommend even trying to retrieve related documents outside of this API. The layers of abstraction for this piece of SAP CRM normally befuddle the most senior developers working with the solution.

Listing 6 is an example to retrieve a list of documents for a business partner and then retrieve each individual document. This example calls the method CL_CRM_DOCUMENTS_API=>GET_WITH_FILE to download them to the end-user’s PC directly via the SAP GUI. You can also call the method GET_WITH_TABLE to store the document into an internal table instead.


Listing 6
Retrieve Document Attachments for a Business Partner

This was an exclusive excerpt from, “SAP CRM: Technical Principles and Programming,” by Stephen Johannes. To order the book or for more information, visit its page on insiderBOOKS.com.

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.


Comments

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.