SAP CRM Marketing allows you to filter your business partner database to send email campaigns to any target group. Learn how to create custom filters so that you can segment contacts based on virtually any selection criteria.
Key Concept
Standard filters allow you to build target groups based on the contacts' marketing attributes or other criteria, such as their country or region. However, you may have cases in which you want to combine selection criteria or use programming logic to determine whether or not a business partner should be included in a target group. SAP CRM provides the toolset you need to build complex filters that include virtually any type of selection criteria for segmentation.
In 2006, Dow Corning Corporation implemented SAP CRM 2005 as a foundation for our Sales and Marketing functionality. We now use SAP for all our global email-based marketing campaigns.
Each time we execute an email campaign, we first use Segment Builder (transaction CRMD_MKTSEG) to create a target group, which is the list of contacts who will receive the campaign. The criteria for creating the target group vary with each campaign. Many of our campaigns are based on marketing attributes. For example, we may want to target contacts who have expressed an interest in using Dow Corning products in the construction industry. Other campaigns may target different industry sectors, or they may be sent to contacts who have subscribed to our email-based newsletters. Since we have marketing attributes set up for these campaigns, it is easy to create filters for building the target groups. Let me show you how this is done.
Create a Simple Filter Based on a Marketing Attribute
In Segment Builder, the user drags filters into a work area to build a target group from the entire database of business partners.
Target groups are frequently based on marketing attributes, which are fields tied to the business partner record. You can define any number of marketing attributes in your system using transaction CRMD_PROF_CHAR. You can then categorize business partners in your database using these attributes. For example, if you want to flag all the contacts in your database who have an interest in the electronics industry and should receive email campaigns on this topic, you could create a marketing attribute named ELECTRONICS and assign it to an attribute set named SUBSCRIPTIONS. You could then assign contacts to the attribute set and have the system populate the attribute to note their interest in this industry. You could then build a filter based on this marketing attribute to build a target group containing all contacts who have the ELECTRONICS flag populated.
You create the filters in transaction CRMD_MKTDS. For my example, I am creating a filter based on the marketing attribute named NEWSLETTER. The attribute has a data type of CHAR and is one character in length. The valid values are Y and N and the attribute is assigned to an attribute set named GENERAL (Figure 1).

Figure 1
Define the marketing attribute in transaction CRMD_PROF_CHAR
To create a filter based on this marketing attribute, follow these steps:
- In transaction CRMD_MKTDS, select Create Data Source
- Choose an Origin Type of 01 Attribute Set
- Specify the attribute set named GENERAL. Note that the description for this set is General Attributes. This description becomes the name of the data source.
- Save the data source and return to the main screen of CRMD_MKTDS
Next, you need to create an attribute list, which is where you define the filter:
- In transaction CRMD_MKTDS select Create Attribute List
- Enter a description for the list. In this example I enter General Filters.
- Since I intend to use the filter for campaigns, I specify a Category of 01 Campaign Execution and a Segment Type of 100000 Campaign
- Next, choose Assign Data Source and select the data source you just created (General Attributes)
- When you drill down into the General Attributes entry within the attribute list you can see the Receive Newsletter attribute that you created. Check the box next to this attribute.
- Next, right-click on the attribute and choose Create Filter
- A dialog box appears showing the value for the attribute (Y and N). Select the row containing Y.
- Save the attribute list. Your filter should look like the one shown in Figure 2.

Figure 2
Filter based on a marketing attribute
Now that you have defined the filter, you can access it in Segment Builder, as shown in Figure 3. When you drag the filter into the work area of that transaction, it selects only the business partners who have a value of Y in the NEWSLETTER marketing attribute.

Figure 3
The filter becomes available in Segment Builder after you create it
Create a Complex Filter Based on an InfoSet
Creating a filter based on a marketing attribute is relatively easy. However, you may have situations in which you need to use more complex logic to select business partners. Suppose you want to create a filter that segments contacts based on the region where they are located. For example, you may want to send a campaign only to contacts in Europe, while another campaign may be targeted to contacts located in countries that are part of the Association of Southeast Asian Nations (ASEAN). Let me show you how to develop the components you need to create filters for more complicated scenarios.
The procedure for creating a complex filter is similar to the process you went through when you created a simple filter for a marketing attribute. First you create an InfoSet, which reads data from the database. Next, create a data source as you did before, but with the origin type 03 InfoSet rather than 01 Attribute Set. Finally, repeat the steps for defining the filter.
Create a Data Retrieval Program for an InfoSet
You create InfoSets in transaction SQ02. In this example, I use a data retrieval program to read the data into the InfoSet. However, you can also populate an InfoSet from a join, directly from a table, or from a logical database.
In this example, I have kept the logic in the data retrieval program quite simple to illustrate the concept of using such a program in an InfoSet. Your logic may be much more involved, depending on the type of filter you need to create. You should design your program with performance in mind, especially if you will be filtering a large business partner database.
Figure 4 shows the source code for data retrieval program ZCRM_READ_COUNTRY_GROUP. You may choose to use this sample code as a starting point for developing your own InfoSet.

Figure 4
Source code for data retrieval program ZCRM_READ_COUNTRY_GROUP
If you analyze the sample code, you can see the comment * after the TABLES statement. You must include this comment in the data retrieval program. It should appear after the TABLES and DATA statements and before the actual program logic. You can see that the first SELECT statement reads entries from a table named ZVALUE. This is a generic table of values that is used to associate groups of codes and lookup values. Figure 5 shows a subset of the records that are read when the ZVALUE table is accessed.
Note
For more information about using generic tables of values, see my SAPexperts article “Simplify SAP CRM Maintenance with a Generic Table of Values.”

Figure 5
Entries in the ZVALUE table associate a country in the CODE column with one or more country groups in the VALUE column. The TYPE for this group of records is COUNTRY_GROUP.
The next SELECT statement in the data retrieval program reads the view named BBPV_BUPA_ADDR, which joins the business partner table BUT000 with address tables BUT020 and ADRC. You can simplify the data retrieval code greatly by reading this view, rather than recreating the logic to join these tables in the code. The SELECT statement looks for business partners whose country matches the entry that was just read from ZVALUE. Each matching entry is placed in the output structure.
In this example, I have chosen to use the SAP-delivered structure BUPA_DATA_ALL as the output structure. You can simplify the development process by reusing an existing structure, or you may choose to create your own. The main requirement is that the structure must include the PARTNER_GUID field.
In this scenario, I also need a long field in which to place my filter criterion. I will use BUPA_DATA_ALL-REMARK (address notes) for this purpose. Each time the second SELECT statement reads a matching business partner, the system populates the PARTNER_GUID and the REMARK fields in the output structure. The first field contains the unique identifier for each business partner. The REMARK field contains the VALUE entry from the ZVALUE table, so it contains a string such as Europe, EU or Asia, ASEAN.
Immediately after the line of code that populates the output structure, you see the comment * . This comment must be included in the data retrieval routine within a looping block (SELECT, DO, or LOOP AT). The comment should appear at the point where the output structure contains one row of data but before the loop is closed with ENDSELECT, ENDDO, or ENDLOOP. Note that the program logic populates the table structure BUPA_DATA_ALL within the loop, but the table is not appended. The data retrieval program works correctly as long as the structure defined in the TABLES statement is populated with a single record each time the system executes the loop.
To summarize, each time the program logic passes the * comment, the BUPA_DATA_ALL structure contains a record similar to ones shown in Figure 6. In the next section, I will design a filter to select only records that contain “Europe” or “ASEAN” in the REMARK field so that the system retrieves a subset of the business partners.

Figure 6
Sample data in fields PARTNER_GUID and REMARK in output structure BUPA_DATA_ALL
Tip!
When you are developing a data retrieval program, you may want to temporarily insert a WRITE statement after the * placeholder, similar to the WRITE statement that has been commented-out in the sample code. This allows you to execute the program in transaction SE38 and verify that the output structure is being populated correctly before you proceed with building the InfoSet.
Create the InfoSet
After you have created the data retrieval program and have verified that it is working correctly, you can build the InfoSet by completing these steps:
- Go into transaction SQ02 (SAP Query: maintain InfoSet)
- Specify an InfoSet name. I use ZCRM_COUNTRY_GROUP in this example
- Click on the Create button
- Next, you are prompted to enter a Name for the InfoSet, along with the parameters that define its data source. Enter the Data structure that the data retrieval program populates and the External program that reads the data, as shown in Figure 7.
- The next screen shows the structure for the InfoSet and the field in it. Save the InfoSet and generate it from this screen.

Figure 7
The Data structure and External program name are specified when the InfoSet is created
When the system generates the InfoSet, you can create a filter that uses it. The procedure for this filter is similar to the process you went through previously:
- In transaction CRMD_MKTDS, select Create Data Source
- Choose an Origin Type of 03 InfoSet, rather than 01 Attribute Set as you did before
- Specify the InfoSet you just created, ZCRM_COUNTRY_GROUP
- The description is the name for the data source. In this example, I use Data Source for Country Group.
- The Business Partner field should contain the output structure field that holds each partner's GUID. The data retrieval program populated the BUPA_DATA_ALL-PARTNER_GUID field, so you should specify that field in the data source.
- After you have specified the parameters as shown in Figure 8, save the data source

Figure 8
Parameters for a data source that uses an InfoSet
Next, you continue by creating the attribute list and the filter:
- In transaction CRMD_MKTDS, select Create Attribute List
- Enter a description for the list. In this example, I use Country Group.
- This filter is for campaigns, so I again specify a category of 01 Campaign Execution and a segment type of 100000 Campaign
- Next, choose Assign Data Source and select the data source you just created (Data Source for Country Group)
- When you drill down into the Data Source for Country Group entry within the attribute list, you see the all the fields in the BUPA_DATA_ALL structure. In this transaction, the descriptions for the fields are displayed, rather than field names in the structure. Look for the description Address notes, which corresponds to the BUPA_DATA_ALL-REMARK field. Select the check box next to this attribute.
- Next, right-click on the attribute and choose Properties. Replace the description with Country Group so that it accurately describes the filter.
- Right-click on the attribute and choose Create Filter
- A dialog box appears in which you can enter a filter description and the criterion for the filter. I want to select all the records that have ASEAN anywhere in the REMARKS field, so I specify CP Contains Pattern of *ASEAN*. Figure 9 shows the parameters for this filter.
- Save the attribute list
- Repeat steps 13-15 to create additional filters for Asia, EU, and Europe

Figure 9
Create the filter for the attribute list
Now that you have defined the filter, it is available in Segment Builder, as shown in Figure 10. When you drag the filter into the Segment Builder work area, it selects only the business partners whose country matches the country group specified in the filter.

Figure 10
The new filter as it appears in Segment Builder
Filters in Segment Builder are fully customizable. You can easily create filters based on marketing attributes or you can create more complex filters that use InfoSets. You can base InfoSets on data retrieval programs that contain virtually any programming logic. Using this flexibility in creating Segment Builder filters helps you maximize the value of your SAP CRM Marketing system.
William R. Pritchett
William (Bill) Pritchett has more than 25 years of IT industry experience and has worked at Dow Corning Corporation for the past 16 years. Over the past eight years he has focused on the company’s CRM systems and processes. His current responsibilities include expanding the capabilities of Dow Corning’s SAP CRM 7.0 system.
You may contact the author at bill.pritchett@dowcorning.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.