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.useOneAsMany_MM

The objective of this mapping is to convert all book in tree structure into book in flat structure. Below is the test data and the expected output result:
useOneAsMany_tree_data_and_flat_data

Let’s take a look at the queue of each fields:

Source Field Display Queue Information
CatID useOneAsMany_queue_CatID Total 3 context changes
total 3 values
each context contain one value
CatName useOneAsMany_queue_CatName Total 3 context changes
total 3 values
each context contain one value
Book useOneAsMany_queue_Book Total 3 context changes
total 6 values
each context contain different value count (3, 1, 2)
BookID useOneAsMany_queue_BookID Total 6 context changes
total 6 values
each context contain one value
BookName useOneAsMany_queue_BookName Total 6 context changes
total 6 values
each context contain one value

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’.
useOneAsMany_MM_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:
useOneAsMany_MM_CatID

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:
useOneAsMany_queue_CatID_useOneAsMany
To further explain in graphical way:
useOneAsMany_queue_CatID_explained
Same logic applied for CatName
useOneAsMany_queue_CatName_useOneAsMany
For BookID and BookName,is direct one to one mapping only:
useOneAsMany_MM_BookID_BookName
Hope my explanation is clear and understandable. Cheers!

useOneAsMany Explained in Easy Example
Tagged on:                 

17 thoughts on “useOneAsMany Explained in Easy Example

  • January 20, 2015 at 5:31 pm
    Permalink

    Beautifully explained node function useOneAsMany. Really appreciate your efforts.
    Thank You.
    Regards,
    Ajit

    Reply
    • January 28, 2015 at 10:52 pm
      Permalink

      Hi Ajit,
      Thanks for your kind words. 🙂
      Regards,
      Yee Loon

      Reply
  • May 19, 2015 at 5:25 am
    Permalink

    Really awesome and easy to understand. Thank you.
    Keep the good work.
    Regards,
    Sachin

    Reply
  • August 18, 2017 at 3:45 am
    Permalink

    Great Explanation. Really helpful. Thank You!!

    Reply
  • September 12, 2017 at 7:40 am
    Permalink

    Hi,
    This is a great explanation.
    Its very clear and detailed.
    Thanks for all the effort.
    Regards
    Anurag

    Reply
  • September 27, 2017 at 4:22 pm
    Permalink

    Good Explanation 🙂

    Reply
  • February 6, 2018 at 11:05 pm
    Permalink

    Awesome Explanation….Keep rocking…. 🙂
    Regards,
    Venki

    Reply
  • August 13, 2018 at 3:56 pm
    Permalink

    thanks forexplaing in detail.

    Reply
  • November 11, 2019 at 8:19 pm
    Permalink

    very good. thanks a lot!

    Reply
  • December 1, 2019 at 9:33 pm
    Permalink

    Verry good work, You really helped me to understand this subject
    thanks a lot

    Reply
  • December 27, 2020 at 7:08 am
    Permalink

    Thank you very much. Crystal clear. If someone wants to know how to use the function have to “read” this blog!!!

    Reply
  • May 24, 2021 at 11:54 pm
    Permalink

    very nice explanation

    Reply
  • Pingback:collapseContext and formatByExample to Convert Flat Structure to Tree Structure – Integration Learn

  • January 10, 2024 at 6:19 pm
    Permalink

    Very well explained!!

    Reply

Leave a Reply to Anurag Cancel reply

Your email address will not be published. Required fields are marked *