Division by zero

vijayandersonvijayanderson Member Posts: 207
Hi Friends,

I got the following error when Invoice has been posted "Division by Zero " 0/0, when sale order is posted.

Regards,
vijay

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Hi Friends,

    I got the following error when Invoice has been posted "Division by Zero " 0/0, when sale order is posted.

    Regards,
    vijay

    Interesting. Is this 3.56? I never knew that this version was even released in India.

    Either way this looks like an error in the Invoice Report, probably some code to print the unit cost by dividing the Amount by Quantity.

    Its going to be very hard to fix though, because you will find it very difficult to even find a developer with a license.
    David Singleton
  • vijayandersonvijayanderson Member Posts: 207
    No. its 4.0 (sp3) with all Hot fixes.
  • garakgarak Member Posts: 3,263
    then u are in the wrong forum.

    Is there are some customized code?
    Did you have checked the source with using the debugger?
    Do you make it right, it works too!
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'Navision DOS' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • vijayandersonvijayanderson Member Posts: 207
    yes i have run the debugger, it goes to code unit 6500.
  • ssinglassingla Member Posts: 2,973
    Is the database customized. Start the debugger and check where the error comes. I remember the error used to come when I started using upgraded 4.0 sp3 database, but now i do not remember the solution/cause. Some details might help to remember.
    CA Sandeep Singla
    http://ssdynamics.co.in
  • garakgarak Member Posts: 3,263
    yes i have run the debugger, it goes to code unit 6500.

    And where there? Is there some customized source or is it all "standard".
    Copy the codesnippes and the functionname here for a better help.

    Regards
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,304
    yes i have run the debugger, it goes to code unit 6500.
    So you have the debugger on, you have traced the error, you know where it is. What exactly is your question then :-k
  • garakgarak Member Posts: 3,263
    DenSter wrote:
    What exactly is your question then :-k

    Maybe how he can prevent the division by zero .....
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,304
    garak wrote:
    Maybe .....
    Exactly my point. There is no question, and everyone is guessing what the problem is.
  • SavatageSavatage Member Posts: 7,142
    Just have to add the 0 catch to the code

    if C=0
    then a=0
    else A := B / C
  • DenSterDenSter Member Posts: 8,304
    or:
    IF C = 0 THEN 
      C := 1;
    A := B/C;
    
  • David_SingletonDavid_Singleton Member Posts: 5,479
    or in light of how much infromation the OP has given so far:

    A := RAND(1);

    which save a lot of lines of code. \:D/
    David Singleton
  • DenSterDenSter Member Posts: 8,304
    Thanks David, you made me spray my water on my screen :mrgreen:
  • garakgarak Member Posts: 3,263
    David , :lol::lol::lol::lol::lol::lol: , now on my screen is also water :lol::lol::lol:
    Do you make it right, it works too!
  • kinekine Member Posts: 12,562
    edited 2009-02-04
    Problem is that if you make some "Workaround" to not have this error, you can be in big troubles, becuase you haven't solved the core problem, just the effect. And it can lead e.g. to some costing problems in future (just example). In most cases, when you get this error, it means that the data are wrong. In cases, when you can assume, that the divider will be zero, there will be appropriate condition. If it is not there, you can assume that when the divider is 0, there is some problem because it cannot be zero from the logic.

    Conclusion: just think about the meaning of the code, do not just blindly make "workaround" to prevent this error. There can be deeper problem in this. 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • SogSog Member Posts: 1,023
    With Rand as a user defined function which has this code: http://xkcd.com/221/
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • DenSterDenSter Member Posts: 8,304
    kine wrote:
    Problem is that if you make some "Workaround" to not have this error, you can be in big troubles, becuase you haven't solved the core problem, just the effect.
    =D> Finally some intelligence in this thread :mrgreen:
    It's true, rather than write code to blindly prevent the division by zero, it would be better to put in a different, more descriptive, error message. We're so bent on "division by zero should not happen", but forget the underlying problem.

    If the process needs to divide by a quantity, and that quantity is 0, the original line is not correct, so the error message should still come up, but with a descriptive message (something like "there is nothing to divide" :mrgreen: )
  • SavatageSavatage Member Posts: 7,142
    kine wrote:
    Problem is that if you make some "Workaround" to not have this error, you can be in big troubles, becuase you haven't solved the core problem, just the effect. And it can lead e.g. to some costing problems in future (just example). In most cases, when you get this error, it means that the data are wrong. In cases, when you can assume, that the divider will be zero, there will be appropriate condition. If it is not there, you can assume that when the divider is 0, there is some problem because it cannot be zero from the logic.

    Conclusion: just thing about the meaning of the code, do not just blindly make "workaround" to prevent this error. There can be deeper problem in this. 8)

    Perfect example is we were trying to show on a form the actual quantity on hand QOH / Item."Sales Unit Of Measure".
    Once in a while we get the division error. So as stated above the deeper problem was that someone was not filling in the UOM fields. So the next step was making the UOM mandatory. Therefore solving the deeper underlying problem.
Sign In or Register to comment.