using mdm 7.1 key-mappings in a pi landscape

40
SAP NetWeaver How-To Guide Using MDM 7.1 Key-Mappings in a PI Landscape Applicable Releases: SAP NetWeaver MDM 7.1 SAP NetWeaver Process Integration 7.00 SAP NetWeaver Process Integration 7.1x Topic Area: Information Management Capability: Master Data Management Version 1.0 May 2009

Upload: shahrokhhassasian

Post on 16-Oct-2014

113 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Using MDM 7.1 Key-Mappings in a PI Landscape

SAP NetWeaver How-To Guide

Using MDM 7.1 Key-Mappings in a PI Landscape

Applicable Releases:

SAP NetWeaver MDM 7.1

SAP NetWeaver Process Integration 7.00

SAP NetWeaver Process Integration 7.1x

Topic Area:

Information Management

Capability: Master Data Management

Version 1.0

May 2009

Page 2: Using MDM 7.1 Key-Mappings in a PI Landscape

© Copyright 2009 SAP AG. All rights reserved.

No part of this publication may be reproduced or

transmitted in any form or for any purpose without the

express permission of SAP AG. The information contained

herein may be changed without prior notice.

Some software products marketed by SAP AG and its

distributors contain proprietary software components of

other software vendors.

Microsoft, Windows, Outlook, and PowerPoint are

registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, Parallel

Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390,

OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP,

Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix,

i5/OS, POWER, POWER5, OpenPower and PowerPC are

trademarks or registered trademarks of IBM Corporation.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader

are either trademarks or registered trademarks of Adobe

Systems Incorporated in the United States and/or other

countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered

trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame,

WinFrame, VideoFrame, and MultiWin are trademarks or

registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or

registered trademarks of W3C®, World Wide Web

Consortium, 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 and

implemented by Netscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP

NetWeaver, and other SAP products and services

mentioned herein as well as their respective logos are

trademarks or registered trademarks of SAP AG in

Germany and in several other countries all over the world.

All other product and service names mentioned are the

trademarks of their respective companies. Data contained

in this document serves informational purposes only.

National product specifications may vary.

These materials are subject to change without notice.

These materials are provided by SAP AG and its affiliated

companies ("SAP Group") for informational purposes only,

without representation or warranty of any kind, and SAP

Group shall not be liable for errors or omissions with

respect to the materials. The only warranties for SAP

Group products and services are those that are set forth in

the express warranty statements accompanying such

products and services, if any. Nothing herein should be

construed as constituting an additional warranty.

These materials are provided “as is” without a warranty of

any kind, either express or implied, including but not

limited to, the implied warranties of merchantability,

fitness for a particular purpose, or non-infringement.

SAP shall not be liable for damages of any kind including

without limitation direct, special, indirect, or consequential

damages that may result from the use of these materials.

SAP does not warrant the accuracy or completeness of the

information, text, graphics, links or other items contained

within these materials. SAP has no control over the

information that you may access through the use of hot

links contained in these materials and does not endorse

your use of third party web pages nor provide any warranty

whatsoever relating to third party web pages.

SAP NetWeaver “How-to” Guides are intended to simplify

the product implementation. While specific product

features and procedures typically are explained in a

practical business context, it is not implied that those

features and procedures are the only approach in solving a

specific business problem using SAP NetWeaver. Should

you wish to receive additional information, clarification or

support, please refer to SAP Consulting.

Any software coding and/or code lines / strings (“Code”)

included in this documentation are only examples and are

not intended to be used in a productive system

environment. The Code is only intended better explain and

visualize the syntax and phrasing rules of certain coding.

SAP does not warrant the correctness and completeness of

the Code given herein, and SAP shall not be liable for

errors or damages caused by the usage of the Code, except

if such damages were caused by SAP intentionally or

grossly negligent.

Disclaimer

Some components of this product are based on Java™. Any

code change in these components may cause unpredictable

and severe malfunctions and is therefore expressively

prohibited, as is any decompilation of these components.

Any Java™ Source Code delivered with this product is only

to be used by SAP’s Support Services and may not be

modified or altered in any way.

Page 3: Using MDM 7.1 Key-Mappings in a PI Landscape

Document History Document Version Description

1.00 First official release of this guide

Page 4: Using MDM 7.1 Key-Mappings in a PI Landscape

Typographic Conventions Type Style Description

Example Text Words or characters quoted from the screen. These include field names, screen titles, pushbuttons labels, menu names, menu paths, and menu options.

Cross-references to other documentation

Example text Emphasized words or phrases in body text, graphic titles, and table titles

Example text File and directory names and their paths, messages, names of variables and parameters, source text, and names of installation, upgrade and database tools.

Example text User entry texts. These are words or characters that you enter in the system exactly as they appear in the documentation.

<Example text>

Variable user entry. Angle brackets indicate that you replace these words and characters with appropriate entries to make entries in the system.

EXAMPLE TEXT Keys on the keyboard, for example, F2 or ENTER.

Icons Icon Description

Caution

Note or Important

Example

Recommendation or Tip

Page 5: Using MDM 7.1 Key-Mappings in a PI Landscape

Table of Contents

1. Background Information..................................................................................................... 1

2. Business Scenario............................................................................................................... 2 2.1 Introduction................................................................................................................... 2 2.2 Scenario Description .................................................................................................... 2 2.3 Pros & Cons of the Scenario ........................................................................................ 3

2.3.1 Advantages ...................................................................................................... 3 2.3.2 Drawback ......................................................................................................... 3 2.3.3 Alternatives ...................................................................................................... 3

3. Prerequisites ........................................................................................................................ 4

4. SAP NetWeaver MDM 7.1 Web Services ........................................................................... 5 4.1 Use ............................................................................................................................... 5 4.2 Integration..................................................................................................................... 5 4.3 Programming and Configuration................................................................................... 5 4.4 Prerequisites................................................................................................................. 5 4.5 Features........................................................................................................................ 5 4.6 Activities........................................................................................................................ 6 4.7 High Availability and fail-over aspects.......................................................................... 6

5. Configuration Steps in Detail ............................................................................................. 7 5.1 Configuration in the Backend ECC System.................................................................. 7

5.1.1 Prerequisites .................................................................................................... 7 5.1.2 Partner Profile .................................................................................................. 7 5.1.3 Inbound Processing ......................................................................................... 7

5.2 Configuration in the MDM system ................................................................................ 8 5.2.1 SAP NetWeaver 7.1 web-services generator .................................................. 8

5.3 Configuration in the PI System................................................................................... 11 5.3.1 System Landscape Directory......................................................................... 12 5.3.2 Enterprise Services Repository ..................................................................... 13 5.3.3 Integration Directory....................................................................................... 21

5.4 Testing your Scenario................................................................................................. 26 5.5 Monitoring your Scenario............................................................................................ 28

APPENDIX ..................................................................................................................................... 29 A – Creating Technical and Business systems in PI ........................................................... 29 B – Java code for DOMUtil class......................................................................................... 31 C – Java code for GetKeyMap user-defined function.......................................................... 32 D - Java code for getGlobalContainerValue........................................................................ 34

Page 6: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

1. Background Information This guide explains how to set up MDM - PI landscape for leveraging the SAP NetWeaver MDM key-mapping functionality for supporting direct data distribution between client systems.

Such a scenario is particularly useful for supporting system upgrade processes where a preliminary de-duplication and cleansing of master data is required. In the example described in this guide we show how the links between Sales Orders and Customer master data can be correctly updated and distributed with the help of SAP NetWeaver MDM and SAP NetWeaver PI.

May 2009 1

Page 7: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

2. Business Scenario

2.1 Introduction SAP MDM is the ideal solution to build a central repository for master data and their related customizing from heterogeneous landscape. It helps to build the key mapping between same or similar objects from different systems. This key mapping information is very valuable and is requested in many application scenarios regarding master data objects: global spend analysis, global sales reports etc. But there are other IT scenarios that enable you to benefit from this consolidation work done in MDM: mapping during data exchange in cross systems business scenarios, such as unit of measures, basic material etc.

2.2 Scenario Description To better understand the whole process flow, it is necessary to take a simple business scenario where a purchase order data is sent to the PI system asynchronously to create a sales order in a backend ECC system. The data is sent to the PI system via http or file adapter for further processing. The mapping program before transforming the data from order data to Orders IDoc, invokes a web service on the MDM Server to get the details of the customer. The main purpose of the scenario is to show how SAP NetWeaver PI via Key-mapping can leverage SAP NetWeaver MDM’s web service capabilities key-mapping features.

The following graphic describes the important application components and their communication with the PI system for a typical three system landscape.

May 2009 2

Page 8: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

2.3 Pros & Cons of the Scenario In this scenario MDM plays the role of broker for master data keys. The data distribution processes orchestrated by SAP NetWeaver PI depend fully MDM key mappings, and are directly influenced by the MDM component. That has advantages and draw-backs

2.3.1 Advantages • SAP NetWeaver MDM can be used as a central place for managing the master data keys.

• Since PI is synchronously connected to PI any changes corresponding to cleansing and de-duplication activities are immediately available during the Mapping. This avoids the possibility of having data objects being mapped to duplicates, or master data that should be removed from the landscape. This would be particularly interesting for the case of Sales Orders, where accurate Customer data is a strong requirement.

2.3.2 Drawback • A failure in MDM would immediately impact the overall performance of the PI processes that

depend on MDM key mappings. That drives a larger investment in designing a fail-over scenario that satisfies the maximum downtime accepted by the business requirements. Please refer to the MDM Solution Operation Guide for more details.

2.3.3 Alternatives Before implementing the solution described in this guide you should investigate either or not the MDM fail-over concept fulfills your requirements.. If not you should consider replicating the key mappings in SAP NetWeaver PI, and conceive mechanisms for avoiding synchronization issues between the MDM system and PI.

May 2009 3

Page 9: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

3. Prerequisites • Good Knowledge of the MDM and Web Services

• Good Knowledge of SAP NetWeaver PI

• Good knowledge of ERP or ECC systems.

Relevant SAP Notes 1278123 MDM Web Services – NetWeaver Supportability

652736 Configuration file generation for MDM Key Mapping Framework

704303 Key mapping error due to incorrect key mapping properties file

679994 Key mapping of link objects implemented

1261268 MDM solution and server cluster compatibility

1261268 SAP NetWeaver MDM in a cluster under Microsoft Windows

1283909 SAP NetWeaver MDM in a cluster under UNIX based OS

May 2009 4

Page 10: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

4. SAP NetWeaver MDM 7.1 Web Services

4.1 Use The MDM Web services can be used to:

• Manage Master Data Objects

Existence check of a central master object before local creation

Retrieve details and create a local replicate

Create or update master data objects on MDM

• Manage Unique Identifiers of Master Data Objects

Remote system registers local object as replicate of global object

Key mapping during message exchange on SAP NetWeaver XI

4.2 Integration Web services are web-based interfaces that can be integrated into business scenarios of a company based on open and commonly accepted standards. They describe a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards.

Web services for MDM are open interfaces to the MDM Server. They are based on the Simple Object Access Protocol (SOAP) and Web Services Description Language (WSDL) standards. They provide data management capabilities (create, read, update) and access to central key mapping (create, read). MDM Web Services provide synchronous access to MDM for the consumer of the Web services.

4.3 Programming and Configuration SAP NetWeaver MDM 7.1 offers a WebDynpro based project management framework that allows configuring and deploying CRUD support over web services. More details on installation and usage of these WebDynpro components can be found in: https://service.sap-ag.de/~sapidb/011000358700001718732008E

4.4 Prerequisites In this guide we will describe how to use the Customer Key mappings stored in SAP NetWeaver MDM 7.1 for supporting the distribution of transactional data. The transactional data (Sales Orders) is never stored in the MDM server, however Customer data has to be previously consolidated. For this guide we will assume that this process has been already performed, and that the respective key-mappings are available in the system.

4.5 Features MDM Web services provide the following Web service categories: ...

1. To create and retrieve key mapping information for MDM records

2. CRUD (Create, Retrieve, Update and Delete) Web services

May 2009 5

Page 11: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

3. Exposes MDM's rich functionality in searching for records and maintaining data in records (for example, main table, lookups, qualifiers, and Tuples)

4.6 Activities ...

1. Create a project in the SAP NetWeaver MDM 7.1 web-services management tool

2. Define a specific web-service for reading the Customer key mappings in MDM

3. Deploy the web-services in the J2EE engine that will make the web-services available for PI.

4.7 High Availability and fail-over aspects SAP NetWeaver MDM 7.1 is used here as a central broker for Master Data key mapping across systems. It is therefore fundamental to investigate if the SAP NetWeaver MDM failover concept fulfills your business requirements and KPIs.

For more details please refer to the MDM Solution Operation Guide on SAP Service Marketplace (SMP logon required).

May 2009 6

Page 12: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

5. Configuration Steps in Detail This section covers the complete configuration steps that are required in Backend ECC, MDM and PI Systems for message processing.

5.1 Configuration in the Backend ECC System Your backend ECC system need to be configured in order to receive the Order data via IDoc from the SAP NetWeaver PI system. The necessary configuration needs to be done in the SAP Materials Management (MM), Sales and Distribution (SD), and Financial and Controlling (FI/CO) modules. This procedure is normally performed by the MM and SD configuration areas according to their specific requirements. This guide assumes that this configuration has already been done in your ECC system. In this section we only discuss how to configure the inbound processing to receive the Order data via an IDoc.

5.1.1 Prerequisites ...

1. The Segment E1EDKA1 with partner function AG (sold-to party) must exist in the incoming ORDERS05 IDoc. The system can determine the Customer from this entry.

2. The material number maintained in your system must be specified in the IDoc in a segment of type E1EDP19 with the qualifier 002.

5.1.2 Partner Profile You need to maintain the partner profile using transaction WE20 for the incoming Idoc messages with the following parameters:

• Partner Type: KU

• Partner Role: AG

• Message Type: ORDERS

• Process Code: ORDE

• Syntax Check Checked

• Trigger Immediately Checked

5.1.3 Inbound Processing The IDoc interface posts the IDoc in the database and triggers inbound processing. If no errors occur, the system updates the standard order automatically

May 2009 7

Page 13: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

5.2 Configuration in the MDM system

5.2.1 SAP NetWeaver 7.1 web-services generator ...

1. The first step is to create a new project in the web-services generator tool. This is a WebDynpro application that should be deployed in the development system. The application can be accessed from the url:

http://<dev_server>:<port>/logon/logonServlet?redirectURL=%2Fwebdynpro%2Fdispatcher%2Fsap.com%2Ftc%7Emdm%7Ews%7Egenerator%7Eui%2FWSGenerator%3FSAPtestId%3D0

This link may differ depending on your local configuration. There are no particular pre-requisites for the development workstation.

For the purpose of this guide we created the project CustomerWS:

2. In the MDM Web Services Generator wizard, highlight the Project CustomerWS and click Edit. This allows you to select the SAP NetWeaver MDM 7.1 server and Customer repository from where the metadata will be extracted. In the Logon to MDM Server section, enter the MDM Server name and MDM Server password (if any). In the Logon to MDM Repository section, enter the Repository name CustomerRepos with the login User name and Password and click Next.

May 2009 8

Page 14: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

3. In the next step, the wizard allows you to select the tables for which the web services should be made available. For the purpose of this guide we select the Customers table, and choose the search and retrieve operations as shown below:

May 2009 9

Page 15: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

4. In the next step, the wizard allows you to configure the fields that should be exposed by the web-service. In order to optimize performance select only the Customer MDM Id field. The Key mapping fields do not need to be selected as they will be automatically generated by the tool.

5. In the next screen, select the Transport Protocol. In the example we used HTTP, however https protocol could be used as well. Save the project and click Generate to generate the web service.

6. The generated web-service can now be deployed to the Web AS and make it available for the consumer applications such as SAP Netweaver PI to consume it.

May 2009 10

Page 16: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

May 2009 11

7. This web service can be tested now using the Web Service navigator in SAP NetWeaver1 as shown below:

5.3 Configuration in the PI System The section covers configuration steps required in the PI system to configure the Key Mapping Scenario. This includes defining the Software components and Business systems in the System Landscape Directory (SLD), configuring the design objects in the ES Repository, and defining the configuration and routing objects in the Integration Directory of SAP NetWeaver PI. ...

1. Logon to the SAP NetWeaver PI via SAPGUI with your username and password.

2. From the main menu select “Start Integration Builder” (Transaction SXMB_IFR). This will launch the Integration Builder homepage in a separate window as shown below.

1 The link to the corresponding url can be found under http://<server>:<port>

Page 17: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

5.3.1 System Landscape Directory This section covers the creation of Software Component for housing the design objects, and creation of Technical and Business Systems necessary for communicating with the backend ECC system.

5.3.1.1 Create Software Component In this section, we will define a Software Component that will house all the development objects necessary for the MDM Key mapping. ...

1. In the Integration Builder Home Page, select “System Landscape Directory”. This will bring up the SLD in a separate window.

2. Select “Products” from the “Software Catalog”. This will take you to a wizard for creating a new Product and Software Component Version. In the next screen, create a new product called “MDM_product” with the Unit Name “MDM_Unit”.

3. In the next screen, add the software component version to this product and name it “MDM_KEYMAPPING” as shown in the below screen.

More Information:

• SAP Help Portal: Software Component Versions

5.3.1.2 Create Technical and Business Systems This guide assumes that the technical and business systems have already been defined for the backend ECC systems.

Note For detailed steps on how to create the technical and business systems in the SLD of SAP NetWeaver PI, refer to the Appendix section.

May 2009 12

Page 18: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

5.3.2 Enterprise Services Repository This section covers the steps required in the ES Repository for the MDM Key-mapping. ...

1. From the Integration Builder home page, select “Enterprise Services Builder”. This will launch the java web start application. Login with your user ID and password.

2. In the left frame, Click on the menu Object New. In the next dialog-window, select “Work Areas” and “Software Component Versions” and choose the radio button “Import from SLD”.

3. Select the SWCV “MDM_KEYMAPPING” from the list of software component versions and click “Import”. The newly created SWCV should appear in the left frame.

4. Open the SWCV and then double-click on the version. This will bring the SWCV in the right frame. Switch to edit mode and add the namespace “http://sap.com/mdm/pi/keymapping”. Save and Close. The new namespace should be visible under the SWCV node in the left frame.

Note The best practice is to import SAP Interfaces such as RFCs and IDocs into SAP BASIS or SAP APPL software components to avoid redundancy. But if you need to import these objects into your SWCV, you need to enter the system details in the section “Connection data for Import from SAP System” of SWCV.

5. In the left frame, right-click on the Namespace “http://sap.com/mdm/pi/keymapping” and select “New”. In the next dialog-window, select “Data Type” from the Interface objects node and create a new Data Type “OrderRequest”.

6. In the data type editor, create the structure for the OrderRequest as specified below. Make sure to save the object.

Note The structure shown below is a sample order data created for this scenario. You can modify the structure to meet your specific needs.

May 2009 13

Page 19: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

7. In the left frame, right-click on the namespace “http://sap.com/mdm/pi/keymapping” and select “New”. In the next dialog-window, select “Message Type” from the Interface objects node and create a new Message Type called “OrderRequest”.

8. Switch to edit mode on the OrderRequest message type. For the section “data type used” you can go to the input help (F4) and choose your data type “OrderRequest” (created in the previous step) from the drop-down list. Verify the data type and save the object.

9. Right-click on the namespace and select New. In the next dialog-window, select “Service Interface” from the Interface objects node and create a new Service Interface called “Orders_Out”. The interface should be outbound and asynchronous as shown in the screen below.

May 2009 14

Page 20: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

10. In this step, you will import the WSDL for the MDM Web service “SAP_MDM_CUSTOMER_01” into the external definition of the namespace “http://sap.com/mdm/pi/keymapping”. This Web service will be used for looking up the customer data in the MDM database. The procedure for generating the web services in MDM is described in Section 5.2.1.

In the left frame, right-click on the namespace”http://sap.com/mdm/pi/keymapping” and select New. In the next dialog-window, select “External Definition” from the Interface objects node and create a new External Definition called “Mdm_Cust”. Switch to the edit mode on the “Mdm_Cust” external definition. Select the category as “wsdl” and import the WSDL file for the SAP_MDM_CUSTOMER_01 web service and save the object.

May 2009 15

Page 21: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

11. Right-click on the namespace and select New. In the next dialog-window, select “Service Interface” from the Interface objects node and create a new Service Interface called “MdmService_Sync”. In the right frame below, choose the message type “External Message” and select “retrieveCustomersIn_doc” as the Request message and “retrieveCustomersOut_doc” as the Response message from the drop-down list. The interface should be inbound and synchronous as shown in the screen below:

12. In this step, you will create the graphical mapping between the custom order data and the Orders05 Idoc. In the left frame, right-click the namespace and select “New”. In the next dialog-window, select the node “Mapping Objects” and create a new Message Mapping object and name it “Orders_ORDERS05_Lookup”. In the graphical mapping editor, select your message type “OrderRequest” as source message. As target message, select the ORDERS.ORDERS05 IDoc from the SAP BASIS software component under the node “Imported Objects”.

Note <Enter text here> You need to import the ORDERS.ORDERSO5 IDoc into the imported Objects section of the SAP BASIS software component prior to the mapping. For more information on how to import IDocs, see SAP Help Portal: Importing IDocs and RFCs.

13. Map the fields of the source document to the equivalent fields in the ORDERS05 IDoc. This can be achieved easily by locating the field in the target field structure and then drag and drop from the source field to the target field. Please refer to the table below for the mapping rules and make sure to save the mapping.

Source field in OrderRequest Target field in ORDERS05

Header Currency E1EDK01 CURCY

Header PONumber E1EDK01 BELNR

Header DocType E1EDK01 BSART

May 2009 16

Page 22: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

Header PartnerInfo PartnerRole E1EDKA1 PARVW

Header PartnerInfo Name E1EDKA1 NAME1

Header PartnerInfo Street E1EDKA1 STRAS

Header PartnerInfo City E1EDKA1 ORT01

Header PartnerInfo Zip E1EDKA1 PSTLZ

Header PartnerInfo Country E1EDKA1 LAND1

Header PartnerInfo Region E1EDKA1 REGIO

Header PartnerInfo Name2 E1EDKA1 BNAME

Header PartnerInfo Language E1EDKA1 SPRAS_ISO

Header PONumber E1EDK02 BELNR

Header PODate E1EDK02 DATUM

Header References Qualifier E1EDK17 QUALF

Header References RefNum E1EDK17 LKOND

Header References RefText E1EDK17 LKTEXT

Items ItemNumber E1EDP01 POSEX

Items Action E1EDP01 ACTION

Items Quantity E1EDP01 MENGE

Items UOM E1EDP01 MENEE

Items MaterialInfo Action E1EDP19 QUALF

Items MaterialInfo Material E1EDP19 IDTNR

14. Now we have to assign constants to certain fields and attributes in the IDoc. Refer to the table below for more details on the mapping rules.

Constant Target field in IDoc

1 ORDERS05 IDOC BEGIN

1 E1EDK01 SEGMENT

1 E1EDKA1 SEGMENT

1 E1EDK02 SEGMENT

001 E1EDK02 QUALF

1 E1EDK17 SEGMENT

1 E1EDP01 SEGMENT

1 E1EDP19 SEGMENT

May 2009 17

Page 23: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

Mapping Lookups 15. By using mapping lookup, mapping programs in SAP Netweaver PI can call functions from other

application systems (MDM in this case) while a mapping program on the Integration Server is being executed. In this step, we use mapping lookups to lookup customer specific information in the MDM application by making a web service call at runtime while the message mapping being executed. You can use the mapping lookup API in the user-defined functions of the message mapping to make this call.

a. As a first step you create the java class DOMUtil.class with NetWeaver Developer Studio or any Java Workbench. Import this class into the imported archives node as shown in the screen below. Save the Object.

Note Please refer to the Java code for the DOMUtil class in Appendix B.

b. In the mapping editor of the message mapping Orders_ORDERS05_Lookup, switch to the Functions tab Page. In the Functions and Java areas section, click on the Archives Used tab and add the DOMUtil class from the imported archives. In the Import Instructions tab add the imports as shown in the screen below.

May 2009 18

Page 24: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

The following user-defined functions need to be created for your message mapping Orders_ORDERS05_Lookup to execute the mapping lookup using the mapping Lookup API.

More details on how to use the Lookup API in a message mapping and the steps that need to be performed in the Integration Directory can be found at the link: Using the Lookup API in a Message Mapping.

GetKeyMap – In this user-defined function, you will build the payload that the soap adapter expects and parse the result payload. More details on how to code this user defined function can be found at the link: Implementing Lookups using SystemAccessor.

May 2009 19

Page 25: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

getGlobalContainerValue: This function is used to get the value from the resulting payload.

To create these new functions select “Create New Function” button at the bottom left corner of the message mapping editor.

In the subsequent dialog, fill in the label of the function and the necessary parameters and then click on Create Function button. Enter the Java code in the subsequent dialog and save it.

Note Please refer to the Java code for these functions in Appendix C and Appendix D.

To use these two user-defined functions, we can do the following mapping:

In the mapping editor, map the source fields Header PartnerInfo PartnerRole and Header PartnerInfo PartnerNumber to the target field E1EDK01 with the following mapping rule. This mapping rule makes the web service call to the MDM server while the mapping program is being executed on the Integration Server at runtime.

In the mapping editor, map the source fields Header PartnerInfo PartnerRole and Header PartnerInfo PartnerNumber to the target field E1EDKA1 PARTN with the following mapping rule.

16. Save and activate the message mapping Orders_ORDERS05_Lookup. Once the lookup API is implemented in the user-defined function of the message mapping and have it configured in the integration directory (See the configuration steps 2 and 3 defined in the Integration Directory section below), you should be able to test the message mapping program using the Test tab of the Operation Mapping (defined in Step 16) of the Enterprise Services Repository.

May 2009 20

Page 26: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

17. In this step, you will create an Operation mapping object. In the left frame, right-click the namespace and select “New”. In the next dialog-window, select the node “Mapping Objects” and create a new Operation Mapping object and name it “Orders2Idoc”. Assign the following the Service Interfaces and mappings to the newly created operation mapping:

• Source Operation: Orders_Out

• Target Operation: ORDERS.ORDERS05

• Mapping Program: Orders_ORDERS05_Lookup

18. Activate all your change lists.

5.3.3 Integration Directory This section covers the steps required in the Integration Directory for the MDM Key-mapping. ...

1. From the Integration Builder home page, select “Integration Builder”. This will launch the java web start application. Login with your user ID and password.

Note The objects defined in the steps 2 and 3 below are used to make a web service call to MDM Server from the message mapping using the mapping Lookup API.

2. In the left frame, Click on the menu Object New. In the create dialog-box, select Collaboration profiles Business Component and assign the name ‘MDMSoapService” to this component and click on Create. In the next screen, select the Receiver Tab and assign the inbound interface defined in the ES Repository, “MdmService_Sync” in your namespace (http://sap.com/mdm/pi/keymapping). Save the Business Component.

May 2009 21

Page 27: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

3. In this step, you will create the communication channel to make a call to the MDM Web Service using the SOAP Adapter. In the left frame, right-click on the Business Component MDMSoapService Communication Channel and click on New. In the create dialog-box, assign the name ‘MDM_Soap_Receiver” to this communication channel and click on Create. In the next screen, enter the values as shown in the screen below and Save. The Target URL is the URL for the MDM web service.

4. Create a Sender Party: In the left frame, Click on the menu Object New. In the create dialog-box, select Collaboration profile Party and assign the name ‘MDM_Sender” to this component and click Create. In the Identifiers tab, enter the alternative identifier for the backend system as shown in the screen below:

May 2009 22

Page 28: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

5. Create the Sender Business Component: In the left frame, right-click on the Party MDM_Sender Communication Component and click New. In the create dialog-box, select Collaboration profiles Business Component and assign the name ‘MDM_BS” to this component and click on Create. In the next screen, select the Receiver Tab and assign the inbound interface defined in the ES Repository, “Orders_Out” in your namespace (http://sap.com/mdm/pi/keymapping). Save the Business Component.

6. Create the Receiver Business System: In the left frame, right-click on the Business System node and click on Assign Business Systems. In the next pop-up dialog, select the Business system for the backend ECC system ECC_100 (created in APPENDIX D), uncheck the “Create Communication Channels automatically” check box, and click on Finish.

7. Create the Receiver Communication Channel: In this step, you will create the communication channel to communicate with the backend ECC system using IDoc Adapter. In the left frame, right-click on the Business System ECC_100 Communication Channel and click on New. In the next screen, enter the values as shown in the screen below and save.

• RFC Destination: RFC Destination for the Backend ECC system created using Transaction Code SM59

• Interface Version: Interface version of the IDOC

• Port: Port for the backend system created using Transaction code IDX1.

• SAP Release: Release of the SAP System

May 2009 23

Page 29: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

8. Create the Receiver Determination: In the left frame, Click on the menu Object New. In the create dialog-box, choose Communication Object Receiver Determination and assign the following values and click Create.

• Communication Party: MDM_Sender

• Communication Component: MDM_BS

• Interface: Orders_Out

• Namespace: http://sap.com/mdm/pi/keymapping

In the next window, choose the Contents tab and choose the ECC_100 as the communication component and Save.

May 2009 24

Page 30: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

9. Create the Interface Determination: Open the Receiver Determination object created in step 8 (if it is not already open), switch to Configuration overview and click Refresh ( ). The Business system ECC_100 should now show up in the Receivers List. Expand ECC_100 and highlight the ORDERS.ORDERS05 interface. In the frame Objects of Selected Criterion, right-click on the interface determination and click New specific. This defaults some of the specific values for the Interface determination. Choose the following values for the remaining fields as shown in the screen below and Save.

• Operation Mapping: Orders2Idoc

• Name: ORDERS.ORDERS05

• Namespace: urn:sap-com:document:sap:idoc:messages

10. Create the Receiver Agreement: Open the Receiver Determination object created in step 8 (if it is not already open), switch to Configuration overview and click Refresh ( ). The Business system ECC_100 should now show up in the Receivers List. Expand ECC_100 and highlight the ORDERS.ORDERS05 interface. In the frame Objects of Selected Criterion, right-click on the Receiver Agreement and click New specific. This defaults some of the specific values for the Receiver Agreement. Choose the following values for the remaining fields as shown in the screen below and Save.

• Receiver Communication Channel: IDoc_receiver

May 2009 25

Page 31: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

11. Active all the Objects in the change list.

5.4 Testing your Scenario ...

1. From the Integration Builder home page, choose Runtime Workbench. Login with your user ID and password.

2. In the next screen, choose Component Monitoring and click on Display. Within Components, navigate to Domain<SID>(domain.00.<host>) Integration Server and click Integration Engine<SID>. Then at the bottom of the screen, choose Test Message tab as shown below:

May 2009 26

Page 32: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

3. Enter the following values in the fields of the Test Message tab and click Send Message. You can copy these values from the Receiver Determination object of the MDM_Sender party in the Integration Directory.

• Send Message to: http://<Host>:<Port Number>/sap/xi/engine?type=entry

• Sender Party: MDM_Sender

• Sender Component: MDM_BS

• Interface: Orders_Out

• Interface Namespace: http://sap.com/mdm/pi/keymapping

• User: <Your Username>

• Password: <Your Password>

• Payload: <Test Payload>

Note You can generate the payload for this test using Test Tab of message mapping in ESR.

May 2009 27

Page 33: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

5.5 Monitoring your Scenario ...

1. In the ABAP Stack of the SAP NetWeaver PI, go to transaction SXMB_MONI and choose Monitor for Processed XML messages and click Execute ( ). In the next screen, You can filter using Sender Party as shown below:

2. In the monitor screen, your messages should appear with a checkered flag (message processed successfully) if it is processed successfully.

3. From this screen, you can navigate to the details of the message as shown in the screen below:

May 2009 28

Page 34: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

APPENDIX

A – Creating Technical and Business systems in PI

Creating Technical System This section explains the detailed steps required to define a Technical System for the backend ECC system. ...

1. In the SLD Home Page (Click “Home” in the upper left corner), select “Technical Systems” from Landscape section and click on “New Technical System”. This will take you to a wizard for creating a new technical system.

2. For the type of technical system, select “AS ABAP” and enter the backend ECC system’s SID, Installation number and the Host Name.

3. In the next screen, add the central servers and application servers to the technical system

4. In the subsequent screen, add the Client number and the Client Logical name.

5. In the next screen, select “ECC 5.0” from the list of available products, and select the software component “SAP BASIS 6.40” from the list of available software components and click on “Finish”.

More Information:

• SAP Help Portal: Working with Technical Systems

May 2009 29

Page 35: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

Creating Business System In this section, you will define a Business System for the backend ECC system. ...

1. In the SLD Home Page (Click “Home” in the upper left corner), select “Business System” from the Landscape section and click on “New Business System”. This will take you to a wizard for creating a new business system.

2. For the type of technical system that the business system is associated with, select “AS ABAP” and click “Next”

3. In the next screen, Select “ECC on ecchost” you created in the previous section as the technical system and click “Next”

4. In the next screen, enter “ECC_100” as the name of the Business system. In the following screen, verify the products and software components that are installed for the business system.

5. In the next screen, select the role of the business system, specify the integration server and click on “Finish”.

More Information:

• SAP Help Portal: Working with Business Systems

May 2009 30

Page 36: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

B – Java code for DOMUtil class

package com.sap.xi.mapping.parse.dom;

import org.w3c.dom.*;

public class DOMUtil {

public static Element getFirstElement(Element element, String name) {

NodeList nl = element.getElementsByTagName(name);

if (nl.getLength() < 1)

throw new RuntimeException(

" Element: " + element + " does not contain: " + name);

return (Element) nl.item(0);

}

public static String getSimpleElementText(Element node, String name) {

Element namedElement = getFirstElement(node, name);

return getSimpleElementText(namedElement);

}

public static String getSimpleElementText(Element node) {

StringBuffer sb = new StringBuffer();

NodeList children = node.getChildNodes();

for (int i = 0; i < children.getLength(); i++) {

Node child = children.item(i);

if (child instanceof Text)

sb.append(child.getNodeValue());

}

return sb.toString();

}

}

May 2009 31

Page 37: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

C – Java code for GetKeyMap user-defined function import com.sap.aii.mapping.lookup.*;

public String GetKeyMap(String Remkey, Container container) throws StreamTransformationException{

String request = “<Payload of the MDM_Cust Request web service. See sample below>”

InputStream isRequest = new ByteArrayInputStream(request.getBytes());

SystemAccessor accessor = null;

try{

// Determine a Communication channel. This communication channel should already be configured in the Integration Directory.

Channel channel = LookupService.getChannel("*", "MDMSoapService", "MDM_Soap_Receiver");

// Get a System Accessor for the Channel

accessor = LookupService.getSystemAccessor(channel);

// Create a payload according to the data type which the adapter expects

Payload payload = LookupService.getXmlPayload(isRequest);

// Execute Lookup

Payload result = accessor.call(payload);

// Parse Response

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

InputStream resStream = result.getContent();

Document document = builder.parse(resStream);

Element retrieveCustomersResponse = document.getDocumentElement();

NodeList customer = retrieveCustomersResponse.getElementsByTagName("pns:customers");

// Store in a Global Container

GlobalContainer gc = container.getGlobalContainer();

gc.setParameter("CustomerData", customer);

} catch (Exception e) {return e.getMessage();

} finally {

try {

if (accessor != null) accessor.close();

} catch (Exception e) {

return e.getMessage();

}

}

return Remkey;}

May 2009 32

Page 38: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

Sample Payload for GetKeyMap

<?xml version="1.0" encoding="UTF-8"?>

<ns0:retrieveCustomers xmlns:ns0="urn:SAP_MDM_CUSTOMER_01Vi">

<ns0:query>

<ns1:criteria xmlns:ns1="urn:com.sap.mdm.ws.beans">

<ns1:internalID/>

<ns1:keyMapping>

<ns1:remoteSystem>R3_ERP</ns1:remoteSystem>

<ns1:remoteKey>This field is passed as a parameter to UDF</ns1:remoteKey>

</ns1:keyMapping>

</ns1:criteria>

<ns1:resultDefinition xmlns:ns1="urn:com.sap.mdm.ws.beans">

<ns1:fieldListType>all</ns1:fieldListType>

<ns1:retrieveKeyMapping>true</ns1:retrieveKeyMapping>

<ns1:loadAttributes>false</ns1:loadAttributes>

</ns1:resultDefinition>

</ns0:query>

<ns0:reposInfo>

<ns2:dataLang xmlns:ns2="urn:com.sap.mdm.core.beans">English [US]</ns2:dataLang>

<ns2:repositoryName xmlns:ns2="urn:com.sap.mdm.core.beans">SAP_CUSTOMER_012020</ns2:repositoryName>

<ns2:serverName xmlns:ns2="urn:com.sap.mdm.core.beans">madd00002696a</ns2:serverName>

</ns0:reposInfo>

</ns0:retrieveCustomers>

May 2009 33

Page 39: Using MDM 7.1 Key-Mappings in a PI Landscape

Using MDM 7.1 Key-Mappings in a PI Landscape

May 2009 34

D - Java code for getGlobalContainerValue public String getGlobalContainerValue(String objectName, String valueName, Container container) throws StreamTransformationException{

String result = new String();

try{

GlobalContainer gc = container.getGlobalContainer();

NodeList custList = (NodeList) gc.getParameter(objectName);

for (int i = 0; i < custList.getLength(); i++) {

result = DOMUtil.getSimpleElementText((Element) custList.item(i),valueName);

}

} catch (Exception e) {

return e.getMessage();

}

return result;

}

Page 40: Using MDM 7.1 Key-Mappings in a PI Landscape

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