SAP Knowledge Base Article - Public

2742164 - Import Function CheckForDuplicates Does Not Work as Expected

Symptom

You created a custom odata service using the standard Business Object (BO) Customer and with that you also created an import function with the action CheckForDuplicates. However, as a result of calling the function in the odata query https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/cust/v1/service_XYZ/CustomerCheckForDuplicates1?ObjectID=’YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY’, you received only the message below:

<code>ERROR</code>
<message xml:lang="en">
17 potential duplicates found for business partner ZZZZZZ (ABC) ABC
</message>

(XXXXXX represents the tenant number / service_XYZ represents the name of the custom odata service / YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY represents the Object ID / ZZZZZZ represents the Business Partner ID, ABC represents the name of the Business Partner)

Environment

  •  SAP Hybris Cloud for Customer.

Reproducing the Issue

  1. Go to the Administrator work center, in the OData Services Explorer view.
  2. Select the filter to show Custom OData Services.
  3. Click on New, to create a new service.
  4. Set a name for your service and open it.
  5. Select the Customer BO.
  6. Click on the Import Functions tab.
  7. Add a new line and select the Function Import Type as ACTION.
  8. Select the Entity Name (e.g. Customer).
  9. Select the HTTP Method GET.
  10. Select the BO Action/Query CheckForDuplicates.
  11. Save and activate.
  12. Call the function and see the result message.

Cause

The OData framework currently supports two function import types:

  • ACTION: This one performs an operation on one or more instances. It does not have any exporting/returning parameters.
  • QUERY: This one returns data by using an existing query at a business object.

So this approach fails for two reasons:

  • You are using a function import of type ACTION. That one, by design, cannot return data.
  • The action CheckForDuplicates at the Customer BO is designed for a very specific UI scenario and is not consumable by an OData service the same way it is in UI.

Resolution

Trying to implement a function import of type QUERY likely will not yield the required results, either.
 
The biggest obstacle being that a query has to be called in a very specific 'configuration' for it to work like a duplicate check and not just a regular exact match query. In particular the caller has to provide field weights and etc. Currently the OData framework does not support such requirements. The existing OData function imports CheckForDuplicates (Contacts) and CheckForDuplicateIndividualCustomers (Individual Customers), therefore, rely on extensive exit coding to work properly.

Keywords

function imports, custom odata service, checkforduplicates, customer check for duplicates , KBA , LOD-LE-BP-BP , Business Partner , How To

Product

SAP Cloud for Customer add-ins all versions ; SAP Cloud for Customer core applications all versions