• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

riyaz.net

Tech Tips and Tutorials for SAP Professionals and Bloggers

  • Home
  • WordPress
  • Tips & Tricks
  • Internet
  • SAP
    • SAP PI
    • SAP ABAP
  • Personal Finance
  • Health & Fitness
  • Travel & Leisure
You are here: Home / SAP / XI/PI – 1:n Multi-Mapping using BPM

XI/PI – 1:n Multi-Mapping using BPM

April 23, 2008 by Riyaz

Multi-mapping is a method of message transformation wherein one or more source messages can be combined or split to generate one or more target messages. We can have three types of multi-mapping transformations – 1:n, n:1, and n:m mapping transformation. In this article, we will understand how to create and use 1:n multi-mapping transformation in a BPM scenario.

Input MessageLets say, we have a source message as shown on the left. It contains combined data of a set of sales orders. The node OrderData can occur n number of times where n≥1. And we have the target structure as shown below wherein the node OrderData can occur exactly once. Thus our aim is to read one message from source system and generate n messages at the target system, where n = number of orders (OrderData nodes) present in the source message.Output Message

Create the required data types (Structures here), message types, and message interfaces. We will need four asynchronous message interfaces: one for outbound message, one for inbound message and two abstract interfaces one each for the source and the target message.

Graphical MappingNow create a mapping program (say MM_Orders). Select the source and target message types. Go to the Messages tab and change the occurrence of the target message to 0..unbounded (see figure on the left). Come back to the Design tab and define your transformation logic. Here is the complete graphical mapping.

Since the nodes CompanyCode and SalesArea occur only once in the source structure and should be generated in every target structure, we need to use node function useOneAsMany as shown in the figure below to map these fields from source to target. For more details about useOneAsMany function refer this article.

useOneAsMany

Once you have completed the message mapping go to the Test tab, right-click the node OrderData and use Repeat Subtree option 2-3 times. Then execute the mapping program to verify that multiple messages structures are indeed generated at the target side.

Create an Interface Mapping (say IM_Orders) using the abstract interfaces defined for source and target messages. We need to use abstract interfaces as we will be using this mapping within the BPM process definition. Make sure you change the occurrence of the target interface to 0..unbounded.

Now, create an Integration Process (BPM) as shown below.

BPM with 1:n Multi-Mapping Transformation

Define two container elements Source and Target for the two abstract interfaces as shown below. Note that the element Target must be a Multiline element since we need to generate multiple messages at the target. We will define CurrentLine element later during the block step.

Container Elements

Receive Step: Asynchronously receives the source message.

Receive Step

Transformation Step: Transforms the Source to Target using the transformation defined by the Interface Mapping.

1:n Transformation Step

Block Step: Select ForEach mode. In ForEach mode the block executes for each line of multiline container element and completes either when the End Condition returns true or when all the lines of multiline container element get processed. The end condition is checked as soon as the block processes the first line of multiline container element.

ForEach Block Step

A single line container element needs to be defined to hold the Current line of the multiline element. Select the Block and define a new container element (say CurrentLine) as shown previously. Note that this element is visible only within the specified block. No need to define end condition as we want to process all the elements of the multiline container element.

Send Step: Define a send step within the ForEach block. This step sends out the contents of CurrentLine element asynchronously one by one.

Send Step

Check your BPM using F7 key. Activate the change list. Then complete the directory configuration. You will require one sender agreement; one receiver/interface determination each for source system to BPM and BPM to target system and one receiver agreement.

You can use file systems as the source and the target systems in which case you can define file adapters at the sender and receiver side.

Once all the changes have been activated, test your interface by putting a file containing data for multiple orders in the source directory. Open and check the target directory to see whether the specified number of files have been correctly generated.

Filed Under: SAP Tagged With: SAP PI

About Riyaz

Riyaz Sayyad is the founder of Riz Labs. Learn more about him here.

Primary Sidebar

Popular Guides

  • Dropbox Tutorial
  • CDN Setup Guide
  • Blog Design Tips
  • Optimize RSS Feed
  • Create Twitter App
  • Short URLs
  • Password Protect Folders
  • Time Management
  • ALE IDocs Tutorial
  • SAP PI Starter Kit
  • SAP PI Tips
  • Ergonomics

Popular Topics

  • Home
  • WordPress
  • Tips & Tricks
  • Internet
  • SAP
    • SAP PI
    • SAP ABAP
  • Personal Finance
  • Health & Fitness
  • Travel & Leisure

About Riyaz

riyaz.net is a popular technology site with how-to guides, tips and tutorials on personal technology, blogging, social media, web apps, personal finance and SAP.

riyaz.net was launched way back in 2005 by web designer, blogger and SAP Consultant Riyaz Sayyad from Pune, India. Over the years the site has grown into a full featured online community with thousands of visitors daily from around the world. Read more.

Copyright © 2023 · riyaz.net