Skip to Content

Taking forward, the build  for my Customised Data Manger for SAP Portal Integration using MDM Java APIs, please find this blog as the new addition the series:

Using MDM Java APIs to retrieve Taxonomy attribute Values                                 
Using MDM Java APIs to add Text(type) taxonomy attribute allowable values

Before I demonstrate using MDM Java APIs to retrieve matching strategies, let us understand what are matching strategies and how do we create or add them in MDM.

A matching strategy is comprised of one or more matching rules and a pair of numeric thresholds.Each strategy can be executed against a set of one or more records against the set, the search results, or all of the records in the repository.

Matching strategies identify potential matches for each record based on the matching scores of the individual rules that comprise the strategy and the thresholds that determine which records are potential matches for each record.

1. As a first step we will create a matching strategy from with in Matching Mode of Data Manager, to add a new strategy to the list of strategies:

  • If necessary, click on the Strategies tab to make it the active tab.
  • Right-click in the Strategies pane and choose Add Strategy from the context menu, or choose Records > Matching > Strategies > Add Item from the main menu.
  • MDM adds a new matching strategy named “New Strategy” to the list of strategies, and highlights it for editing.
  • Include the columns against which target records are to matched, say Material_Number in current scenario.
  • Type the name ‘Material Strategy’ for the matching strategy and press Enter.

2. Now since we have created the matching strategy by the name ‘Material Strategy’ let us look at the MDM Java API code snippets, which will be required to execute the matching strategy. Using the Java API, at first we reteieve matching strategies available in MDM repository:

RetrieveMatchingStrategiesCommand retMatStr =  new RetrieveMatchingStrategiesCommand(connection);


try {

retMatStr.execute(); }

catch (CommandException e) {

e.printStackTrace(); }

// we have only one matching strategy, retriving the matching strategy id

matchStID = retMatStr.getMatchingStrategies()[1].getId();


connection & authUserSession vaiables hold MDM Connection and authenticated user session respectively

After fetching the matching strategy id, we are left with two following steps:

3. For any new records being created,using the matching strategy id we execute the matching strategy to find mathcing records:

ExecuteMatchingStrategyForNewRecordValuesCommand exeMatstr = new ExecuteMatchingStrategyForNewRecordValuesCommand(connection);





exeMatstr.setTarget(new Search(new TableId(1)));





catch (CommandException e)





recs is the array of source records, these are records to find matching for, currently only one record is supported

rids is the array of target recod ids, these are the recods to match to

setTarget(new Search(new TableId(1))) sets the target records in form of a search object, these are the records to match to, i.e. all records in main table

4. After executing the matching strategy we execute the RetrievedMatchedRecordsCommand, to retrieve the records that matched the source record for the matching strategy, which was executed:

RetrieveMatchedRecordsCommand retMR = new RetrieveMatchedRecordsCommand(connection);



retMR.setRecordId(new RecordId(-1));

retMR.setResultDefinition(new ResultDefinition(new TableId(1)));

try {

retMR.execute(); }

catch (CommandException e) {

e.printStackTrace(); }


setMatchingTaskId(exeMatstr.getMatchingTaskId()) sets the matching task Id  fetched using executeMatchingStrategy command object from the last step, this identifier is a handle to the matching stratgey that was executed in the last step.

setRecordId(new RecordId(-1)) sets the source record Id, the matched records will be based on this source record.For external record matching, the record Id is -1.

As discussed in the blog, one can use the steps to execute matching strategies already existing in MDM in a different way. Though one might argue for running parallel searches in MDM using the API to accomplish certain kind of matching between records, instead of executing matching strategies this way. I would say this is a feature provided by the java API, it empowers developer to replicate data manager features over the web, and I personally feel using it this way would save a lot of development time required to explicitly code such a matching strategy using the APIs.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply