cancel
Showing results for 
Search instead for 
Did you mean: 

Counter from the end of context

Former Member
0 Kudos

Hi friends,

we are looking for a functionality to count/increment from the end of the context.

for example,

we want to increment after "005" in this case & start counting further as 006, 007 etc.

Please share your ideas.....

or even some ideas to capture the last number of context/queue would help us to build the logic further.....

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Santosh,

Anupam is right. No need to take a For loop.

Logic is very simple.  You can check how many times that filed is populated for which you want to display the context of the counter, (No of times the filed exist +1 ) will be your result. You can create an udf and can apply it to any field.

Best Regards,

Sagarika

Former Member
0 Kudos

Hi guys,

Below is the udf to do this functionality,

public void Queue_counter(String[] BUZEI, ResultList result, Container container) throws StreamTransformationException{

for (int i=0;i <= BUZEI.length; i++)
  {
  
   if (i == BUZEI.length)
  
   {
   result.addValue(i);

   }
  }

}

-santosh.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Santosh,

                     I think this will  work

public void Queue_counter(String[] BUZEI, ResultList result, Container container) throws StreamTransformationException{

   result.addValue(""+BUZEI.length);

}

I feel for loop is not required here.

Please kindly check if this works.

regards

Anupam