|
Hi, I assume you used that API to get an unique record key in a file. I had recently the same issue and created therefore a program to generate an unique key with 10 digits out from the timestamp. The program runs faster than the iSeries can handle time. As the timestamp does not provide lower values than milliseconds, I had to monitor duplicate keys. My program works well, but it's created on V5R2. The advantage is to get a key which can be sorted chronological. For all who are interested in, here is the code: D GETKEY PR ExtPgm('GETKEY') D r$Key Like($Key) D §C S 1A Dim(25) CtData PerRcd(25) D i1 S 5U 0 D i2 S 5U 0 D i3 S 5U 0 D $KeyPrv S Like($Key) D $TmStmp DS D YYYY 4A D YY 2S 0 Overlay(YYYY:3) D MM 2S 0 D DD 2S 0 D HH 2S 0 D MN 2S 0 D SS 2S 0 D MS 3S 0 D Filler 3S 0 D $Key DS D Year 1A D Mon 1A D Day 1A D Hour 1A D Min 2A D Sec 2A D MSec1 1A D MSec2 1A D GETKEY PI D r$Key Like($Key) /free DOW 1 = 1; $TmStmp = %char(%dec(%char(%timestamp():*iso0):20:0)); If YY >= 10; Year = §C(YY-9); Else; Year = %char(YY); EndIf; If MM >= 10; Mon = §C(MM-9); Else; Mon = %char(MM); EndIf; If DD >= 10; Day = §C(DD-9); Else; Day = %char(DD); EndIf; If HH >= 10; Hour = §C(HH-9); Else; Hour = %char(HH); EndIf; Min = %editc(MN:'X'); Sec = %editc(SS:'X'); i1 = %div(MS:35); If i1 >= 10; MSec1 = §C(i1-9); Else; MSec1 = %char(i1); EndIf; i2 = MS - (i1 * 35); If i2 >= 10; MSec2 = §C(i2-9); Else; MSec2 = %char(i2); EndIf; If $Key <> $KeyPrv; Leave; EndIf; EndDo; $KeyPrv = $Key; r$Key = $Key; Return; /end-free ** Code Table A=10, etc. Z=34 (O is ignored) ABCDEFGHIJKLMNPQRSTUVWXYZ Regards, GEFIS Gesellschaft für Individual-Software mbH Werner Noll -----Ursprüngliche Nachricht----- Von: Titus Kruse [mailto:t_kruse@xxxxxxxxx] Gesendet: Freitag, 30. April 2004 12:25 An: Midrange RPG Betreff: CEERAN0 not allways random? Hi! We're using the API CEERAN0 (availible since V5R2) to add a random number for each record in a database file. The field with those numbers is defined 16,0 packed. It seems like all numbers in the file are different. But doing an SQL query over the 20,000 records grouping by the number shows, that very much numbers are duplicate. Why that? Maybe is the release V5R1, where the program is running the reason for this strange behaviour? Or do I use the seed parameter not correct? I've initialized it on first call with zero and use the return seed for next call and so on. Titus Kruse Software-Entwicklung IBM iSeries ESW Software Warda KG (GmbH & Co.) Telefon: +49.40.682893.22 Telefax: +49.40.682893.28 E-Mail: t_kruse@xxxxxxxxx Web: www.esw-kg.de _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.