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.
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
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
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.
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?
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?
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
I was interested in your response regarding 1:n without using BPM. I have an asyn/sync bridge (synchronous) scenario:
JMS->PI->RFC
whereby the 1 response from the rfc may have many items, then for each item I need to generate 1 message response back through JMS.
Can this be done without BPM, on PI 7.1?
Any thoughts appreciated.
Thanks,
Keith
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
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
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.
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?
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.
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
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
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?
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
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.
Hi Riyaz
You are right – I am using PI 7.1.
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
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.
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.
is it possible to send sync send step in Block step. can you give me a reply to my mail id
You can have any step type in a block step. There are no restrictions.
Hi Riyaz,
I’ve followed this blog and gone over and over each step many times however I only get 1 result….
Exactly like the first post by Malu…I do not receive the target files…Graphic log shows that the send step is not triggered.
There are no errors in Sxmb_moni, in fact it shows that it was processed successfully on the outbound side aswell (very strange)…
SXI_Cache shows 0 and I have re-activated it over and over to no avail…. :(
I am using PI 7.1…and tried different options in BPM (Create Transaction – checked/unchecked etc…) but still made no difference.
The mapping/Operation Mapping both when tested (OrderData node duplicated) produce the right amount of messages on the target side and target side is set as 0..unbounded as per your blog.
Please advise as I desperately want to understand what is going wrong here – Everything seems logical yet not resulting files are being produced….
Awaiting your reply,
Thanks in advance
Max
Max,
You can use trasaction SXMB_MONI_BPE to drill down to the BPM where it failed. Or Use transaction SXMB_MONI and choose process radio button and execute.
Locate your message and click on link in Process def column (starts with WS…). This will take you to the process builder. use the menu Workflow–>syntax check and make sure there are no errors/warnings. If errors/warnings, something is wrong with your BPM definition in IR/ESR.
Come back and click on PE link in Inbound/outbound column. Now from the top bar choose icon that says List with technical details or use Shift+F9. Now your steps will be displayed as a tree. Drill down to the last step where your BPM failed. Now look at the tabs in the bottom pane. You should be able to see the cause of error somewhere here.
In the container tab in the bottom pane, you should be able to see MESSAGES_IN and MESSAGES_OUT. Drilling down inside will take you to the actual message before and after the execution of the particular step. If there are no entries here, it means your message failed to move forward. Looking at the source payload then you should be able to locate the cause of error.
Let me know if this helps.
All the very best!
Regards,
Riyaz
Hi Riyaz,
Firstly many thanks for your swift reply, and I apologise for the delay in getting back to you.
I have performed the steps you mentioned…
In process def Workflow–>syntax check –
I get 1 information and 1 warning and 0 errors:
Information: Container element ORDER_CURRENT_LINE in block 0000000018 is not used
Warning: Conversion From ‘[NN.]’ to ‘[XC.ZXI_PROXY_SIAA_ORDER_1TON_0002]’ Can Cause Data-Dependent Errors
Where ORDER_CURRENT_LINE is my single line container I defined in the BPM to hold the current line.
At first it seems this is the problem however on an almost identical BPM done by a previous developer you get the same 1 info and 1 warning yet this works fine so I’m not confident this is the problem.
And then under PE link:
The BPM does not indicate it has failed at any step although as mentioned previously it finishes on (Green arrows go up to) ForEachOrder Block and not all the way to the end but again does not show any errors.
If I click on the last step (ForEachOrder block) and click container everything – its all blank.
If I click on mapping step and then on container I can see Message_in and Message_out – drilling deeper shows that message_in has the source message however message_out is empty.
I created the source XML file from the test area in the message/operation mapping and the test results looked ok so I presumed this was fine to use……
There is no mapping exceptions either….
As mentioned we have another BPM scenario which is almost identical to your example but with different interfaces and I have compared it to mine (which is based on your blog) and cannot see what is wrong!
Many thanks Riyaz
p.s if you have a personal email account I can always send screenshots..source XML file….maybe easier to see?
Thanks again.
Kind regards,
Max
Hi Riyaz,
Just an update….I have got it working at last! A silly but easily mistakable fault which was overseen…
I was using the following source message xml Originally as it is taken from the “Test” tab in OP/Message Mapping:
PB18
Distribution
123456
235645
456784
975645
763158
653487
569855
853624
This resulted under the test tab of op/message mapping being successfull however when the interface was actually run no resulting files were being produced….
So then I fixed the source message XML as below and got rid of some excess tags as below:
UK18
London
123456
235645
456784
975645
763158
653487
569855
853624
And now everything is fine! :)
It is producing the right amount of resulting files….
However if I was to test it with the above source XML under test tab in OP/Message mapping it obviously does not work which caused all the confusion in the first place!
Thanks for your help and keep up the excellent work with your site and blogs – they are simply superb and you’re a top guy for all your efforts!
All the best!
Max
Just realised the forum does not support XML tags…
but for the interest of others…
I got rid of the following tags surrounding the source payload:
ns0:Messages xmlns:ns0=”http://xxxxxxx.com/yyyyyy”
ns0:Message1
/ns0:Message1
/ns0:Messages
Regards,
Max
Wow… u’re post are very interesting. Thank you very much, this post in particular helped me a lot ^.^
Glad that you found the post useful Cristina :)
Hi Riyaz,
I just implemented the use one as many as shown by you in your blog but i am getting the following error when i tested the mapping with multiple instances of OrderData.
Too many values in the second queue in function useOneAsMany. The number of values for all contexts must be the same as the number of values for the third queue] in class com.sap.aii.mappingtool.flib7.NodeFunctions method useOneAsMany
The above example was built using XI 3.0. If you are using PI 7.1, there might be some changes in the way the function operates. I am not sure though. You might need to change the order of parameters.
hi riyaz,
i m not able to activate operational Mapping program
it throws exception
Message Mapping YDEBMASFile_Temp | urn:xyz does not match operation mapping: Occurrence of target message Message Type CustomerFile | urn:xyz in message mapping does not match occurrence of target interface Operation: CustomerFile_In | urn:xyz
please suggest wher i do mistake.
Hi Riyaz,
It would be very helpful if u post some basic materials for BPM.
Regards,
Kamali
Hi Riyaz,
I have tried to use a send synchronous step instead of the send asynchronous step in the same scenario. But the message fails in the BPM with the error message” No definition for interface <> <> operation”
Please help.
Thanks divya.
Hi Riyaz,
I implemented the same scenario, but the transformation(mapping) step in the bpm doesnt create any messages.
I think it is because the target interface is 0 to unbounded. When I make the occurence of the target interface as 1, it works fine but the for each block executes only ones and all the multiple records come as one message.
Any suggestions?