Need explanation of the error

Reedberg
Member Posts: 68
Hello all!
I have a report with such code:
CallUpdateItemG.RUN(Item) - doesn't cause an error
IF CallUpdateItemG.RUN(Item) causes an error.
What is the difference?
P.S.:
I already searched the forum and found this post very usefull: http://www.mibuso.com/forum/viewtopic.php?t=38919&f=23
However it doesn't describe why error occurs if I handle boolean return value of RUN(Codeunit).
Thanks!
I have a report with such code:
IF ErrorHandlingG = ErrorHandlingG::"Skip error" THEN BEGIN IF NOT CallUpdateItemG.RUN(Item) THEN BEGIN IsErrorG := TRUE; ControlPanelTempG."No. of Errors" := ControlPanelTempG."No. of Errors" + 1; CurrReport.SKIP; END; END ELSE CallUpdateItemG.RUN(Item);When I run rhis report from Object Designer it works just fine if ErrorHandlingG = "Skip error" or "Break on error". When I run this report from another form (Job Batch) and ErrorHandlingG = "Break on error" it also works fine. When ErrorHandlingG = "Skip error" I got this error message:
I know I can put COMMIT before running CallUpdateItemG codeunit, I tried it and it works. But it doesn't fit me. I want to understand, whyThe following C/AL functions can be used only to a limited degree during write transactions (because one or more tables will be locked).
Report.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'Report.RunModal(...,FALSE)' is allowed
CallUpdateItemG.RUN(Item) - doesn't cause an error
IF CallUpdateItemG.RUN(Item) causes an error.
What is the difference?
P.S.:
I already searched the forum and found this post very usefull: http://www.mibuso.com/forum/viewtopic.php?t=38919&f=23
However it doesn't describe why error occurs if I handle boolean return value of RUN(Codeunit).
Thanks!
0
Answers
-
Well, superjet's last post actually explains it pretty well.
In NAV there is at most one write transaction.
If NAV allowed your 2nd codeunit.RUN it needed to start a 2nd, nested, transaction just before the call in order to roll back to this point in case something goes wrong within that 2nd RUN. The first call to codeunit.RUN (within Job Queue Dispatcher) could still succeed and therefore should not be rolled back. This is only possible with nested write transactions and therefore, this situation cannot be handled by NAV.0 -
vaprog,
Thanks!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions