cancel
Showing results for 
Search instead for 
Did you mean: 

Count-Function in Message Mapping

Former Member
0 Kudos

Hey, trying to map following structures:

message

-m1

--m11

-m2

--m22

-m3

--m33

to

message

-m1

--m11

-m2

--m22

-m3

--m33

-f1

--countItems

The nodes m1,m2 and m3 can appear 1..unbounded. In target structure I would

like to have the numbers of all nodes (m1,m2,m3).

For example: In this source structure m1,m2,m3 appear only one time. In the

field countItems I would like to have the number 3.

I tried the count function, but it could only count the structure where I used it (in

this case: f1).

How can I count the above-mentioned nodes?

thanks

chris

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

map like this..

m1--count---\

ADD----\

m2--count-/ ADDcountitems(f1)

m3-count--/

remember u have to give the context of m1,m2,m3 to root node..

hope this helpful...

Answers (6)

Answers (6)

Former Member
0 Kudos

hi christian u have to use count function of (Statistic) in graphical mapping...

it ill work ....

Former Member
0 Kudos

Hi,

thank you all. It works. Just to understand, why I have to change the context:

If I don't do it, he will restart counting with every new context, but if I use root as

context, there is only one context query, right?

thanks to all. Points are given....

regards

chris

Former Member
0 Kudos

Correct

Former Member
0 Kudos

hi christian did u understand...

Former Member
0 Kudos

hi,

map like this....

m1--count---\

ADD----


\

m2--count-/ ADD----countietms(f1)

m3---count----/

remember .....u have to make the context of m1,m2,m3 to root node...

hope this helpful...

Former Member
0 Kudos

Use can do the same with Global counters.Here a is the dummy parameter means you can inster this UDF wherever you want to add the counter

<b>To add the counter for each element use the folloing UDF logic</b>

public String incrementCounter(String a,Container container){

//write your code here

if(a.equals(" "))

{

Object o = container.getGlobalContainer().getParameter("CNTR");

Integer ii;

if( o == null ) ii = new Integer(0);

else ii = (Integer)o;

ii = new Integer( ii.intValue() + 1);

container.getGlobalContainer().setParameter("CNTR", ii);

String temp = ii.toString();

return temp;

}

else return " ";

<b>To initialise the counter follow the following UDF logic:</b>

//write your code here

Object o = container.getGlobalContainer().getParameter("CNTR");

Integer ii = new Integer(0);;

container.getGlobalContainer().setParameter("CNTR", ii);

return "1";

Message was edited by:

Gangisetty Vijaya Bhaskarudu

former_member189387
Active Contributor
0 Kudos

Hi Christian Riekenberg ,

You use three Count functions for Three M1,M2,M3 , ( Context should be root ) then sum all the theree count values and store in The Target Countimes fileds.

Regards.,

V.Rangarajan

Former Member
0 Kudos

Use the count function on m1, m2, and m3 and add them together using the add function.

You will have to use the add function twice like this:

add( add(count(m1), count(m2)), count(m3))

Former Member
0 Kudos

Hey,

thanks for your answers.

But I still couldn't understand how to do this. I open the message mapping for field f1, but the count function could only be set on an target-element, so where to set the counters for m1,m2,m3? Do I have to insert extra fields under m1..m3?

If I do the counter would increment with every node, so if I have two times m1, in second tree of m1 a two will be insert. If I use the add function, only for these two tree the result would be three!

@Gangisetty Vijaya Bhaskarudu

Is this just one UDF? From where he knows, which nodes he have to count, if I have more than m1..m3, but only want to count this three?

@ sasitharan

same problem as mentioned above:

this doesn't work:

m1--count---\

I can't use m1 as input for count! Or do I have a wrong count function?

<b>....au damm, answered my own question. Of course. I use COUNTER and you use

COUNT!!!!!!!!!!!! I will try this with COUNT!!</b>

thanks

chris

former_member192892
Active Contributor
0 Kudos

Hey christian

assign m1, m2 and m3 from source structure to count separately for each. Now insert the add function twice

For the 1st ADD give m1 count and m2 count as input

For 2nd ADD give output of 1st ADD and m3 count as input

Assign the 2n ADD output to f1

Thanks

Former Member
0 Kudos

It is 2 UDF's one for the increment the counter and other for initialise the counter. See call the icreament_counter UDF wherever you want to increament and call Intialise_counter UDF whenever it has to be intialised.

Warm Regards,

Vijay