Transaction numbers used twice: Random number generator bug?

davidecdavidec Member Posts: 63
Hello!

I have a problem unapplying customer entries, about which I posted another topic. I write this because something else happens in the same context and it looks odd (and could be the reason for my other problem)...

I'm using NAV 4SP3 IT based on SQL Server with a DB of about 10GB: If I unapply two customer entries, say a payment and an invoice, the transaction number assigned to the creation of the new payment is the same as some other previously used, maybe even performed by some other user... Is this normal? Shouldn't transaction numbers be unique? For instance, if I try to reverse the payment transaction, all other entries are included as well, which is not what one wants...

I had a similar problem on the same system when generating random numbers: A codeunit which worked on every other system did in fact always generate the same numbers within a short timespan (I didn't solve the problem, I found a workaround).

Has any of you any idea of what's happening?

Thank you in advance!

PS: Users access the DB by first connecting via terminal server to one PC where the client is installed. The SQL Server resides on another PC

Comments

  • kinekine Member Posts: 12,562
    I will just react to the part about random numbers. Number on PC are not random, they are pseudo-random.They are based on some number (seed), which is in most cases generated based on time (somehow). It means, if you want really random numbers, you need to set random seed first (through RANDOMIZE), else you will get same numbers (same seed means same number row). On this forum are some tips how to generate good random seed to get random numbers, e.g. based on numbers from randomly generated GUID ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • davidecdavidec Member Posts: 63
    Hello!

    Kine, thanks for your prompt reply. Sorry if I didn't express myself properly: I've been a "normal" developer long before becoming a "NAV" developer, so I know that machines can't generate real random numbers and I know some algorithms to generate them from a seed: Fortunately that's not issue today, nor was it when I met the first "issue" on the system I mentioned: using random numbers was just a trick, so I decided to to it the clean way, instead. I still don't need random numbers... :)

    The reason why I mentioned random numbers in my post is the way transaction numbers are generated in NAV: In the system I'm having issues with, there's apparently no criterion in their order (later entries have lower transaction numbers and vice versa), so I thought they were generated randomly (otherwise, I can't find the codeunit which generates them). And here lies the problem: at least when I unapply customer entries, already used Transaction Numbers are reused when creating the new entries... Is this normal or shouldn't they be globally unique? This repetition causes problems I posted in another topic...

    Does any of you have any idea of what might be happening? Or do you know the codeunit which generates transaction numbers? ;)

    Thanks again in advance!
  • kinekine Member Posts: 12,562
    I know that it is not the problem...

    Ok, the Transaction No. is generated in the InitCodeunit function of the Codeunit 12. It will find last GL Entry and take the transaction no. +1 from this entry. it means it would be continuous growing row if all is going well, each posting have own transaction no. If it is not true, there is some way when this number is cleared or the InitCodeunit function is not called etc.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • davidecdavidec Member Posts: 63
    If it is not true, there is some way when this number is cleared or the InitCodeunit function is not called etc.
    I know that it is not the problem...

    Hm, not called... I guess that's why I didn't find where the number is generated... ;)

    Thank you very very much, I'll take a look!
Sign In or Register to comment.