Table Concurrency

Hi, I have created a new process to create invoices from the program. But when I try to run the process concurrently with another user who is creating invoices from the Sales Invoices Form, I encounter the Error for the Document Dimension table which terminate the process immediately: " The Document Dimension Table has been locked by USERID. Please try again later." Therefore, I added code to the Standard Codeunit “Dimension Management” → “DimDoc.LOCKTABLE(TRUE);” whenever there is an insert, modify or delete code for Document Dimension table. But the concurrency still does not work. When I run the debugger to track on the break points, I found that the code terminates at the “DimDoc.LOCKTABLE(TRUE);” for the Concurrency Error. Since I have initiated a wait on Table Locking, the system should wait till the first user has finished with the process and then proceed to the second user. There should have been no termination in the interim. I suspect it could be due to deadlocks, but I have no solution to this. I need help desperately.

Hi Elena, my first thought is that you have a problem with the whole structure of your code, but without more details, I can’t offer to much more on that front. I’d also like to know if this is C/side or sql. what I can guess is happening, is that you are creating a asles header and line, then calling some code that triggers the creation of dimensions. I think your short termn solution (without restructuring the code), is to lock the dim tables before you create the sales header, then perfom a commit when finished … something like repeat dimdoc.locktable; salesline.locktable; salesheader.locktable; insertsalesheader; dosalesheadermods; salesheader.modify; repeat insertsalesline; dosaleslinemods; salesline.modify; dodimensionstuff; until alllinescreated; updatesomecounter; commit; until createdlastinvoice; in this case it should be the other user that gets the error, not you. You may need to use the locktable with paramaters it just depends on exactly what you want to happen. i hope this helps, if not, please give more information.

Hi, we have a similiar problem in the standard posting routine (Navision SE3.10). We cannot post an sales order at the same time that we for instance create sales orders. We have found that is due to deadlocks (two routines locking in different order causing eachother to abort). In the Tools CD there is a map called Performance Troubleshooting Guide. Here you can find documentation and fobs over how to find these deadlocks. In short you specify which locking order you should have, then run this fob to see all places where the locking order is broken. Regards Daniel

the basic rule, is start at the bottom and work up. i.e. you don’t want to lock a sales header if the lines are not yet locked, since another user may lock the lines before you try to lock them after locking the header. The tools help, but its better to think about locking long before you design, i.e. way way before you are testing code.