cancel
Showing results for 
Search instead for 
Did you mean: 

Generating Sequence Number

Former Member
0 Kudos

I am trying to Generate Sequence Number using a user defined function. For some reason it is not working. I got this piece of code from one of the training manuals.

//write your code here

int inc = 1;

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

if (seqNo == null) {

seqNo = new Integer(inc);

}

else {

int number = seqNo.intValue() + inc;

seqNo = new Integer(number);

}

container.setParameter("seqNo",seqNo);

return seqNo.toString();

Any help appreciated.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Michael

If you want only a sequence number to be attached then you can use the function "Counter" in airthmetic function. Then you can specify the start value and the increment value.

Also can you tell us what for exactly you are using this?

---Satish

former_member206604
Active Contributor
0 Kudos

Hi,

If your sequence number is for the record number then you can use a built in function called <b>index</b> you can find this under <b>stastics</b>.

It would be fine if you explain you whole scenario, so I can help you better.

Thanks,

Prakash

Former Member
0 Kudos

I have a structure that has a REC_NO in each substructure.

root

H01 - REC_NO

H02 - REC_NO

H03 - REC_NO

H02 and H03 can occur multiple times. I would like to increment all the way from H01 - H03.

I think index looks good but it expects an input.

Former Member
0 Kudos

Hi Michael,

You can just give a constant as input and then trigger standard function Index.

Regards

Vijaya

Former Member
0 Kudos

What value do you give the constant.

In my case say if the data has

H01

H01 - RECNO 1

H02

H02 - RECNO 2

H02

H02 - RECNO 3

H03

H03 - RECNO 4

H03

H03 - RECNO 5

I have to generate sequence numbers as above

The

Former Member
0 Kudos

Michael

You use counter function for this recno. Then you give start value as 1 and increment as 1. By this I think your issue can be solved.

---Satish

former_member206604
Active Contributor
0 Kudos

Hi,

Yes you can solve this by counter as said by Satish or you can use Index to which your source will be any key field that coresponds to that particular record. Can you give us the source and the target structure.

Thanks,

Prakash

Former Member
0 Kudos

Count does not work as H01 , H02 , H03 are different nodes.

former_member206604
Active Contributor
0 Kudos

Hi,

Try using <b>Index</b> and you need to give some source node as the input to Index. It will be easy for us to help you if you could post us the source and the target structure and explain in detail.

Thanks,

Prakash

Former Member
0 Kudos

HI Michael,

Just take H01 as the sender node and change the context of htis node for the whole structure and then map this as input to fucntion index and to your receiver.

Do this for all the fields.

eg.

root

header1

detail1

header2

detail2

header3

detail3

root

Just take detail1-indexreceiver

change context of detail1 to root.

regards

Vijaya

former_member206604
Active Contributor
0 Kudos

Hi Michael,

Yes exactly do what Vijaya said it will work fine. As she said take care of the node context, set it to the root node.

Thanks,

Prakash

Former Member
0 Kudos

I just want a sequence number for my target. No source is required.