XI/PI - 1:n Multi-Mapping using BPM
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.
Lets 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.
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.
Now 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.

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.

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.

Receive Step: Asynchronously receives the source message.

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

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.

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.

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.



Malu Mader says:
July 25th, 2008 at 1:09 pm
Hej Riyaz
Thansk for this blog , I have run it but i can not se any file in the target directory.
every thing looks fine in ID and in IR, the monitor shows that the graphical workflow log ends at the send step and not at the end of the block.
any help
Riyaz says:
July 25th, 2008 at 1:26 pm
Hi,
Please check whether all the properties of BPM steps are correctly defined. You can check the return code for the BPM in SXI_CACHE. If the return code is 0, try reactivating your BPM object by using the activate button. If return code is other than zero, you need to check the syntax errors in BPM definition in IR. Use F7 in IR to check for syntax. Also, check properties of individual steps.
Hope this helps.
Regards,
Riyaz
Leela says:
October 11th, 2008 at 3:07 pm
Hi,
Thanks for your blog. I have done this scenario. Evrything if fine. But while executing the scenario, i am not getting the output. It is in th queue. I have seen the return code of my BPM also. It is 0.In the queue the status it was showing is :Retry”.
Below is the input file i am giving.
Y-351
1100
KG
Y-352
1100
KG
Y-353
1111
KG
Y-354
1111
KG
.
I am not specifying any condition. I have done 1:1 mapping.
Could you please help in my scenario.
Riyaz says:
October 11th, 2008 at 9:27 pm
Leela,
Please explain your scenario clearly. This article is about 1:n mapping. You are speaking about 1:1 mapping.
Is you message shown with a red flag in SXMB_MONI? if not is it successful on the outbound side?
Hennie Nel says:
October 29th, 2008 at 1:55 am
Hi Riyaz - I have looked everywhere and have found no solution to my challenge - I am interested in a file-to-multiple IDOC scenario - I have a file with a single structure and need to map that into the standard IDOC ACC_GL_POSTING01 - I have no problem in mapping all of the lines from the file to a single IDOC but have some challenges doing it to multiple…is this possible in a message mapping on PI 7.1 without going the BPM route?
Riyaz says:
October 29th, 2008 at 11:46 am
Hi Hennie,
1:n Multi-mapping is now possible without using BPM. You can create your 1:n message mapping and the corresponding Interface mapping in IR/ESR.
Point to note here is dont use the imported IDoc structure directly. Export the XSD of the imported IDoc structure from ESR using Tools->Export XSD menu. Edit the XSD file in notepad. Change the element name IDOC by adding minOccurs and maxOccurs parameters. e.g.
<xsd:element name=”IDOC” type=”ORDERS.ORDERS05″ minOccurs=”1″ maxOccurs=”unbounded” />
(IDoc type in your case would be different)
Now save and put this XSD file into a ZIP file and import it into ESR as an external definition. Use this structure in your message mapping and interface mapping.
In ID, when creating Interface Determination object, you can choose radio button next to Extended interface determination and specify the name of interface mapping you created in ESR as explained previously.
Thus, you can achieve 1:n multi-mapping for IDoc structures without using BPM.
Let me know if this helps.
Regards,
Riyaz
Hennie Nel says:
October 29th, 2008 at 3:54 pm
Hi Riyaz - thanks for your prompt feedback - I happened to find the same solution on SDN shortly after contacting you yesterday…Keep up the good work…Hennie
Cesar Gutierrez says:
December 6th, 2008 at 8:12 pm
Hi Riyaz
You’re the best!! …Thanks for your blog.
I have this question or problem.
I’m going to get this flat file of documents:
HEADER_01 POS_01_FA POS_01_FB
POS_02_FA POS_02_FB
HEADER_02 POS_01_FA POS_01_FB
POS_02_FA POS_02_FB
POS_03_FA POS_03_FB
HEADER_03 POS_01_FA POS_01_FB
POS_02_FA POS_02_FB
and I need generate one message for each group that belong to each document (header). This case will be 1 to n.
You think it is possible to convert this file to the following message output?:
message 1
HEADER_01
POS_01_FA POS_01_FB
POS_02_FA POS_02_FB
message 2
HEADER_02
POS_01_FA POS_01_FB
POS_02_FA POS_02_FB
POS_03_FA POS_03_FB
message 3
HEADER_03
POS_01_FA POS_01_FB
POS_02_FA POS_02_FB
I think that the solution will be able implemented using “multimapping” as in your example. Is this correct?
Is possible that I can add all the lines for each document over the “block of step” in a message and then send that message?.
If you have another solution, I would appreciate your sharing me that solution.
Thank you very much! ;D
Riyaz says:
December 8th, 2008 at 11:18 am
You can very much use multipmapping as described here. For multimapping using BPM, its must that you use transformation step to generate n messages from a single message. You may use file-content conversion or Java mapping to convert your source file to XML and then use BPM. If you want to skip BPM, you may consider use of Extended interface determination in configuration.
itisha says:
January 8th, 2009 at 2:45 pm
hi
i tried this scenario.The file gets picked up.However ,it doesnt reach the target.When i checked smq2, it showed ”permanent error in BPE inbound processing” error.Can you guide me as to how to debug the prob?
Riyaz says:
January 12th, 2009 at 9:28 am
Itisha,
Please check the return code of your BPM in transaction SXI_CACHE. If return code is not equal to zero, then your BPM process definition in IR contains syntax errors which you need to resolve.
Peter says:
February 6th, 2009 at 9:06 pm
Hi RIYAZ:
we are getting the same error like Itisha “permanent error in BPE inbound processing”. Return code in SXI_CACHE is Zero. Do you have any other ideas to fix this issue?
Thanks,
Peter
Riyaz says:
February 10th, 2009 at 9:47 pm
Hi Peter,
Run the transaction SWF_XI_CUSTOMIZING and press F9 to carry out automatic BPM/Workflow Customizing
Let me know if it helps.
Regards,
Riyaz
Chirag says:
February 28th, 2009 at 2:48 am
How do you do it so when the messages are split they are sent in the same order.
for example
the structure is
all have ( tag)
Order 1
Order 2
Order 3
But when its being sent it goes like
Order2
Order1
Order3
Is there a way to make sure it goes out the BPM the same way it is structured in the source file?
Markus says:
March 16th, 2009 at 7:12 pm
Hi Riyaz
Thanks for all of your blogs. The scenario with BPM did not work at my site - maybe I made a mistake.
But the tipp for 1:n multimapping without BPM worked. I just want to add some comments, because I had to try some possibilities, since it was not 100% clear to me.
My solution is:
- Export the XSD of the imported IDoc structure from ESRand change the element name IDOC by adding minOccurs and maxOccurs as you mentioned.
- Save and put this XSD file into a ZIP file as you mentioned.
- Then I used this ZIP file directly as target message in my message mapping.
- I did not import it as “external definition”
- In the operation mapping (interface mapping) and in the ID I used the originally imported IDoc
Nevertheless - your blogs are great. Thanks a lot
Markus
Riyaz says:
March 16th, 2009 at 7:49 pm
Hi Markus,
You are right as well. I guess you are using PI 7.1 or SP12+ version of PI7.0. I guess earlier versions do not support using zip file directly.
Markus says:
March 16th, 2009 at 7:58 pm
Hi Riyaz
You are right - I am using PI 7.1.
Lovein says:
April 21st, 2009 at 8:53 am
Hi Riyaz
I am using a multi mapping in PI 7.1 but i do not see Extended Interface determination radio button while creating Interface determination object in ID.
Am I missing something.
Thanks
Lovein
Riyaz says:
April 22nd, 2009 at 2:59 pm
Hi Lovein,
In PI 7.1, you wont see any radio button for Extended Interface determination. You dont actually need to choose it now. You can specify your operation mapping in the interface determination. If the multiplicity of your operation mapping is anything other than ‘1′, it will be processed in the same way as extended interface determination in older XI versions.
Ansh says:
July 3rd, 2009 at 10:31 am
Hi Guys,
i m using PI 7.1
In multimapping scenario, i have RFC at receiver side….the way Markus mentioned to export the XSD and change the occurences…worked for me also for IDOCs but does it work for RFC also without BPM???
As i am facing issues in doing the same with RFC at target side.
Venu says:
December 5th, 2009 at 2:10 am
is it possible to send sync send step in Block step. can you give me a reply to my mail id
Riyaz says:
December 5th, 2009 at 1:13 pm
You can have any step type in a block step. There are no restrictions.