Skip to Content
avatar image
Former Member

Count-Function in Message Mapping

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 08, 2007 at 09:19 AM

    hi,

    map like this..

    m1-- count ---\

    ADD----\

    m2-- count -/ ADD countitems(f1)

    m3 -count --/

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

    hope this helpful...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2007 at 08:58 AM

    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))

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Aug 08, 2007 at 09:20 AM

    hi christian did u understand...

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 08, 2007 at 09:02 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2007 at 09:04 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2007 at 09:42 AM

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

    it ill work ....

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2007 at 09:16 AM

    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...

    Add comment
    10|10000 characters needed characters exceeded