CRM
Identifying older sales opportunities as closed in your CRM system and automatically removing them from searches keeps salespeople focused on current opportunities and can lead to increased productivity and sales.
Key Concept
Every SAP CRM opportunity has a Sales Stage field that indicates the phase of the sales cycle for that record. For example, the customer may be learning about your company’s products and be in the early stages of gathering information, or the customer may be in the decision-making phase and preparing to select a vendor. The value in the Sales Stage field is used to indicate the current phase in the buying cycle. This field can also be used to indicate automatic closure of opportunities that have not been updated within a specified period of time.
Sales professionals are remarkably good … at doing exactly what they are compensated for. If your sales compensation plan offers maximal incentives for hitting 300 percent of quota, good salespeople are going to hit 300 percent of their quota every quarter – or at least until they get that new sports car and Lake Tahoe vacation home paid off. Never mind that sales reps might be giving away product through ridiculous discounting or poaching accounts from another rep’s territory.
It is precisely for this reason that many companies have implemented sales force automation (SFA) and pipeline performance management software tools. These tools provide sales reps with visibility into their opportunities and sales pipeline, but the system – like any system – is only as good as the data it relies on. Unfortunately, while sales reps excel at the critical skills needed to close deals – such as deliberately missing an easy three-foot putt on the golf course to let the client win, or selecting the perfect full-bodied oaky Chardonnay to pair with the Béarnaise sauce on a petite filet – they often struggle at more mundane tasks such as updating older opportunities in the CRM system that have fallen by the wayside.
Unlike fine wines, sales opportunities usually don’t improve with age. Granted, there are certain industries – particularly with multi-million dollar products – in which sales cycles can legitimately extend for several years. However, even in these industries, a sales rep should regularly update the opportunity with ongoing progress. If, on the other hand, an opportunity sits in the system for a year or more without being touched, it’s likely that the opportunity has been lost and needs to be updated to reflect the current status.
In this article, we review ways of keeping records clean so that your users can focus on winning opportunities that contribute to your company’s bottom line.
Configuring the Sales Cycle and Sales Stage
Opportunities that have not been updated within a specified time frame should be marked with a special Sales Stage for identification purposes. Configure a new Sales Stage and assign it to the Sales Cycle you are using for opportunity management. Execute transaction code SPRO and follow menu path Customer Relationship Management > Transactions > Settings for Opportunities > Define Sales Cycle and Sales Stages > Define Sales Stages (Figure 1). Define a new Sales Stage with an identifier of 5 and Closed as its description. This is the Sales Stage that will be assigned to obsolete opportunities, so it must be defined in the system.

Figure 1
Define the new Sales Stage for opportunities that will be automatically closed
Further, you should assign this new Sales Stage to the Sales Cycle for opportunities so that it can be assigned to records. To do this, follow SPRO menu path Customer Relationship Management > Transactions > Settings for Opportunities > Define Sales Cycle and Sales Stages > Assign Sales Stages to Sales Cycles (Figure 2). Here you associate the newly defined Sales Stage 5 with the existing Sales Cycle 1 for general opportunity use.

Figure 2
Assign the Sales Stage to the existing sales cycle
With this configuration in place, any opportunity can be set to a closed status. Now we explain how this can be automated for records that have been inactive for an extended period of time.
Identifying Outdated Records
The process of identifying records that have not been updated within a specified time frame is fairly straightforward and can be accomplished with a simple ABAP program.
To make the process as flexible as possible, use the ZVALUE table (which is a generic list of values), to store the number of days that an opportunity can remain inactive before the process closes it automatically. By entering this value on the table, you can initially set the inactive period to 365 days. If you want to adjust this time frame to be shorter or longer in the future, you can do so without having to modify ABAP code.
Start by creating the ZVALUE table if you have not used this concept previously. Use transaction code SE16 to add a record that has a Type of CLEANUP, a Code of OPPORTUNITY, and a Value of 365 (Figure 3).

Figure 3
Use the ZVALUE table to control the number of days that an opportunity can be inactive
The steps for that program are as follows:
- Perform a SELECT SINGLE statement to read the ZVALUE entry that was created in the previous step. The value of 365 is stored in a variable that is referenced when the last update date for each opportunity is checked.
- Use a SELECT statement to read all the entries on table CRMD_OPPORT_H that are currently open (CURR_PHASE is 1, 2, 3, or 4).
- For each open opportunity, use the GUID from table CRMD_OPPORT_H to reference table CRMD_ORDERADM_H, the business transaction header. The CHANGED_AT field on that table contains the time stamp when the opportunity was last updated. (Note: For efficiency, the CRMD_OPPORT_H and CRMD_ORDERADM_H tables can be accessed via a JOIN statement that references the GUID on both tables.)
- Calculate the number of days since the last change by subtracting the CHANGED_AT time stamp from the current date (SY-DATUM).
- Compare the resulting value to the number stored on the ZVALUE table to see if the date of the last update exceeds the specified time frame. Using the values shown here, you know the record should be closed if the last update occurred more than 365 days ago.
- Call standard function module BAPI_OPPORTUNITY_CHANGEMULTI to update the Sales Stage of all records that exceed the specified time frame. Since you want to update only a single field on the record, a minimal number of fields can be sent to the BAPI:
header-guid = GUID of the opportunity being updated
opportunity-ref_guid = GUID of the opportunity being updated
opportunity-curr_phase = “5” (Code of the new Sales Stage in this example)
input_fields-ref_kind = “A” (Administration Header)
input_fields-objectname = “OPPORT_H” (Opportunity Header)
input_fields-ref_guid = GUID of the opportunity being updated
input_fields-fieldname = “CURR_PHASE” (Field to update)
input_fields-changeable = “X”
- Check the RETURN table to see if errors or warnings occurred during the update process. If records are found on the RETURN table, output the message number and message text for troubleshooting purposes.
- If no errors occurred, call BAPI_TRANSACTION_COMMIT to write the changes to the database.
Once your custom production has been tested and moved to the production system, you should schedule it to run on a weekly or monthly basis so that outdated records are continually moved to a closed status.
Excluding Closed Records by Default
Configuring your system to exclude closed opportunities from users’ searches by default eliminates clutter from users’ search results, making it easier for them to locate active opportunities.
To set default search parameters, create an implementation of class CL_BT111S_O_SEARCH_IMPL and redefine method DO_INIT_CONTEXT. Implementing this routine requires the skills of an ABAP developer, but making this enhancement is a fairly straightforward task, since a small amount of code is required. Figure 4 shows the code required to exclude closed opportunities from the search results. This routine checks the search values on the opportunity screen and removes the CURR_PHASE parameter. It then inserts that parameter with the default values specified. Comments have been included in the routine for clarification.

Figure 4
Sample code for setting default search parameters
Once the code is in place and has been activated, you can test it by navigating to the opportunity search screen from the home page of the WebClient user interface (UI). Previously, when that screen was accessed, none of the parameters was pre-filled with a default value. With the custom code in place, you should see Sales Cycle, is not, and Closed specified in the search (Figure 5).

Figure 5
With the custom class and method active, closed opportunities are automatically excluded from the search screen
By eliminating closed records by default, you can keep salespeople focused on viable opportunities that, if won, help them grow your company’s business.
Making Closed Records Easy to Find
You can provide users with a way to locate closed opportunities using the saved search functionality that is available in the WebClient UI. From the SAP CRM home page, go into the opportunity search screen and specify the closed sales cycle. You also might want to add the Belonging To parameter so that users see only the records assigned to their ID. You then specify a name for the query (in this example, the query is named My Closed Opportunities). Click the Save button to create the saved search (Figure 6).

Figure 6
Create a saved search to find opportunities that have been closed
You can also expand the functionality of your saved search so that users can see which opportunities have been closed within a given time period. For example, you may want to create a saved search that shows all records closed within the last month and another that shows opportunities closed within the current quarter. To learn how to create saved searches that use date parameters, see “Make Query Parameters Dynamic.”
John Burton
John Burton is a director of product management at SAP and is responsible for the SAP CRM Interaction Center (including ERMS) and social CRM topic areas. John has 13 years of experience at SAP and has been involved with SAP CRM and the Interaction Center since 1999. He is also the author of Maximizing Your SAP CRM Interaction Center, available at the SAPinsider Store. John is an alumnus of the University of Michigan and Central Michigan University. John can be found on LinkedIn at www.linkedin.com/in/sapjohnburton.
You may contact the author at john.burton@sap.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.

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.