Unique sequential numbers for Web-based form

This code calulates a totally unique, sequential, 8 digit number for Web forms.

This code calulates a totally unique, sequential, 8 digit number for Web forms.

This number also allows for forms that are created at the same time. All forms will be unique accoring to the calulation below.

REQUEST NUMBER CALCULATION

This request number formula will produce a unique sequential number for each request.
EXAMPLE:

1A44-316I

1  A  44 - 316  I   
A  B  CC - CCC  D


A = The current month. 
The month of October is X.
The month of November is Y.
The month of December is Z.
October , November , December are represented by letters because they are 
2 digit months. B = The current day. Two digit days are represented by letters. Example: day10=A , day11=B , day12=C etc. CC-CCC = Number of seconds past 12:00 AM of the current day. There can be up to 86400 seconds in a day. So there needs to be 5 digits to account for. D = Random Alpha Character. To distinguish requests created at exactly the same second. 1 A 44-316 I 1=Month(January) A=Day(10) 44-316=Time(12:18:36 or 43200+1080+36) I=random alpha Code: REM "REQUEST NUMBER CALCULATION"; REM ; REM "This request number formula will produce a unique sequential number
for each request."; REM ; REM ; REM "1A44-316I = January, 10 12:18:36 PM = 43200+1080+36"; REM ; REM "1 A 44 - 316 I"; REM "A B CC - CCC D"; REM ; REM ; REM "A = The current month. "; REM "The month of October is X."; REM "The month of November is Y."; REM "The month of December is Z."; REM "October , November , December are represented by letters because they are
2 digit months."; REM ; REM ; REM "B = The current day."; REM "Two digit days are represented by letters."; REM "Example: day10=A , day11=B , day12=C etc."; REM ; REM ; REM "CC-CCC = Number of seconds past 12:00 AM of the current day."; REM "There can be up to 86400 seconds in a day. So there needs to be 5
digits to account for."; REM ; REM ; REM "D = Random Alpha Character."; REM "To distinguish requests created at exactly the same second."; REM "Get the current year."; year:=@Text(@Year(@Now)); REM "Get the current month."; month:=@Right( ("0"+@Text(@Month(@Now))) ; 2); REM "Get the current day."; day:=@Right( ("0"+@Text(@Day(@Now))); 2); REM "Get the current seconds past 12:00 AM this morning."; start:=@TextToTime(month+"/"+day+"/"+year+" 00:00:00 AM"); fin:=@Now; csc:=@Text((fin-start)); REM "Make the month a 1 digit character"; m := @If( month = "10" ; "X" ; month = "11" ; "Y" ; month = "12" ; "Z" ; @Right(month;1)); REM "Make the day a 1 digit character"; d:=@If( day="10";"A"; day="11";"B"; day="12";"C"; day="13";"D"; day="14";"E"; day="15";"F"; day="16";"G"; day="17";"H"; day="18";"I"; day="19";"J"; day="20";"K"; day="21";"L"; day="22";"M"; day="23";"N"; day="24";"O"; day="25";"P"; day="26";"Q"; day="27";"R"; day="28";"S"; day="29";"T"; day="31";"U"; day); REM "Add leading zeros for the current seconds past 12:00 AM if necessary.";
c:=@Right("0000"+csc;5); c1:=@Left(c;2); c2:=@RightBack(c;2); REM "Calculate a random alpha character."; rand:=@Right(@Unique;1); r:=@If( rand = "0" ; "A"; rand = "1" ; "B"; rand = "2" ; "C"; rand = "3" ; "D"; rand = "4" ; "E"; rand = "5" ; "F"; rand = "6" ; "G"; rand = "7" ; "H"; rand = "8" ; "I"; rand = "9" ; "J";rand); REM "Display request number..."; m+d+c1+"-"+c2+r
This was first published in January 2002

Dig deeper on Domino Resources - Part 7

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close