cancel
Showing results for 
Search instead for 
Did you mean: 

adding of two files occurances

Former Member
0 Kudos

Hi ,

I am adding two files to one and sending to receiver in this if I get N as occurance of file1 and M as occurance of file2 then I need to get N+M occurance for received file

for exaple if I have 2 occurance and file 1 and 3 occurance for file 2 at this time I need to get 5 as occurance for receiver file

for this please guid how to achive this logic

regards

Krishna

Accepted Solutions (0)

Answers (1)

Answers (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Krishna,

It is simple. Do as follows. You need Count and ADD function to implement it.

Example: Use seperate Count for N and M. Both output of count give it to ADD. Map add output to target field.

N ---> count -


>

Give output of Count N and M as input to ADD -


> Target Field

M -


> count -


>

Former Member
0 Kudos

Hi ,

I am adding two files to one and sending to receiver in this if I get N as occurance of file1 and M as occurance of file2 then I need to get N+M occurance for received file

for exaple if I have 2 occurance and file 1 and 3 occurance for file 2 at this time I need to get 5 as occurance for receiver file

for exaple if I am having two files like this

file1

<e1>

<a1>

<b1>

</e1>

<e1>

<a2>

<b2>

</e1>

file2

<e2>

<d>

</e2>

OUTPUT FILE

<out>

<a1>

<b1>

</out>

<out>

<a2>

<b2>

</out>

<out>

<d>

<f>

</out>

for this please guid how to achive this logic

Edited by: krishnachitanya siddavattam on Feb 14, 2011 5:06 AM

Edited by: krishnachitanya siddavattam on Feb 14, 2011 5:13 AM

RKothari
Contributor
0 Kudos

Hello,

May be you can make use of UDF to populate the output node .

As per your example:

int i,j,n,m;

n = e1.length;
m = e2.length;

j = n+m;

for(i=0;i< j;i++)
{
     result.addValue(""+i);
}

-Rahul

Former Member
0 Kudos

Hi,

with this code I am unmable to get the required output...

please suggest to get the required output

Former Member
0 Kudos

Hi,

Since in your case there are 2 source files coming, so you need to use a BPM with 2 receivers for the 2 source files, one each in one of the branches of a fork, i.e you need a fork step with 2 branches. Then after the fork step , you need to insert a transformation step where you have to do the required message mapping.

After the message mapping, insert a send step which will send the output of the message mapping to the intended receiver.

In the message mapping, you need to have 2 source structures for the 2 source files i.e. there should be 2 source message types in the message mapping. Then you need to use the count node function for both the source messages to count the number of occurrences of the parent node in each of them, and then use the add node function to count the total number of occurrences of the target node and map this to the target side's parent node.

After that, simple map the child node of both the source structures directly to the child node in the target side.

MT1

<Node1>

<child1>

MT_TARGET

<NODE>

<child>

MT2

<Node2>

<child2>

Map both <child1> and <child2> with the same child as shown above for <child1> of MT1 of source

That's it. Hope this helps you

Thanks

Biswajit

Edited by: 007biswa on Feb 14, 2011 12:16 PM

Edited by: 007biswa on Feb 14, 2011 12:17 PM