useOneAsMany is a very useful function to repeat header level-like data, as many time as needed at detail-level data, and still follow desired context change pattern.
It is difficult to explain this function using words and sentences only, let’s understand this function by using a easy example.
Below are the source message type and target message type. Source message type is tree structure, and target message type is flat structure.
Let’s take a look at the queue of each fields:
Map the first target field which is ‘row’ field. The ‘row’ should be repeated for each book, so map the ‘Book’ field to ‘row’. The ‘Book’ field should be mapped regardless of the context change, so add removeContext function before map to ‘row’.
Map the CatID field. The challenge here is CatID total have 3 values only, but need to map to total 6 values because total have 6 books. Each CatID need to repeat how many time correctly? and total is 6 and still match each book’s category correctly? useOneAsMany come to rescue.
We can map the CatID like below:
First input parameter supply the value will be mapped, so choose CatID.
Second input parameter supply the information for each CatID need to repeat how many time. Choose Book.
Third input parameter supply the template of context change will be used on output. Choose BookID.
Below condition must be fulfilled:
To further explain in graphical way:
Same logic applied for CatName
For BookID and BookName,is direct one to one mapping only:
Hope my explanation is clear and understandable. Cheers!