cancel
Showing results for 
Search instead for 
Did you mean: 

Create a sequential number 1,2,3 for each record

Former Member
0 Kudos

Hi All,

In the Stylus Studio at the target side i have a Recordid, I have to Create a sequential number 1,2,3 for each record which i send from the Sourec side. I have to do it in xslt mapping.

Thanks & Regards

ANIL

Accepted Solutions (0)

Answers (4)

Answers (4)

aashish_sinha
Active Contributor
0 Kudos

Hi,

Use this code inside a UDF and you are done

public String SimpleUserdefined(Container container){

//write your code here

int inc = 1;

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

if (seqNum == null)

{

seqNum = new Integer (inc);

}

else

{

int number = seqNum.intValue() + inc;

seqNum = new Integer (number);

}

container.setParameter("seqNum", seqNum);

return seqNum.toString();

}

Regards

Aashish Sinha

PS : reward points if helpful

Former Member
0 Kudos

Hi venkat anil,

You can find the similare question at:

[|]

This will solves your problem

Regards

Bhanu Tiruveedula

Intelligroup.

former_member859847
Active Contributor
0 Kudos

Hi,

you can develope this via XSLT mapping with recursive function.

other wise develope an UDF with the following code.

public String seqNumber(Container container)

{

int i;

GlobalContainer global=container.getGlobalContainer();

String getnum=(String)global.getParameter("a");

if(getnum==null){

global.setParameter("a","1"); i=1;

}

else{

i=Integer.parseInt(getnum); i++;

global.setParameter("a",String.valueOf(i));

}

return String.valueOf(i);

}

regards

mahesh.

Former Member
0 Kudos

Hi,

Why is there a restriction to perform this in XSLT mapping ?

Is this the only mapping you are using ? No graphical mapping ?

If you have any graphical mapping, you can define a global variable which you increment by 1 each time.

Kind regards

Colin.

Former Member
0 Kudos

Hi ANIL,

as in XSLT (1.) variables and parameter can not be modified if they are onces set, you can only do this through recursion!

See e.g.

Recursion Example 2: Iterating on a number

in

http://www.ibm.com/developerworks/xml/library/x-xslrecur/

Regards Mario