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

nachoporcarnachoporcar Member Posts: 27
edited 2007-05-30 in Navision Attain
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

Comments

  • ara3nara3n Member Posts: 9,256
    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.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kinekine Member Posts: 12,562
    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...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.