Page 1 of 1

increment counter

Posted: Fri Jan 26, 2007 3:12 pm
by sdfasih
Hi,
I would like a counter to be loaded in a field.
For ex:-
First run
Record1 counter=1
Record2 counter=2 so on
Second run
Record1 counter=1
Record2 counter=2 so on
Every time job is run counter should be intialized to 1.
I used KeyMgtGetNextValue function but its not intializing counter to 1 at the start of second run.
Thanx.

Posted: Fri Jan 26, 2007 3:21 pm
by I_Server_Whale
Use @INROWNUM.

Posted: Fri Jan 26, 2007 3:23 pm
by chulett
Course not, that's not what it is for. <smack> :wink:

Use that when you need it to pick up from where it left off last time. Use one of the ROWNUM system variables:

@INROWNUM
@OUTROWNUM


Read the online help available for them so you understand the difference.

Re: increment counter

Posted: Fri Jan 26, 2007 3:33 pm
by devilsmentor
Try Modifying the routine. Open the routine and click on the 'CODE' tab. Then comment the last line in the code that reads

"Writeu NextVal On SeqFile, Arg1 Else Ans = -1". Put an asterisk * in front of it .


This routine may not modify as it is built-in, try copying the code and paste it in a new routine. Name it and OWN IT !!! :twisted:

Posted: Fri Jan 26, 2007 3:35 pm
by DSguru2B
Thats not necessary and extra work + unnecessary maintenance. As pointed out @INROWNUM and @OUTROWNUM can accomplish the task.

Posted: Fri Jan 26, 2007 3:43 pm
by chulett
Don't even think about editing that routine - create a copy and edit that version if you want to try that. Anyone already using it will thank you... actually, they won't kill you. (I feel like I may have just saved a life today) :P

Posted: Fri Jan 26, 2007 3:48 pm
by DSguru2B
That routine cannot be edited anyways. Right :roll: ?

Posted: Fri Jan 26, 2007 3:50 pm
by chulett
They all can edited unless someone specfically goes and makes them RO.

Posted: Fri Jan 26, 2007 3:54 pm
by DSguru2B
Which is the case in most places. I have always seen them as RO and hence my assumption.

Posted: Fri Jan 26, 2007 3:54 pm
by I_Server_Whale
chulett wrote:They all can edited unless someone specfically goes and makes them RO.
:o

I'm not able to edit it. :wink: . But I believe nobody made them RO. I always thought that sdk routines were un-editable. Am I assuming wrong here? :?

Posted: Fri Jan 26, 2007 4:03 pm
by devilsmentor
Alright let me take all the pain to explain you in peace.
1. Right click on routines tab in ur repository
2. choose "New Routine"
3. Name it "XYZ" and paste the code that you copied from the earlier one.
4. Now edit it as you wish, and dont forget to change the filename in which the data will be written.
5. This way no one will kill you if someone is already using it.
6. Or you can use the @INROWNUM/@OUTROWNUM as suggested.
7. And i mentioned already that you cannot edit the built-in ones, so NAME IT AND OWN IT.

This is the deal !!! You ask for one and we give you many. Cheers :D . OHHH I LOVE THIS PLACE :idea:

Posted: Fri Jan 26, 2007 4:09 pm
by I_Server_Whale
devilsmentor wrote:Alright let me take all the pain to explain you in peace.
1. Right click on routines tab in ur repository
2. choose "New Routine"
3. Name it "XYZ" and paste the code that you copied from the earlier one.
4. Now edit it as you wish, and dont forget to change the filename in which the data will be written.
5. This way no one will kill you if someone is already using it.
6. Or you can use the @INROWNUM/@OUTROWNUM as suggested.
7. And i mentioned already that you cannot edit the built-in ones, so NAME IT AND OWN IT.

This is the deal !!! You ask for one and we give you many. Cheers :D . OHHH I LOVE THIS PLACE :idea:
Hi,
I'm not the OP. :wink: I was just trying to determine whether the sdk routines are RO or NRO by default.

Posted: Fri Jan 26, 2007 4:12 pm
by devilsmentor
Yes sir, They are RO

Posted: Fri Jan 26, 2007 4:18 pm
by chulett
True, they are. Sorry. I was confused there for a moment and thinking about other routines. Keep the advise more as general advise not to make changes to existing routines unless you own them and are aware of the impact the change will have on every job that uses them.

Otherwise, you're just asking for trouble.