1. Use Case
At one of my customers we have the following setup:
- B2C customers are created in SAP CRM and NOT transferred into SAP ECC.
- B2B customers are downloaded into SAP CRM, and are also created in SAP CRM. In SAP CRM they are transferred into SAP ECC when certain conditions are met, e.g. maintaining the business partner role Sold-to-Party and some other details.
In this tutorial I will explain more about how you can technically delete business partners (organizations) there were downloaded from SAP ECC into SAP CRM by mistake.
The reason in this case was incorrect filter settings were made in the Business Object CUSTOMER_MAIN (at the time when we performed our first initial download from SAP ECC) which you can view using the transaction code R3AC1.
In the below example customers are being downloaded from SAP ECC based on criteria such as customer number ranges, sales organization and type of business partner (natural person versus legal person).
For your information -these settings are only NOW active. During the first initial download the criteria “sales organization” was NOT set as a filter condition. As such, a lot of customers were downloaded that were not maintained for the defined sales organizations by mistake. In order to correct this, we had the requirement to delete these business partners in SAP CRM.
First you need to create a complete list of affected customers. You can obviously do this based on the (incorrect) filter settings you made in the first place.
Check in table KNVV those customers that fall under the number range settings you initially made in CUSTOMER_MAIN. Next, filter out those that ARE not maintained for the 2 sales organizations that were set as a filter afterwards. This should provide you a list of customers that were probably downloaded by mistake.
Compare this output with the SAP CRM business partners in your system. They normally have the same number ranges (although this depends on your setup of course – internal versus external numbering).
3. Attention points
The purpose is to delete those customers that were downloaded by mistake. However, you cannot just start to delete the list of customers you created in step 2.
- Some customers might already have a “relationship” with another business partner in SAP CRM (e.g. has the contact person xxx). Therefore you also want to exclude the customers from your list that already have a relationship in table BUT050 in SAP CRM.
Make sure to use your Business Partner numbers in both fields (business partner) just to be on the safe side!
- You also would like to avoid deleting customers in SAP CRM that are already used in business transactions. Therefore it would be smart to also perform a check in table CRMD_ORDER_INDEX using the field “Partner Number”
4. Deregister the Outbound Queue in SAP CRM
Why is this necessary? If you would simply delete all business partners on your list, this would trigger the creation of an outbound Bdoc, by which these customers would also get deleted in the SAP ECC system. A fast reason to get FIRED at your customer
Therefore we actually performed this complete action after normal working hours, a timeframe in which we were certain that business would not be impacted.
Launch transaction code SMQ1 to call the “outbound queue” overview.
In the menu, choose “GOTO >> QOUT Scheduler”.
In yellow color I marked the Logical destination pointing to our SAP ECC system.
This is the one you will want to “deregister”.
Select this entry (flag it) and next push the button “Deregistration”.
You will see a pop-up showing the “destination” you selected.
Press the “ok” button.
You will now see that the status of this outbound queue is “U”. (Unregistered)
5. Quick Test to see if the deregistration works fine
If you want to be convinced the deregistration actually is working fine, you can test this by adding a simple character into an existing SAP CRM business partner (e.g. in the field first or last name) that you would like to delete. If you save this change in SAP CRM, an outbound Bdoc should be created, and if you now check the outbound queue via SMQ1, you will see it’s NOT getting processed.
6. Deleting the SAP CRM Business Partners
In order to delete the customers in SAP CRM you can use:
- the transaction code BUPA_DEL
- Report BUPA_TEST_DELETE (program behind transaction code BUPA_DEL)
In the above screenshot I “unflagged” the fields (when performing my real deletion run):
- Only system status “deleted”
- Test run, check only
I advise you once again, to start with a small test run of let’s say 10 customers. If this test went ok, proceed with the complete list.
The test run you can perform in foreground as this will not impact performance. The complete run I would rather schedule in background!
When executing the deletion, click “YES” on the above pop-up.
When executing this action as a background job, you can monitor this job using transaction code SM37.
Once the job is finished, you can try to look at the Spool request to see if there were any problems.
In the above screenshot you can see apparently at least 1 customer escaped the checks I mentioned during chapter 3 –Attention Points.
7. Verifying the created outbound Queues in SMQ1
Once the job is finished you have to check the outbound queues in SAP CRM that have been created due to the “deletion process”.
In SMQ1 you can somehow easily check the list of outbound queues that have been created using the following input parameters:
Personally it think it would have been great if SAP would have provided a multiple selection option for the Queue Name, as this would make the selection process easier…but anyway.
Once I get the list of relevant “outbound” queues, I select ALL entries (you might want to do some additional checks here – to be on the safe side) and press the DELETE button.
8. REGISTER OUTBOUND QUEUE AGAIN
We are now finished with the deletion process. We also assured that no deletion took place in SAP ECC of the impacted business partners, by having unregistered and next deleted all triggered outbound queues.
As a final step we now must ‘register’ this queue once again.
You do this by selecting the relevant Queue and next pressing the button “Registration”.
The SAP University Team