Skip to Content
avatar image
Former Member

Message split based on Element value

Hi all,

I am looking for a way to split my source message into multiple target messages based on the Material element.

My Source and Target structures are exactly the same.

What i am trying to do is read from a order related flat file with multiple Materials and then create multiple flat files based on each material. So basically, each target file will have all the order info for EACH material.

In MM i tried to change the occurance of the target message from 1 to 0..unbounded but was not succesful.

Any help is appreciated. Please see below example source and desired target messages

Source Message:

<Header>

<GUID1>E663336789</GUID1>

</Header>

<Data>

<Order>50000890</Order>

<Material>Mat1</Material>

</Data>

<Data>

<Order>50000891</Order>

<Material>Mat2</Material>

</Data>

<Data>

<Order>50000892</Order>

<Material>Mat1</Material>

</Data>

<Data>

<Order>50000892</Order>

<Material>Mat2</Material>

</Data>

Expected Result ->First Split Message

<Header>

<GUID1>E663336789</GUID1>

</Header>

<Data>

<Order>50000890</Order>

<Material>Mat1</Material>

</Data>

<Data>

<Order>50000892</Order>

<Material>Mat1</Material>

</Data>

Expected Result ->Second Split Message

<Header>

<GUID1>E663336789</GUID1>

</Header>

<Data>

<Order>50000891</Order>

<Material>Mat2</Material>

</Data>

<Data>

<Order>50000892</Order>

<Material>Mat2</Material>

</Data>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 30, 2009 at 06:53 AM

    Yes you are right, target occurrence has to be unbounded

    mapping for target root node MT_target

    material --> sort --> collapse context --> MT_target

    GUID1 mapping

    you need to generate GUID1 as many times as many materials. useOneAsMany logic should be incorporated. Also split by value is required to manage context

    Map Order and Material accordingly so as to get same material into one message

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 30, 2009 at 06:27 AM

    Hi RodneyH

    The requirement which you have is same as is given in TBIT 41

    If you do have TBIT 41 then there is one exercise named Exercise 3: Advanced Message Mapping

    go through this exercise this contains UDF code also and same requirement as you required.

    regards

    sandeep

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 30, 2009 at 06:31 AM

    Looks like you are using the same message type used for source and as a result you may not be able to modify the occurence..

    if you are trying to change the occurence of same message then better create the anoter messsage type for target and change the occurence...also you can go to message mapping last tab and change the occurence of the same....

    HTH

    Rajesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 30, 2009 at 09:05 AM

    Hi,

    As per your requirement, I think you can use format by example, use one as many and split functions.

    example:

    FormatByExample

    1.>Order(Change the context to header)

    2.>Material

    Then the target structure will be:

    <Data>

    <Order>50000890</order>

    <order>50000892</order>

    <Material>MAT1</material>

    </Data>

    Now Split By Value Change

    Target will be:

    <Data>

    <Order>50000890</order>

    <Material>MAT1</material>

    </Data>

    <Data>

    <order>50000892</order>

    <Material>MAT1</material>

    </Data>

    Edited by: nutan champia on Dec 30, 2009 10:10 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 30, 2009 at 09:22 AM

    Hi Rodney,

    Pls try out the below mapping.It should solve your issue.

    Material >removeContexts >sort >SplitByValue(value changed) >Order_MT

    Material >removeContexts >sort >SplitByValue(value changed) >Header

    GUID-->

    Material > removeContexts -


    useOneAsMany>SplitByValue(Each Value)-->GUID

    Material--> removeContexts -->

    Data >removeContexts >

    formatByExample-->Data

    Material--> removeContexts >sort >splitByValue(value changed)-->

    Material >removeContexts >

    sortByKey--


    | formatByExample ->SplitByValue(Each Value)-->Order

    Order >removeContexts >

    Material >removeContexts >sort >SplitByValue (EachValue) >Material

    Material >removeContexts >sort >SplitByValue (EachValue) >Material

    Rgds,

    Lekshmi.

    Add comment
    10|10000 characters needed characters exceeded