Skip to Content
avatar image
Former Member

Counter not working

Hi All,

I have 10 records in the same level and in each record there is a field "LineNumber" and this is a incremental field, I have used counter to increment it starting from 1, but in all the cases records the field value is "1", it's not incrementing. I have also tried an UDF, but it also gives the same result.

Do you have any clues????

Regards,

Bharani

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Sep 04, 2008 at 10:23 AM

    Hi,

    Using counter we can achive your requirement.Its because of context problem.

    Change the context parent node..

    Like,

    you have a structure,

    <Node>

    <Node1>

    <Field>

    Then change the context to Node.

    Regards,

    Prakasu

    Edited by: prakasu on Sep 4, 2008 12:24 PM

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 10:23 AM

    Hi Bharani,

    Instead of using a counter, you can use the Statistic Function called Index. It can also be manipulated to count contexts.

    Hope this helps.

    Regards

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 10:36 AM

    Hi Prakasu,

    But the counter is not related to any of the source field....

    I have records...based on certain conditions records are populated

    Record 1

    -


    counter -> LineNumberField

    Record 2

    -


    counter -> LineNumberField

    Record 3

    -


    counter -> LineNumberField

    Record 4

    -


    counter -> LineNumberField

    So I don't have the scope of changing the context anywhere.

    Regards,

    Bharani

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 12:08 PM

    Hey use this,

    int inc=1;

    Integer seqno=(Integer) container.getParameter("seqno");

    if(seqno==null)

    {

    seqno = new Integer(1);

    }

    else

    {

    int number=seqno.intValue()+inc;

    seqno=new Integer(number);

    }

    container.setParameter("seqno",seqno);

    return seqno.toString();

    thanks

    hemant

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 12:15 PM

    Hi,

    Is the counter increment value is 1.

    The problem might be because of the context level.

    Can you paste the source and target structure that is used.

    Thanks

    SaNv...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 12:55 PM

    Check with the below UDF

    use cache parameter value and no inputs to UDF

    public String increase(Container container)
    {
      //write your code here
    i = i + 1;
     String c;
    c  = Integer.toString(i);
    return c;
     }

    Here i is a global variable initialized to 0.(goto Edit java section fill in global variable section and initialization section)

    increase--->target

    Edited by: malini balasubramaniam on Sep 4, 2008 3:12 PM

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 01:24 PM

    Hi,

    As is replied earlier the issue is because of the context.

    Do paste your source and target structure.

    Also try this UDF.

    Source(to get the no of occurance) ---> remove context ---> UDF -


    > SplitByValue ---> Target

    UDF(of type queue):

    public void test1(String[] a,ResultList result,Container container)

    {

    for(int i=1;i<=a.length;i++)

    {

    String temp = Integer.toString(i);

    result.addValue(temp);

    }

    }

    Thanks

    SaNv...

    Add comment
    10|10000 characters needed characters exceeded