how to… identify identical master data records using sap

23
How-to Guide SAP NetWeaver 2004s How To… identify identical master data records using SAP MDM 5.5 ABAP API’s Version 1.00 – November 2006 Applicable Releases: SAP NetWeaver 2004s SAP MDM 5.5

Upload: others

Post on 21-Feb-2022

14 views

Category:

Documents


0 download

TRANSCRIPT

How-to GuideSAP NetWeaver 2004s

How To…identifyidenticalmaster datarecords usingSAP MDM 5.5ABAP API’sVersion 1.00 – November 2006

Applicable Releases:SAP NetWeaver 2004sSAP MDM 5.5

© Copyright 2006 SAP AG. All rights reserved.

No part of this publication may be reproduced ortransmitted in any form or for any purpose without theexpress permission of SAP AG. The informationcontained herein may be changed without prior notice.

Some software products marketed by SAP AG and itsdistributors contain proprietary software components ofother software vendors.

Microsoft, Windows, Outlook, and PowerPoint areregistered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, ParallelSysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400,iSeries, pSeries, xSeries, zSeries, z/OS, AFP, IntelligentMiner, WebSphere, Netfinity, Tivoli, and Informix aretrademarks or registered trademarks of IBM Corporationin the United States and/or other countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registeredtrademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame,WinFrame, VideoFrame, and MultiWin are trademarksor registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks orregistered trademarks of W3C®, World Wide WebConsortium, Massachusetts Institute of Technology.

Java is a registered trademark of Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems,Inc., used under license for technology invented andimplemented by Netscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, and otherSAP products and services mentioned herein as well astheir respective logos are trademarks or registeredtrademarks of SAP AG in Germany and in several othercountries all over the world. All other product andservice names mentioned are the trademarks of theirrespective companies. Data

contained in this document serves informationalpurposes only. National product specifications may vary.

These materials are subject to change without notice.These materials are provided by SAP AG and its affiliatedcompanies ("SAP Group") for informational purposesonly, without representation or warranty of anykind, and SAP Group shall not be liable for errors oromissions with respect to the materials. The onlywarranties for SAP Group products and services are thosethat are set forth in the express warranty statementsaccompanying such products and services, if any.Nothing herein should be construed as constituting anadditional warranty.

These materials are provided “as is” without a warrantyof any kind, either express or implied, including but notlimited to, the implied warranties of merchantability,fitness for a particular purpose, or non-infringement.SAP shall not be liable for damages of any kind includingwithout limitation direct, special, indirect, orconsequential damages that may result from the use ofthese materials.SAP does not warrant the accuracy or completeness ofthe information, text, graphics, links or other itemscontained within these materials. SAP has no controlover the information that you may access through theuse of hot links contained in these materials and does notendorse your use of third party web pages nor provideany warranty whatsoever relating to third party webpages.SAP NetWeaver “How-to” Guides are intended tosimplify the product implementation. While specificproduct features and procedures typically are explainedin a practical business context, it is not implied that thosefeatures and procedures are the only approach in solvinga specific business problem using SAP NetWeaver. Shouldyou wish to receive additional information, clarificationor support, please refer to SAP Consulting.Any software coding and/or code lines / strings (“Code”)included in this documentation are only examples andare not intended to be used in a productive systemenvironment. The Code is only intended better explainand visualize the syntax and phrasing rules of certaincoding. SAP does not warrant the correctness andcompleteness of the Code given herein, and SAP shallnot be liable for errors or damages caused by the usage ofthe Code, except if such damages were caused by SAPintentionally or grossly negligent.

- 1 -

Table of ContentsTable of Contents........................................................................................................1

1 Change History.................................................................................................2

2 Introduction ......................................................................................................3

3 Using MDM ABAP API’s ...................................................................................4

3.1 Customizing for the MDM ABAP API ..................................................................6

3.1.1 Trusted relationship............................................................................................7

3.1.2 Display view MDM DBMS Host ..........................................................................9

3.1.3 MDM server connection......................................................................................9

3.1.4 ABAP Implementation for MDM Version Support................................................9

3.1.5 MDM Repositories............................................................................................10

3.1.6 Trusted user .....................................................................................................10

3.2 Identifying Duplicates (project implementation).................................................11

3.2.1 Extract of the coding.........................................................................................11

3.2.2 Result List ........................................................................................................14

4 Appendix.........................................................................................................18

4.1 MDM ABAP API ...............................................................................................18

- 2 -

1 Change History

Date Version Chapter Content01.11.2006 V1.0 Creation

- 3 -

2 IntroductionThe business case data consolidation describes the process of master dataconsolidation from different client systems. Duplicate objects cause problems and costs.

For example: Multiple maintenance: Higher effort and inconsistent information Customer mailing: Information is mailed more than once Supplier invoice verification: invoice delivery both by B2B and mail

The objective is to identify identical master data records in each of the systems in your ITlandscape, to match and merge these records and to prevent the creation of duplicatemaster data records.

Two tactics to get rid of duplicates are considered:

Prevent creation of new duplicates Cleanse duplicates which already exists in the system

Consolidated master data records will help companies to improve data quality leverage IT investments as it complements and integrates with their existing IT

landscape support major decision-making processes since decisions can be based on

consolidated data provide a solid basis for company-wide analytics and reporting

This guideline should be used as a template only. Matching and merging strategies arehighly dependent on the concrete data they are designed for. At the moment no ABAPAPI is available to use the new SP4 Matching functionality. Therefore the followingchapters will describe a possibility of de-duplication by using the search functionality ofSAP NetWeaver MDM 5.5 ABAP API’s based on the master data object “Vendor”.For further information concerning SAP NetWeaver MDM 5.5 Java API’s please see:

SAP NetWeaver MDM 5.5 SP04: MDM ABAP API HowTo_01: Setting up the Customizing HowTo_02: Create, Connect & Load Repository HowTo_03: Retrieve Repositories HowTo_04: User Management HowTo_05: Client Systems HowTo_06: Metadata HowTo_07: Tracing HowTo_08: Create, Retrieve, Update, Delete Record Data (Simple Types) HowTo_09: Retrieve Simple Types HowTo_10: Retrieve Complex Types HowTo_11: Create/Retrieve (Flat Lookup & Hierarchy Lookup) HowTo_12: Create/Retrieve (Taxonomy Lookup) HowTo_13: Create/Retrieve (Qualified Flat Lookup) HowTo_14: Client System Keys HowTo... Identify identical master data records using SAP MDM 5.5 SP4_V1.doc HowTo... identify identical master data records using SAP MDM 5.5 Java

APIs_V1.doc

- 4 -

3 Using MDM ABAP API’s

Landscape:SAP MDM 5.5 SP4The MDM ABAP API runs on any ABAP system. It is delivered with thecomponent MDMTECHNOLOGY (5.5.4 640, 5.5.4 700). The mandatory kernelpatches for MDM ABAP API are:

> SAP NW2004 (640) dw patch 139> SAP NW2004s (700) dw patch 68

The MDM ABAP API empowers ABAP-based applications to control MDM servers usingmost of the functionalities available in the MDM Console and MDM Data Managerapplications.

The architecture of MDM ABAP API consists of the following components:On the WebAS ABAP:

The Generic API is the release-independent programming interface to accessdata on the MDM Server using ABAP programming.

The Provider Framework provides an interface for the different releases of MDM. The C-Kernel enables communication with the MDM Server. The MDM Server contains repositories that store the master data to be accessed

by the ABAP system.

- 5 -

The following graphic shows how the components interact:

The MDM ABAP API runs on any ABAP system. It is delivered with the component MDMTECHNOLOGY (5.5.4 640, 5.5.4 700). The mandatory kernel patches for MDM ABAPAPI are:

NW2004 (640) dw patch 139 NW2004s (700) dw patch 68

Preconditions:

Installation guide:

- 6 -

Master Guide:

The following example will show the procedures necessary to set up the connectioncustomizing for the MDM ABAP API and to run a simple report to identify possibleduplicates using the search capabilities of SAP MDM 5.5.

Another scenario would be to trigger a search while creating a new customer or vendorto prevent creating duplicates.

3.1 Customizing for the MDM ABAP API

The MDM ABAP API customizing consists of a transaction called MDMAPIC.The transaction consists of following elements:

MDM DBMS Hosts Storage of data regarding the database server connection

MDM Server Connections Storage of data regarding the MDM server connection

- 7 -

ABAP Implementation for MDM Version Support Storage of data regarding the used provider implementation

MDM Repositories It contains the name of the target repository, a logical connection name and cross

references to the elements described above

MDM API trace configurationStores the detail level of the application log

3.1.1 Trusted relationship

To be able to connect a R/3 system to MDM it is necessary to configure a trustedrelationship to MDM server. In other words the server needs to know which clients (forinstance the WebAS) can be trusted. allow.ip and deny.ip

Therefore it is necessary to create a flat, text only file "allow.ip" which contains the IPaddresses of the trusted connection partners apart from MDM Server. Each line in thefile is a connection entry The IP address may be specified as a fully qualified address, forinstance: 10.17.79.94 and 10.17.79.95. It is also possible to use a wildcard to signify theentire subnet whereas everything is allowed apart from the single wildcard sign '*'.

In order to allow an entire subnet but specify some exceptions it isnecessary to define the entries in "allow.ip" as described above andcreate an additional file "deny.ip" according to the same rules as for theallowed IP file.

The example shows the server folder of MDM server pwdf2713 and theopened file allow.ip with maintained R/3 servers.

- 8 -

By default, allow.ip and deny.ip files are placed in the same folder as mds.ini. In otherwords they are stored in the folder in which the executable is located.You can specify an alternate location for these files by specifying a line such as thefollowing line in the mds.ini file:TrustFiles Dir=C:\{path}\something indicating that both the allow.ip anddeny.ip files are in the "C:\{path}\something" folder.After that initial configuration. the trusted partners are configured, enabling trustedcooperation between the WebAS servers and the MDM Server.

- 9 -

3.1.2 Display view MDM DBMS HostEnter a logical DBMS connection name, the DB type, and the DBMS host name.

3.1.3 MDM server connectionEnter a logical (MDM server) connection name, the MDM host name, and the port.The standard port of the MDM server is 20005.

3.1.4 ABAP Implementation for MDM Version SupportEnter a logical provider name and select the provider type.

- 10 -

3.1.5 MDM RepositoriesEnter a logical object name (ZDT_API_Match1) and the repository name. The repository(ZZ_SP4_Matching) already exits on the MDM.Select a MDM connection, a DBMS connection, and a provider. All the other fields areautomatically filled (with references to the tables already filled).

It is now possible to refer to the logical connection ZDT_API_Match1 from within anapplication based on the MDM ABAP API.

3.1.6 Trusted userCreate an entry for each SAP system user name in the user table in the MDM repository.On the basis of the trusted connection between the system and the MDM Server, the APIonly sends the system user name of the user who islogged on. When you create userswith the same name on MDM, it is possible to assign self-defined roles and functions tothem. If the user is not known inMDM, access is denied.It is not necessary to enter a password. With this mechanism it is possible to work onMDM as a trusted user.

- 11 -

3.2 Identifying Duplicates (project implementation)

The attached program will search in SAP MDM with a fixed value that can be defined bythe user. Possible duplicates will be shown in a list.

This logic could be used when creating vendors or customers by showing possibleduplicates.

For finding duplicates the free form search functionality of SAP MDM will be used. AMDM API to use the matching functionality is not available right now. Therefore thelogic for triggering the free form search could be extended by creating tokens andtriggering the search with the tokens.

The example will be based on the following repository:

3.2.1 Extract of the coding

A DDIC structure corresponding to the fields to be shown has to be created. The DDICfield names must be the same as the field codes in the MDM repository.

- 12 -

*&---------------------------------------------------------------------**& Report ZDT_MATCH01*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

REPORT ZDT_MATCH01.

DATA:* System connectionlr_api TYPE REF TO cl_mdm_generic_api,ls_language TYPE mdm_cdt_language_code,cx_exception TYPE REF TO cx_mdm_main_exception,

* Searchinglt_query TYPE mdm_query_table,ls_query TYPE mdm_query,ls_cdt_text TYPE mdm_cdt_text,lt_result_set TYPE mdm_search_result_table,ls_result_set type MDM_SEARCH_RESULT,ls_string Type string,

* Readinglt_record_data TYPE STANDARD TABLE OF ZDT_RECORD WITH NON-UNIQUEDEFAULT KEY,ls_record_data LIKE LINE OF lt_record_data,lv_log_object_name TYPE mdm_log_object_name,lt_keys TYPE mdm_keys,lv_key LIKE LINE OF lt_keys.

lt_record_data: Table of type DDIC. Used to send record data to and retrieverecord data from MDM Server.

ls_record_data: Structure used to fill table lt_record_data.lv_log_object_name:String variable for the name of the logical connection data

(customizing entry).lt_keys: Keys table for retrieve method. Contains the keys of the

records to be read.

SELECTION-SCREEN BEGIN OF BLOCK data WITH FRAME.PARAMETER: Name TYPE AD_NAME1.SELECTION-SCREEN END OF BLOCK data.

TRY.* Constructur: set configuration ID (API_SAMPLE)CREATE OBJECT lr_apiEXPORTINGiv_log_object_name = 'ZDT_API_MATCH1'.

……*--- Search on MDM Repository ---*

ls_query-parameter_code = 'Name'. "Field codels_query-operator = 'CS'. "Containsls_query-dimension_type = 1. "Field searchls_query-constraint_type = 8. "Text searchls_string = Name.GET REFERENCE OF ls_string INTO ls_query-value_low.APPEND ls_query TO lt_query. CLEAR ls_query.…

- 13 -

…*--- Query ---*

CALL METHOD lr_api->mo_core_service->queryEXPORTING*Main Tableiv_object_type_code = 'Vendor'it_query = lt_queryIMPORTINGet_result_set = lt_result_set.

lt_result_set[1]-RECORD_IDS shows the internal MDM keys:

- 14 -

* --- RETRIEVE records ---

CLEAR lt_record_data[]. CLEAR lt_keys[].

* --- Transfer key --- Loop at lt_result_set into ls_result_set. lt_keys = ls_result_set-RECORD_IDS. Exit. Endloop.

CALL METHOD lr_api->mo_core_service->retrieve_simple EXPORTING iv_object_type_code = 'Vendor' it_keys = lt_keys IMPORTING et_ddic_structure = lt_record_data.

3.2.2 Result List

A free form search in MDM with the search criteria “Black” would lead to the followingresult:

- 15 -

The MDM ABAP API will show the same result:

- 16 -

As the logic is based on the free form search, the search with “blak” (written without “c”)will show no result:

- 17 -

- 18 -

4 AppendixPlease note that the coding should only be used as a template. Whenimplementing a How to Paper SAP is not liable for errors or omissions withrespect to the materials. You can find this in more details in the disclaimer sectionof the How to Paper.

4.1 MDM ABAP API

*&---------------------------------------------------------------------**& Report ZDT_MATCH01*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

REPORT ZDT_MATCH01.

DATA:* System connectionlr_api TYPE REF TO cl_mdm_generic_api,ls_language TYPE mdm_cdt_language_code,cx_exception TYPE REF TO cx_mdm_main_exception,

* Searchinglt_query TYPE mdm_query_table,ls_query TYPE mdm_query,ls_cdt_text TYPE mdm_cdt_text,lt_result_set TYPE mdm_search_result_table,ls_result_set type MDM_SEARCH_RESULT,ls_string Type string,

* Readinglt_record_data TYPE STANDARD TABLE OF ZDT_RECORD WITH NON-UNIQUEDEFAULT KEY,ls_record_data LIKE LINE OF lt_record_data,lv_log_object_name TYPE mdm_log_object_name,lt_keys TYPE mdm_keys,lv_key LIKE LINE OF lt_keys.

SELECTION-SCREEN BEGIN OF BLOCK data WITH FRAME.PARAMETER: Name TYPE AD_NAME1.SELECTION-SCREEN END OF BLOCK data.

TRY.* Constructur: set configuration ID (API_SAMPLE)CREATE OBJECT lr_apiEXPORTINGiv_log_object_name = 'ZDT_API_MATCH1'.

* set language, country & regionls_language-language = 'eng'.ls_language-country = 'US'.ls_language-region = 'USA'.

* connect to repository + defining cdt_language_codeCALL METHOD lr_api->mo_accessor->connectEXPORTINGis_repository_language = ls_language.

- 19 -

************************************************************************************ Search************************************************************************************--- Search on MDM Repository ---** Search for all record entries* Build search criteria: for Text search

ls_query-parameter_code = 'Name'. "Field codels_query-operator = 'CS'. "Containsls_query-dimension_type = 1. "Field searchls_query-constraint_type = 8. "Text searchls_string = Name.GET REFERENCE OF ls_string INTO ls_query-value_low.APPEND ls_query TO lt_query. CLEAR ls_query.

*--- Query ---** look on 'Vendor' table and submit prepared query parameter.* Hint: Without optional parameter query all entries of the table are returned.

CALL METHOD lr_api->mo_core_service->queryEXPORTING*Main Tableiv_object_type_code = 'Vendor'it_query = lt_queryIMPORTINGet_result_set = lt_result_set.

************************************************************************************ RETRIEVE records*********************************************************************************** CLEAR lt_record_data[]. CLEAR lt_keys[].

* Transfer keys Loop at lt_result_set into ls_result_set. lt_keys = ls_result_set-RECORD_IDS. Exit. Endloop.

* RETRIEVE

CALL METHOD lr_api->mo_core_service->retrieve_simple EXPORTING iv_object_type_code = 'Vendor' it_keys = lt_keys IMPORTING et_ddic_structure = lt_record_data.

************************************************************************************ Field contents of result*********************************************************************************** NEW-LINE. WRITE: 'Search paramter:', ls_string. NEW-LINE. WRITE 'Possible duplicates (Please check):'. NEW-LINE. ULINE. WRITE '|'. WRITE: AT (15) 'Vendor Number', '|'. WRITE: AT (25) 'Name', '|'.

- 20 -

WRITE: AT (25) 'Street', '|'. WRITE: AT (25) 'City'. ULINE. LOOP AT lt_record_data INTO ls_record_data. NEW-LINE. WRITE '|'. WRITE: AT (15) ls_record_data-VENDOR_NUMBER, '|'. WRITE: AT (25) ls_record_data-name, '|'. WRITE: AT (25) ls_record_data-street, '|'. WRITE: AT (25) ls_record_data-city. ENDLOOP. IF ls_record_data IS INITIAL. WRITE ' Warning: Result set contains only initial data!'. Endif. ULINE.

**********************************************************************************************************************************************************************

* disconnect after work is doneCALL METHOD lr_api->mo_accessor->disconnect.CATCH cx_mdm_usage_error INTO cx_exception.

************************************************************************************ Exception handling************************************************************************************ handle exceptionCATCH cx_mdm_provider INTO cx_exception.* handle exceptionCATCH cx_mdm_kernel INTO cx_exception.* handle exceptionCATCH cx_mdm_server_rc_code INTO cx_exception.* handle exceptionCATCH cx_mdm_not_supported INTO cx_exception.* handle exceptionCLEANUP.* Disconnect after finishing work. This prevents server resource exhaustingTRY.********************************************************************************lr_api->mo_accessor->disconnect( ).********************************************************************************* Ignore all exceptions here:CATCH cx_root. "#EC NO_HANDLERENDTRY.ENDTRY.IF NOT cx_exception is initial.NEW-LINE.WRITE 'Error occured. Program terminated'.NEW-LINE.DATA lv_text TYPE string.lv_text = cx_exception->if_message~get_text( ).WRITE lv_text.ENDIF.

www.sdn.sap.com/irj/sdn/howtoguides