Adjust Cost Error for SQL Navision 3.60

If I start Adjust Cost report in Navision 3.60 for SQL then I get message “Another user has modified the record for Item …” For Native server all is ok. Error appears in codeunit 5804 in UpdateUnitCost on MODIFY command. WITH Item DO BEGIN IF NewStdCost <> 0 THEN "Standard Cost" := NewStdCost; IF NOT UpdateUnitCostItem(Item,RecalcStdCost) THEN IF LastDirectCost <> 0 THEN "Unit Cost" := LastDirectCost; IF LastDirectCost <> 0 THEN "Last Direct Cost" := LastDirectCost; VALIDATE("Price/Profit Calculation"); **MODIFY;** What is a problem? [:(] …[ code] … [ /code]

Do you have any users defined ? If so, do they access the program in the same time, with the same user id ? If this is happening, Navision might be a little confused… You should solve this first [:D] and then try again… Good luck!

This happens for two reasons: 1. An optmimistic concurrency check: another user has indeed changed the record in another session, between the read and modify of your sesssion, just as the error is saying. 2. A C/AL programming error is present. For the SQL version, when you MODIFY a record, that record must have been read from the table in order to read the timestamp value that accompanies it. Then this concurrency check is done against the correct timestamp. However, the code itself can modify a record using a second and subsequent variable, updating the timestamp and causing the timestamp read from the first variable to be ‘old’. Then the first variables does a MODIFY but the timestamp in the table is greater now - giving this error. I have seen this error in the 3.60 app, perhaps in the same place you are reffering to, and there may be a hotfix for it…

According to Navision, the following change in codeunit 5895 should do the trick: Old Code: IF (CostingMethod <> CostingMethod::Standard) AND (Item."No." <> '') THEN ItemCostMgt.UpdateUnitCost(Item,'','',0,0,TRUE,FALSE,FALSE); New Code: IF (CostingMethod <> CostingMethod::Standard) AND (Item."No." <> '') THEN BEGIN Item.LOCKTABLE; Item.GET(Item."No."); ItemCostMgt.UpdateUnitCost(Item,'','',0,0,TRUE,FALSE,FALSE); END; I haven’t tested it yet and since it’s not an officially released fix by Navision (as far as I’m aware) I wouldn’t recommend putting it in any live client database until Navision officially releases it in a hotfix/improvement or a client experiences the problem in their live database …[ code] … [ /code]

Thanks all It’s a damn concurrency I make additional Item.GET and all works properly [^]