01 mapping introduction

Upload: vivek-joshi

Post on 09-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 01 Mapping Introduction

    1/20

    1

    Introductionto Mapping in XIAuthor: Joachim Orb

  • 8/8/2019 01 Mapping Introduction

    2/20

    2

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Object ives

    Af te r comp le t i ng th i s sess ion , you w i l l be ab le to :Where mapping steps occur in SAP XI

    Which mapping techniques you can use within SAP XI

    How to implement different mapping techniques in SAP XI

  • 8/8/2019 01 Mapping Introduction

    3/20

    3

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Overview

    Overview Mapping Introduction

    Java Mapping

    XSLT Mapping

    ABAP Mapping

  • 8/8/2019 01 Mapping Introduction

    4/20

    4

    The term Mapping means:

    1. The transformation process, and/or

    2. The transformation rules.

    Independently from XI, you can distinguish two different mappings

    Structure mappings transform entire message structures.

    Value mappings transform values within messages.

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Peter

    Miller

    Airline KingdomAK0872001-11-22

    business

    22.11.2001087

    Peter Miller

    2Happy Holiday

    Overview - General Mapping Types

    Mapping

    Transformation from one message structure to another

    Transformation rules defined by mapping program

    Structure Mapping

    ValueMapping

  • 8/8/2019 01 Mapping Introduction

    5/20

    5

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Integration Server

    Business ProcessEngine

    Mapping a t Runt im e

    IntegrationEngine

    Outbound Handling(also in adapters)

    Business ProcessExecution

    Inbound Handling(also in adapters)

    Receiver Determination

    Interface Determination

    Channel Determination

    Mapping

    Messages in XI contain a senderinterface

    IS evaluates configuration data

    of the Integration Directory During logical routing, the

    IS determines a ReceiverInterface (1).

    Such an interface pair canoptionally reference an

    Interface Mapping

    An interface mapping

    points to one or moremapping programs

    (for request, responseand/or fault messages)

    IS executes mappingprograms (2)

    Receiver determinationand mapping step can also

    be performed within in thescope of BPM (1;2)

    1

    2

    1;2

  • 8/8/2019 01 Mapping Introduction

    6/20

    6

    request or Mapping programs (message mappings, XSLT mappings or Java mappings) refer tomessages: They are associated either to the request, the response or the fault message byreferring to the corresponding message types (as shown in the slide) or to the corresponding part (response) of an RFC, for example. However, recall that message exchange in XI is interfacebased, for example, a message can be sent by calling the method of an outbound proxy. Togetherwith the name of the sending business system, the name of the corresponding outbound interfaceis an attribute of the message header. This information is evaluated on the integration server to findout receiver and receiver interface. Thus, first interfaces are related to each other during runtime toexchange messages, not message types.

    Thats why we somehow have to specify which mapping programs belong to which interface pair and

    this can be done already during design time in the integration repository. For this purpose, youhave to create an interface mapping. By means of an interface mapping, you relate acorresponding outbound and inbound interface to each other and specify which mapping programsshall be used for this interface pair. You can even define several interface mappings for the sameinterface pair to take requirements of different scenarios for the same interface pair into account.Basically, an interface mapping embraces the mapping programs that shall be used for request,response and fault message. Additionally, an interface mapping allows you to define a sequence ofmapping programs to be executed.

    Thus, the definition of interface mappings is obligatory and simplifies the mapping configuration in theintegration directory: To choose mappings for an interface pair, you just have to choose therelevant interface mapping that had been defined for this pair in the integration repository.

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Overview - Rela te Mapping Programs t o In ter faces

  • 8/8/2019 01 Mapping Introduction

    7/20

    7

    The exchange infrastructure supports three types of mappings:

    Message mappings that can be designed using a graphical mapping editor in theIntegration Builder. As a result, Java code is generated from the graphicalrepresentation that is compiled before it can be executed on the integration server.

    You can implement your own Java mappingby implementing a specific interfaceof the mapping API.

    You can implement an XSLT mapping

    For the latter two, there is no tool support in XI. It is expected that they aredeveloped using external development tools. To make them available for theintegration server, they have to be imported into the integration repository as JARfiles before (JAR: Java Archives).

    Developers can even decide to combine the different mapping technologies:

    Message mappings, XSLT mappings and Java mappings can be combined in a sequence bymeans of an interface mapping (see next slide).

    XSLT mappings can use java functions

    Message mappings support user-defined functions that can use imported java packages of the

    same namespace.

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Overview - Mapping Programs t o Map Messages

    Message Mapping

    Designed by using the graphical mapping editor of IntegrationBuilder

    Result: Generated Java Code.

    Imported Archives

    Import externally defined mapping programs into repository

    Java mapping:Implemented by using a specific interface

    XSLT mapping:

    Runtime supports XSLT processor

    Java methods can be called from within a Style Sheet

    ABAP Mapping

    You can execute mapping programs in a sequence

  • 8/8/2019 01 Mapping Introduction

    8/20

  • 8/8/2019 01 Mapping Introduction

    9/20

    9

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Java Mapping (I )

    Mapping programs can beimplemented in Java

    1. Develop your Java code locallye.g. with your IDE

    2. Create a .jar or a .zip

    2.1 Using the jar command ofthe jdk

    2.2 Using a built-in IDEfunctionality

    3. Create a new Imported Archiveand import the .jar to the

    Integration Repository

  • 8/8/2019 01 Mapping Introduction

    10/20

    10

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Java Mapping (I I ) - Development

    Define a Java class that implements the Java interfacecom.sap.aii.mapping.api.StreamTransformation

    The interface contains two methods:1. public void execute(java.io.InputStream in,

    java.io.OutputStream out)

    to perform the mappings.

    2. public void setParameter(java.util.Map param)

    to access to runtime constants possible(for example: INTERFACE, SENDER_NAME)

    The required libraries are contained in theaii_map_api.jar, which is part of your SAP J2EEEngine installation

    DOM and SAX Parsers provided by the SAP XML Toolkitfor Java can be used

    API to execute value mappings

  • 8/8/2019 01 Mapping Introduction

    11/20

    11

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Java Mapping (I I I ) - Templa te

  • 8/8/2019 01 Mapping Introduction

    12/20

    12

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Overview

    Overview Mapping Introduction

    Java Mapping

    XSLT Mapping

    ABAP Mapping

  • 8/8/2019 01 Mapping Introduction

    13/20

    13

    SAP AG 2004, Mapping Introduction, Joachim Orb

    XSLT Ma pping (I )

    Proceeding equivalent as for Javamappings

    1. Develop your XSLT files

    2. Create a .jar or a .zip

    2.1 Using the jar command ofyour jdk

    2.2 Using a built-in IDEfunctionality

    3. Create a new Imported Archiveand import the .jar to the

    Integration Repository

    4. Uploaded XSLT programs canmodified within the XIRepository by means of asimple editor.

  • 8/8/2019 01 Mapping Introduction

    14/20

    14

    Java mapping

    In order to develop a Java mapping, you have to implement interface StreamTransformation (see above). Bymeans of this interface, you get access to the message as a stream that is received at runtime on theintegration server. To process this stream, use Java API for XML Processing(JAXP), for example. The JAXPsupports the Document Object Model (DOM) and the Simple API for XML (SAX). This gives you greatflexibility for mapping definitions with Java. Within your mapping program you can also access runtimeconstants like senderName or receiverName to implement a mapping that depends on message headercontent. After your message transformation, you can pass it back to the integration server as a stream.

    First experiences with Java mappings showed that mappings using DOM are very memory extensive and werentsuitable for very large messages (e.g., catalog data). Since the size of messages depend of the applicationcase, it was decided to leave the decision of which technology to use (DOM/SAX) to the application and tojust pass a stream.

    XSLT mapping

    Messages are in the form of XML documents. XSL Transformation (XSLT) is a member of the XML family oflanguages. It describes how an XML structure is transformed into another XML structure.

    You can define mappings using XSLT together with XPath. XPath is also a specification of the XML family. UsingXPath you can address any node in an XML document. XSLT implements XPath expressions to selectsubstructures of an XML document. Using templates in XSLT you can define the mapping rules for theselected substructures. Further supported features are:

    You can use the XSLT tags and to include predefined templates for substructures in acomplete mapping definition. In this way, you can reuse mappings for data types.

    Moreover, using an XSLT definition you can call external Java methods to convert XML structures. This proceduregives you more flexibility when defining mappings. However, not all XSLT processors support external Java calls.

    See online documentation for details.

    SAP AG 2004, Mapping Introduction, Joachim Orb

    XSLT Mapping (I I ) - Features

    XSL-Transformation: transforming XML structures

    XPath: Locating information in XML documents

    and : inclusion of other XSLT files to access runtime constants

    Invoking external Java methods from within an XSLTransformation

  • 8/8/2019 01 Mapping Introduction

    15/20

    15

    SAP AG 2004, Mapping Introduction, Joachim Orb

    XSLT Mapping (I I I ) - Ex ample

    XSLT Mapping with Java Enhancement

    Calls the method merge:

  • 8/8/2019 01 Mapping Introduction

    16/20

    16

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Overview

    Overview Mapping Introduction

    Java Mapping

    XSLT Mapping

    ABAP Mapping

  • 8/8/2019 01 Mapping Introduction

    17/20

    17

    SAP AG 2004, Mapping Introduction, Joachim Orb

    ABAP Mapp ing (I)

    Mapping programs can be implemented in ABAP

    1. Add additional mapping types in your Exchange Profile:

    com.sap.aii.repository.mapping.additionaltypes =

    R3_ABAP|Abap-class;R3_XSLT|XSL (ABAP Engine)

    2. Develop your ABAP-OO class in the Object Navigator (se80)

    3. Create a new Interface Mapping

    Select Mapping TypeAbap-class

    Enter the name of the ABAP-OO class

  • 8/8/2019 01 Mapping Introduction

    18/20

    18

    SAP AG 2004, Mapping Introduction, Joachim Orb

    ABAP Mapping (I I ) - Development

    Define a ABAP class that implements the interfaceIF_MAPPING of package SAI_MAPPING

    The interface contains the method EXECUTE to perform themappings.

    You might use the iXML library in an ABAP Objectsenvironment to parse your document

    XSTRINGExportingRESULT

    IF_MAPPING_TRACETRACE

    IF_MAPPING_PARAMPARAM

    XSTRINGImportingSOURCE

    ReferenceDirectionParameter

  • 8/8/2019 01 Mapping Introduction

    19/20

    19

    SAP AG 2004, Mapping Introduction, Joachim Orb

    ABAP Mapping (I I I ) - Templat e

    method if_mapping~execute.

    * initialize iXML

    type-pools: ixml.

    class cl_ixml definition load.

    * create stream factory

    data: streamfactory type ref to if_ixml_stream_factory.

    streamfactory = ixmlfactory->create_stream_factory( ).

    * create input stream

    data: istream type ref to if_ixml_istream.

    istream = streamfactory->create_istream_xstring( source ).

    *

    * get XI parameter

    data: l_sender_service type string.

    l_sender_service = param->get( if_mapping_param=>sender_service ).

    *

    * create output stream

    data: oStream type ref to if_ixml_ostream.

    oStream = streamfactory->create_ostream_xstring( result ).

    *

    endmethod.

  • 8/8/2019 01 Mapping Introduction

    20/20

    SAP AG 2004, Mapping Introduction, Joachim Orb

    Summary

    Now you shou ld be ab le to : get an overview about the different Mapping Programs, supported by

    XI 3.0