Topic
  • 9 replies
  • Latest Post - ‏2013-10-09T09:02:51Z by paul.brett
RPotteti
RPotteti
10 Posts

Pinned topic Multiple Input Cards to Single Out Card

‏2013-07-15T19:57:27Z |

Dear All,

I have two different application systems sending message with same format. Requirement is to combine the input messages at output.

Application 1:
<AddressDetails>
    <Address>
        <City>chicago</City>
        <State>illinois</State>
        <Country>US</Country>
    </Address>
</AddressDetails>

Application 2:
<AddressDetails>
    <Address>
        <City>indianapolis</City>
        <State>indiana</State>
        <Country>US</Country>
    </Address>
</AddressDetails>

Output:
<AddressDetails>
    <Address>
        <City>chicago</City>
        <State>illinois</State>
        <Country>US</Country>
    </Address>
    <Address>
        <City>indianapolis</City>
        <State>indiana</State>
        <Country>US</Country>
    </Address>
</AddressDetails>

I need to use two input cards for each application. but as out put is only one, I am wondering how to achieve this using WTX. How can we merge two messages to one.

Please let us know if anyone came across such situation. Thank you.

 

Updated on 2013-07-15T19:58:01Z at 2013-07-15T19:58:01Z by RPotteti
  • FormerBuckeye
    FormerBuckeye
    25 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-07-17T15:19:53Z  

    As you said, use two input cards and map the fields to a single output card that has two sets of address records.  Repeat as necessary.  You didn't mention if there is any logic linking the addresses from the two inputs aside from the next one in the file / received.

  • karthikpc
    karthikpc
    41 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-07-17T16:54:25Z  

    Hi,

    Define your Output Type tree as below:

          Out_File    

               Address_From_application1(s)

               Address_From_application2(s)

    Since Application 1 and Application 2 sends data in the same format, Structure of Address_From_application2 should be identical to Address_From_application1.

    ------

    Now you can map Input1(s) to Address_From_application1(s) and Input2(s) to Address_From_application2(s).

     

    In result, you will get one concatenated output.

    --------

    If there are any conditions, then you will have to use functional Maps.

     

    Cheers

     

  • RPotteti
    RPotteti
    10 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-07-17T18:31:11Z  

    As you said, use two input cards and map the fields to a single output card that has two sets of address records.  Repeat as necessary.  You didn't mention if there is any logic linking the addresses from the two inputs aside from the next one in the file / received.

    Hi - Thanks for the response.

    Only logic is to append addresses from all apps.

    I am attaching schema file, input files, type trees and map for your reference. If you see the functional map section I am giving input from app1 and app2 to map to functional map.

    But once the functional map is created I am not sure how to append address from app2.

  • RPotteti
    RPotteti
    10 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-07-17T18:38:52Z  
    • karthikpc
    • ‏2013-07-17T16:54:25Z

    Hi,

    Define your Output Type tree as below:

          Out_File    

               Address_From_application1(s)

               Address_From_application2(s)

    Since Application 1 and Application 2 sends data in the same format, Structure of Address_From_application2 should be identical to Address_From_application1.

    ------

    Now you can map Input1(s) to Address_From_application1(s) and Input2(s) to Address_From_application2(s).

     

    In result, you will get one concatenated output.

    --------

    If there are any conditions, then you will have to use functional Maps.

     

    Cheers

     

    Hi Karthik,

    Thanks for the response. If I use different names in the output schema, as the output is XML element tag names will be shown.

    And application team will not be able to make change at their end.

    As per your suggestion output will look like this:

    <AddressDetails>
        <Address_From_application1>
            <City>chicago</City>
            <State>illinois</State>
            <Country>US</Country>
        </Address_From_application1>
        <Address_From_application1>
            <City>Seattle</City>
            <State>Washington</State>
            <Country>US</Country>
        </Address_From_application1>
        <Address_From_application2>
            <City>indianapolis</City>
            <State>indiana</State>
            <Country>US</Country>
        </Address_From_application2>
    </AddressDetails>

    Is there any way we accomplish with out change in the names. Thanks for your response.

  • karthikpc
    karthikpc
    41 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-07-18T01:57:44Z  
    • RPotteti
    • ‏2013-07-17T18:38:52Z

    Hi Karthik,

    Thanks for the response. If I use different names in the output schema, as the output is XML element tag names will be shown.

    And application team will not be able to make change at their end.

    As per your suggestion output will look like this:

    <AddressDetails>
        <Address_From_application1>
            <City>chicago</City>
            <State>illinois</State>
            <Country>US</Country>
        </Address_From_application1>
        <Address_From_application1>
            <City>Seattle</City>
            <State>Washington</State>
            <Country>US</Country>
        </Address_From_application1>
        <Address_From_application2>
            <City>indianapolis</City>
            <State>indiana</State>
            <Country>US</Country>
        </Address_From_application2>
    </AddressDetails>

    Is there any way we accomplish with out change in the names. Thanks for your response.

    Hi,

    I used different tag names to explain you the solution correctly.

    You can make the type tree changes as follows:

       Output:
            AddressDetails(s)

            AddressDetails(s)

    Map your application1 input(s) to first AddressDetails(s) and application2 input(s) to second AddressDetails(s). 

    now you should have the output as expected.

    Cheers

     

     

  • RPotteti
    RPotteti
    10 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-07-18T14:14:51Z  
    • karthikpc
    • ‏2013-07-18T01:57:44Z

    Hi,

    I used different tag names to explain you the solution correctly.

    You can make the type tree changes as follows:

       Output:
            AddressDetails(s)

            AddressDetails(s)

    Map your application1 input(s) to first AddressDetails(s) and application2 input(s) to second AddressDetails(s). 

    now you should have the output as expected.

    Cheers

     

     

    Hi -

    I doubt if we can have a type tree with same element names.

    I tried but TX dosn't accept same name. Let me know if you made it work somehow.

    Thanks.

     

  • karthikpc
    karthikpc
    41 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-07-18T16:07:42Z  
    • RPotteti
    • ‏2013-07-18T14:14:51Z

    Hi -

    I doubt if we can have a type tree with same element names.

    I tried but TX dosn't accept same name. Let me know if you made it work somehow.

    Thanks.

     

    Hi RP,

    Create your type tree as follows. So that you can use same name under one root. In your case Output.

    Output:
           File1(0:1) --------------------------------------------------> Implicit, No initiator, No Terminator

                 AddressDetails(s)                     

           File2(0:1)--------------------------------- ------------------> Implicit, No Initiator, No terminator

                 AddressDetails(s)                    

    ------------------------

    You may get a warning:  Component1(File1) may not be distinguishable from Component 2 (File 2). Ignore this warning because, you are using this type tree as a Output structure. So this will not be an issue.

     

    Now Map input1(s) to File1->AddressDetails(s) And Input2(s) to File2->AddressDetails(s)

    Cheers,

    KPC

  • Bhoju
    Bhoju
    37 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-09-10T12:22:41Z  
    • karthikpc
    • ‏2013-07-18T16:07:42Z

    Hi RP,

    Create your type tree as follows. So that you can use same name under one root. In your case Output.

    Output:
           File1(0:1) --------------------------------------------------> Implicit, No initiator, No Terminator

                 AddressDetails(s)                     

           File2(0:1)--------------------------------- ------------------> Implicit, No Initiator, No terminator

                 AddressDetails(s)                    

    ------------------------

    You may get a warning:  Component1(File1) may not be distinguishable from Component 2 (File 2). Ignore this warning because, you are using this type tree as a Output structure. So this will not be an issue.

     

    Now Map input1(s) to File1->AddressDetails(s) And Input2(s) to File2->AddressDetails(s)

    Cheers,

    KPC

    Cowboy coding...if you are unix guy write a shell script with below code and call it from one map... call another map using run map and read file33 and you are all set.

    #File1
    lineCount=`wc -l < file1 |sed 's/ //g'`
    #Remove Trailer
    linesToPull=`expr $lineCount - 1`

    #Retrieve the lines
    head -"$linesToPull" file1 > file11

     

    #File2
    lineCount=`wc -l < file2|sed 's/ //g'`
    #Remove header
    linesToPull=`expr $lineCount - 1`

    #Retrieve the lines
    tail -"$linesToPull" file2 > file22

    cat file11 file22 > file33

     


     

  • paul.brett
    paul.brett
    554 Posts

    Re: Multiple Input Cards to Single Out Card

    ‏2013-10-09T09:02:51Z  

    A working example

    Attachments