Hi Ruining,
Well just to give you an idea how to catch error (or avoid raising an error blocking your processing task) is to use the OnRun method of a CodeUnit:
CLEARLASTERROR();
If Not Codeunit.RUN Then begin
MESSAGE('The last error was: ' + GETLASTERRORTEXT);
logTable.ErrMsg := GETLASTERRORTEXT;
logTable.Insert;
end;
So putting all your code that could generate an error inside the onRun function of a codeunit and using the code above permits you to avoid blocking your processing task. The GETLASTERRORTEXT as well permit you to get the last error generated in the Run function. You can use this for example if like keep a trace of errors i a log table,...
--
Even if you use this method it won't resolve your locking table problem because you could have many tansactions (inserting, modifying,..) of much tables inside the Run method that makes it very complicated to roll back.
--
What I have in mind now that I can suggest you to use is the Sleep function. Let's imagine that when you execute this code:
............
ItemRec.insert();
you get the error saying the table Item is locked. So to avoid that I suggest you to use this code instead:
..........
If not ItemRec.Insert() then begin
Sleep(3000); // equivalent to 3 seconds
If not ItemRec.Insert() then begin
Sleep(3000); // equivalent to 3 seconds
If not ItemRec.Insert() then begin
Sleep(3000); // equivalent to 3 seconds
ItemRec.Insert(); // this will raise the error if unable to insert, to avoid it use If condition
end;
end;
end;
I hope this could help you and give you an idea.
--
Don't hesitate If you need more details or explanations.
-------------
Please verify my answer if you find my answer helpful. Doing so you'll show other community members that there was found a solution and you credit my help.
-------------
Best Regards,