on 07-15-2011 4:39 AM
Hi gurus,
i want to create the auto-increasing counter for the records in my message mapping.But during my testing,the sequence number always pops up "1" which means it don't calculate based on the cache value. The code as below:
=========================================================================================
public String Counter(Container container){
GlobalContainer gcontainer = container.getGlobalContainer();
Object o = gcontainer.getParameter("counter");
Integer iSeq ;
if(o == null)
{
iSeq = new Integer(1);
}else
{
iSeq = (Integer)o;
iSeq = new Integer(iSeq.intValue() + 1);
gcontainer.setParameter("counter",iSeq);
}
return iSeq.toString();
}
==========================================================================================
can anyone shed light on this?
Thanks in advance.
Hi Rajesh,
Small change in your code. please see the below code
public String Counter(Container container){
GlobalContainer gcontainer = container.getGlobalContainer();
Object o = gcontainer.getParameter("counter");
Integer iSeq ;
if(o == null)
{
iSeq = new Integer(1);
gcontainer.setParameter("counter",iSeq);
}else
{
iSeq = (Integer)o;
iSeq = new Integer(iSeq.intValue() + 1);
gcontainer.setParameter("counter",iSeq);
}
return iSeq.toString();
}
Regards,
Naga.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh,
Have you solved the issue?? same issue we are facing even using UDF the value was not incrementing for the next execution. Could you suggest what changes need to be done.
Thanks In Advance.
Regards,
Anusha Penneru
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As Harish has already mentioned, use the index function for this. Make sure that you remove all context changes by either selecting the context at the root level or using the RemoveContext function before using the index function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh,
You can use the standard funtion index for this requirement.
Regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh,
You can use this simple UDF to achive your requirement.
This is an Advance UDF with execution type all values of Queue
Here input value is input field for which you want to create sequence number in target.
public void generateSequenceNo(String[] Value, ResultList result, Container container) throws StreamTransformationException{
int temp = 1;
// Loop to assign sequence numbers starting from 1
for (int i = 0;i<Value.length;i++)
{
result.addValue(++temp);
}
}
Hi rajesh
\
anothr smart option.
in meesage mapping editor under function tab
add the below code
Under Attributes and Methods Integer iSeq ;
Under init iSeq = new Integer(0);
Then UDF:
public String Counter(Container container){
iSeq = iSeq+1;
return iSeq.toString();
}
Edited by: Debashish on Jul 15, 2011 9:09 AM
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.