Introduction to Node Function UseOneAsMany.
UseOneAsMany is a node function included in SAP PI/PO and SAP Integration Suite (CPI) Graphical Mapping. UseOneAsMany allows us to repeat a value from the source message to multiple segments of the target message. Understanding how this node function operates allows us to avoid creating complex User-Defined Functions (UDFs). For example, if you need to repeat a value of a header segment into multiple repeating target elements, the node function UseOneAsMany will be your best option.
This function UseOneAsMany works the same way in both the new SAP Integration Suite (CPI) and older PI/PO.
The key to learning UseOneAsMany node function is to understand the Input variables and the rules of using them.
SAP Versions used in the illustration:
- SAP PO 7.5
- SAP Integration Suite on BTP (CPI)
Input and Output of UseOneAsMany Node Function.
UseOneAsMany has 3 inputs or arguments. The output of the UseOneAsMany function is derived from these three inputs.
- Input 1: Value from source message which should be repeated at target.
- Input 2: Number of times the first argument ‘Input 1’ should be repeated at the target.
- Input 3: Context Change of the target or output.
Rules of Using the Inputs of UseOneAsMany.
The three Input variables mentioned above should be used in a certain way for the node function to work properly. Here are the rules you need to follow when assigning these three variables from Source message.
- Rule 1: Input 1 should not contain repeating values in the same context.
- Rule 2: The total number of context changes in Input 1 and Input 2 should be equal.
- Rule 3: The number of values in Input 2 should be equal to Input 3.
Rule 1: Input 1 cannot have repeating values.
Each context of Input 1 should have only 1 value.
Input 1 is the value from the source message that we are trying to repeat in the target, therefore, each context of Input 1 should have only 1 value.
Here are some examples of how to assign the first argument of UseOneAsMany function should be assigned.
In both cases above each context has only 1 value. Values are not repeated.
In this context, values are repeated. There are two values in the same context. This is an invalid value assignment for argument 1 of this node function.
Rule 2: Input 1 and Input 2 Should Have the Same Number of Context Changes.
The number of context changes in Input 1 and Input 2 should be equal.
Here are some examples of correct and incorrect assignments of Input 1 and Input 2 of the node function.
Rule 3: Total Number of Values in Input 2 and Input 3 should be Equal.
The total number of values in Input 2 and Input 3 queues should be equal.
For example, both queues of arguments have 4 values each.
If you follow these rules when assigning the inputs, you will not come across any Queue Exceptions.
Illustration UseOneAsMany Node Function with Examples.
Let’s look at the use cases of UseOneAsMany node function with a couple of examples.
Example 1: Repeat the Purchase Order Number Using UseOneAsMany.
Let’s assume we have an interface to transfer Purchase Order information. The source message and desired target message are as follows.
Purchase Order (PONumber) should be repeated at target for each line item.
Source and Target Messages:
UseOneAsMany Mapping:
Input 1 is PONumber in Order context. Argument no 2 is assigned from LineItem and argument no 3 is assigned from ItemNo segment.
Context of the Input 1 <PONumber> is <Orders>.
UseOneAsMany Arguments in Detail:
Input 1 does not have any repeating values. Only one purchase order number for each context. The first purchase order number PO1 is repeated 3 times and the Second purchase order PO2 is repeated once.
Input 3 of the function defines the context changes of the target element. Notice that the total number of values in Input 2 is equal to the total number of values in Input 3.
Example 2: Repeat Product ID at Target Message using UseOneAsMany.
Here we have a source message with product header details. A product can have multiple names. A target message should be created with each product name and corresponding product ID (ProductID).
Source and Target Messages:
UseOneAsMany Graphical Mapping for ProductID:
Input 1 is ProductID. Input 2 and 3 are both ProductName but the third argument uses the SplitByValue function to derive the correct context.
UseOneAsMany Arguments in Detail:
Product-1 should be repeated twice, while Product-2 has only one product name. Product-3 has three different names, therefore it should be assigned to the target 3 times.
For Input 3 we use SplitByValue node function to define the desired context changes.
Notice that we have adhered to the rules 1, 2 and 3 of UseOneAsMany function. No repeated values in argument 1 which is the Product ID queue.
Argument 2 defines the number of times Product ID should be repeated. Inputs 2 and 3 contain the same number of context changes in the queue.
Inputs 2 and 3 have the same number of values.
Example 3: an Alternative Way of Mapping Product ID.
Let’s take the same source and target messages as in example 2, but use the UseOneAsMany node function differently.
Alternative Assignment of Node Function Arguments:
We can assign the arguments as below.
I would like to highlight the argument (Input) 3 in this example. Rule 3 is satisfied here as the number of values in Input 2 and Input 3 match. We use the SplitByValue after UseOneAsMany to satisfy the context change at the target.
To summarize, we can apply the UseOneAsMany node function to repeat values in graphical mapping in SAP Integration Suite (CPI) or PI/PO. In both integration platforms, it works the same way. There are three input arguments and one output in this function. Assign the input arguments to the function based on the three rules. Hope this article on the different aspects of the UseOneasMany node function is helpful to you!
You can also check my previous article on RemoveContext and CollapeContext node functions.
if you have any questions on node function UseOneAsMany, leave a comment below.
Excellent Explanation!
Keep it up:)
Thank you, Sandeep! Always great to hear that it was helpful 🙂
After this I can never get confused while using this node function. It is really, thank you so much!
Haha great to hear Sneha! Yes, the parameters of this function can be quite confusing to understand.
Excellent
Thank you!
im Happy that it helped me alot. Thanks for your habit of sharing knowledge.
Thank you, Syed! I appreciate it 🙂
Superb narration bro especially not this use one as many node functions I saw your remaining topics also great job bro keep it up. kindly please upload remaining node funtions too…
Thank you for the compliment Midhun! 🙂
Absolute excellent explanation Isuru.
Well done!
Thank you for your kind words, Rodney!
Excellent bro, this blog is really helpful to me alot with rules & clear cut example with explanation. Thank you for your effort and I am expecting more and more blogs on SAP PI/PO. I am a beginner of this SAP PI/PO this blog really helpful me
Thank you, Swetha for your kind words! 🙂
Thanks Isuru. Very helpful explanation. I just have one question that perhaps you can answer: I have a situation where the input rules may be broken but I don’t know if they are until runtime. Is there an easy way to “catch” such a situation without the whole mapping crashing?
Hi Isuru.
Nice and great blog~ It’s my 2nd time to view ths blog.
I have to say, with PO experience stronger, read your blog give me more feeling and help.
Appreciate really. Thank you.
very knowledgeable and deeply explain blog
Thank you Akshay! Are you working with SAP Integration Suite already?