cancel
Showing results for 
Search instead for 
Did you mean: 

Merging Header, detail messages

0 Kudos

hello all..

I'm receiving 2 files from this system.and im merging them using BPM, thats just fine.

The problem is that the first file acts like a header, and can have several records...like this...

_HEADER_
1,TEXTA
2,TEXTB
3,TEXTC
4,TEXTD

and the second one can also have several records, but it can be less than the first one.

_DETAIL_
3,*XXX*
4,*YYY*

I need to the messages in a way that they endup with a father child relationship like this.

HEADER
1,TEXTA
2,TEXTB
3,TEXTC
          *XXX*
4,TEXTD
         *YYY*

Any ideas on how to accomplish this???

Points will be rewarded of course.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

Here you need key field as link between These Header and details fields. If you can use the Key fields then you can bundle the message in Transformation step and then in Message Mapping you can format the receiver side sequece of records with the help of advnaced UDFs.

Thanks

swarup

0 Kudos

Hello Swarup.

If you can be a little more specific on the Message Mapping part it would be highly appreciated.

>

> HI,

> Here you need key field as link between These Header and details fields. If you can use the Key fields then you can bundle the message in Transformation step and then in Message Mapping you can format the receiver side sequece of records with the help of advnaced UDFs.

>

> Thanks

> swarup

Former Member
0 Kudos

Hi,

In your scenario for N:1 transformation, you will have 2 different types of Message and target will be having Abstract Target File type.

Now you need to create the Advanced UDF with including the logic as below.

As per your Two source Messages one is Header and another is Details.

Both have comon ID as 1,2,3,4, etc.

Then, Your Traget side structure is

<Row>

<Item>

-


<ID>

-


<Header Data>

-


<Detail Data>

</item>

</Row>

Now in advanced UDF you need to add logic to take input as ID, Header, ID1 from Detail fields and the Data field of Detail Message type

Follow below logic in UDF with Queues.

1. Add the 1st Header field DAta as it is to ResultList

2. Now in UDF make loop on Header ID field

3. Add loop on ID1 of Details field and add the matching Data to resultList.

This way all will be added with Header detail links.

If you can share the exact structure of source and target side Messages then probably I could try to convert it in source code. But I will suggest to try the above logic.

Thanks

Swarup

0 Kudos

>

> If you can share the exact structure of source and target side Messages then probably I could try to convert it in source code. But I will suggest to try the above logic.

>

> Thanks

> Swarup

Hi... i think that i got your point, and i will try to do something like that...

if you can give me a hand with the code it will be wellcome.

Bellow is the exact source and target structure.

<ns0:">
      <Header>
         <NumAsiento/>
         <Cuenta/>
         <Fecha2/>
         <Leyenda/>
         <DebeHaber/>
         <Importe/>
         <Cantidad/>
         <Dolares/>
         <vNumItem/>
      </Header>
      <Details>
         <NumAsiento/>
         <NumItem/>
         <CentroCosto/>
         <Porcentaje/>
      </Details>
</ns0:>

and this is the desired message.

<ns0:">
      <Header>
         <NumAsiento/>
         <Cuenta/>
         <Fecha2/>
         <Leyenda/>
         <DebeHaber/>
         <Importe/>
         <Cantidad/>
         <Dolares/>
         <vNumItem/>
         <Details>
            <NumAsiento/>
            <NumItem/>
            <CentroCosto/>
            <Porcentaje/>
         </Details>
      </Header>
</ns0:>

thanks again.

Former Member
0 Kudos

Hi,

Now here the field NumAsiento is common.

For Header Fields you need to map simply one to one and for Details fields

You can try below code.

Advanced UDF -- Cache Parameters == Queue

// 1st input Header-NumAsiento as A

// 2nd input Detail-NumAsiento as B

// 3rd input Detail-NumItem as C

/// Here every time for all Detail fields you just need to change the 3rd input parameters and have to resuse the UDF

for(int i=0; i<A.length();i++)

{

for(int j=0; j<B.length();j++)

{

if(A<i>.equals(B[j]))

{

result.addValue(C[j]);

result.addContextChange();

}

}

result.addContextChange();

}

Thanks

Swarup

0 Kudos

hello

i happen to implement the code (with a few fixes)..

the main problem is that the mapping only execute for the first header element, (wich obviously fails) and it doesnt try again for the rest.

thanks in advance for any advice.

Answers (0)