To repeat a target field in message mapping, we can use one-to-one mapping, CopyValue, Graphical Variable and useOneAsMany.
Example 1: -
Let’s try one-to-one mapping and CopyValue in below example. Both one-to-one mapping and CopyValue fail to produce correct result.
Using Graphical Variable / useOneAsMany, produces correct result.
Example 2:-
Using Graphical Variable will not produce correct result, in below example. Using useOneAsMany, produces correct result.
So, how to choose between Graphical Variable and useOneAsMany?
If input hierarchy is maintained in output, choose Graphical Variable. If input hierarchy is becoming flat in output, choose useOneAsMany. FYI, Graphical Variable is simple and efficient at runtime (Link page 8).
Below diagram guides on, choosing between Graphical Variable and useOneAsMany.
FYI. How to use Graphical Variable (slide 9 in this demo). Variables in the Target Structure. useOneAsMany. copyValue.