COMMIT for catching exception in IF CU.Run() THEN

nachoporcar
Member Posts: 27
Hi,
i have a Codeunit 50007 with one function, in this function i try to run the codeunit 80 - "Sales-Post", but i want to control the exceptions of this call to Codeunit 80, so i need to put a COMMIT command (view the code).
My question is, the use of the COMMIT could be dangerous? i explain mi question: this COMMIT could intercept, interfere or modify another process thrown by another user?
i annex the code:
procesarPedidoMODULA()
.
.
.
COMMIT;
IF regPedido.RUN(rccabped) THEN
BEGIN
// all OK
END ELSE BEGIN
// Error
sErrores := sErrores + ' E8';
rcCabecera.LOCKTABLE;
rcCabecera.Errores := sErrores;
rcCabecera.MODIFY;
rccabped.LOCKTABLE;
rccabped."Errores preparación" := sErrores;
rccabped.MODIFY;
REPORT.RUNMODAL(REPORT::"Listado Pedidos Prep. Errores",FALSE,TRUE,rcCabecera);
END;
Thanks
Nacho
i have a Codeunit 50007 with one function, in this function i try to run the codeunit 80 - "Sales-Post", but i want to control the exceptions of this call to Codeunit 80, so i need to put a COMMIT command (view the code).
My question is, the use of the COMMIT could be dangerous? i explain mi question: this COMMIT could intercept, interfere or modify another process thrown by another user?
i annex the code:
procesarPedidoMODULA()
.
.
.
COMMIT;
IF regPedido.RUN(rccabped) THEN
BEGIN
// all OK
END ELSE BEGIN
// Error
sErrores := sErrores + ' E8';
rcCabecera.LOCKTABLE;
rcCabecera.Errores := sErrores;
rcCabecera.MODIFY;
rccabped.LOCKTABLE;
rccabped."Errores preparación" := sErrores;
rccabped.MODIFY;
REPORT.RUNMODAL(REPORT::"Listado Pedidos Prep. Errores",FALSE,TRUE,rcCabecera);
END;
Thanks
Nacho
0
Comments
-
why are you running it in an if statement?
You should just give the user the error.
To answer you question about the commit, Either put it in the beginning of CU.
OR at the end. Search for commits in CU 80 and you need to put your code in that section.
Also I would not run a report.modal during a posting routine.
It'll lock everybody else out.0 -
And please, do not use COMMIT, if you do not know, what you can break with it. COMMIT is too dangerous commant to put it into posting rutine without good knowledge what COMMIT can do... do not forget - inserting commit into process is like breaking the atom (and not just symbolically - transaction is atomic and adding commit into the transaction this atomic transaction is splited). If you know how to do it, you have nice powerplant, if you do not know, you have nice atomic bomb...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