Options

Adjust Cost - Item Entries [Error Division By Zero 0/0]

xchildxchild Member Posts: 22
I am getting a "Division by Zero" error message when trying to run the Adjust Cost - Item Entries in Navision 4.0.

The error occurs in Inventory Adjustment codenit number 5895 within the function CalcCostPerUnit.

The error occurs after the second IF statement and I don't really know what values the program is using to create entries in Cost Element Buffer table.

Comments

  • Options
    ara3nara3n Member Posts: 9,255
    Try to import SP1 objects and run adjust cost routine.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    ShenpenShenpen Member Posts: 386
    I am having the same error, and I'm a little bit tired of having to debug this codeunit in all versions again and again... Importing SP1 objects is not feasible, as there might have been related changes in other objects, like Item Jnl - Post Line etc.

    Did anyone debug this error before me, so I might save the effort this time?

    Do It Yourself is they key. Standard code might work - your code surely works.
  • Options
    ShenpenShenpen Member Posts: 386
    However I only got this error in a testing database, where an Item is set to Standard Costing and the standard cost = 0 so it might not happen in a production database, I hope.

    Do It Yourself is they key. Standard code might work - your code surely works.
  • Options
    David_CoxDavid_Cox Member Posts: 509
    Shenpen wrote:
    However I only got this error in a testing database, where an Item is set to Standard Costing and the standard cost = 0 so it might not happen in a production database, I hope.

    [-X You know it will happen, 9/10 of good programming is for the exception.

    Would it not be wise to debug and IF Value1 <> 0 THEN X := Value2/Value1; ?
    :P
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • Options
    ShenpenShenpen Member Posts: 386
    No, because I think this is a deeper issue - I would not assume our friends at Vedbaek made so simple errors - and if I apply such a simple fix, some other value might get wrong.

    Do It Yourself is they key. Standard code might work - your code surely works.
  • Options
    kinekine Member Posts: 12,562
    I know that there were some similar problems in 3.60, solution was to do positive adjustment of one PCS of the item which is source of the problem, run the job and do neg. adjustment of the item back to original quantity. I described the problem somewhere on the former partnerguide site but it is not available anymore and I forgot the details (but there were problem when the system was calculating history of the stock and in some point the system calculated that there is 0 stock and tried to divide the amount with this quantity...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    EugeneEugene Member Posts: 309
    still getting the same error in NAV5SP1
    CalcCostPerUnit(VAR OutbndValueEntry : Record "Value Entry";OutbndCostElementBuf : Record "Cost Element Buffer";ItemLedgEntryQty : DeciMAL...
    WITH OutbndCostElementBuf DO BEGIN
      IF (OutbndValueEntry."Cost per Unit" = 0) AND ("Remaining Quantity" <> 0) THEN
        OutbndValueEntry."Cost per Unit" := "Actual Cost" / (ItemLedgEntryQty - "Remaining Quantity");
      IF (OutbndValueEntry."Cost per Unit (ACY)" = 0) AND ("Remaining Quantity" <> 0) THEN
        OutbndValueEntry."Cost per Unit (ACY)" := "Actual Cost (ACY)" / (ItemLedgEntryQty - "Remaining Quantity");
    END;
    

    What if i add in the beginning
    IF ItemLedgEntryQty - OutbndCostElementBuf."Remaining Quantity" <> 0 THEN
    

    i just wonder if the logic of the code that gives me ItemLedgEntryQty is ok or not. BEcause if it is not then it can lead to wrong results. And if it ok maybe i should assign
    OutbndValueEntry."Cost per Unit (ACY)" := "Actual Cost (ACY)"
    
    and not leave it 0 ?
  • Options
    hawkeyehawkeye Member Posts: 51
    I have the same problem in 2009 R2 - when i´m doing a positive adjustment in an Item Journal Line. I´m considering simular code as Eugene but don´t know if this will cause me any other problems.

    Anyone tried this?

    BR Hawkeye
  • Options
    absolutelyfreewebabsolutelyfreeweb Member Posts: 104
    running into this now on a 2009 system. was there ever any proper resolution to this?

    hawkeye and Eugene how did you get past it?
Sign In or Register to comment.