??? Do you know how a error worked :?:
With an error, the DBMS makes a rollback of the current transaction, for example your posting. Why you will stop this and risk inconsistent transactions :?: ](*,) [-X
IF CodeUnit.RUN() THEN
MESSAGE('No Error in this')
ELSE
MESSAGE('There was an error');
Of course You lose the rest of CodeUnit.RUN code, but still You are able to handle an error appearance. I don't remember any other way of not stopping Your code. Maybe this will help You.
IF CodeUnit.RUN() THEN
MESSAGE('No Error in this')
ELSE
MESSAGE('There was an error');
Of course You lose the rest of CodeUnit.RUN code, but still You are able to handle an error appearance. I don't remember any other way of not stopping Your code. Maybe this will help You.
If you take this approach you must also handle the rollback. NAV will see this has a successful transaction and commit any changes.
IF CodeUnit.RUN() THEN
MESSAGE('No Error in this')
ELSE
MESSAGE('There was an error');
Of course You lose the rest of CodeUnit.RUN code, but still You are able to handle an error appearance. I don't remember any other way of not stopping Your code. Maybe this will help You.
If you take this approach you must also handle the rollback. NAV will see this has a successful transaction and commit any changes.
But only for what was done before the Codeunit.RUN...
Anothing thing on error handling is that you can actually determine the last error - this is especially useful when working with NAS and there is no user interface but you want to be able to log or otherwise notify an admin of the failure condition.
In version 5.0 of Navision they've implemented GETLASTERRORTEXT and CLEARLASTERROR functions. These can be used in conjuction with the programming patter described here using the IF CODEUNIT.RUN() to return the actual error that would be propagated to the users screen.
This is vastly superior to just logging an error has occurred or trying to guess what could have caused the error.
Actually my requirement is i have emp table with Eno,Ename,salary,post(boolean).i write two codeunits like below
codeunit1
IF Emp1.FIND('-') THEN
REPEAT
IF Emp1.Post=FALSE THEN
IF EmpCu.check(Emp1) THEN
Emp1.Post:=TRUE;
Emp1.MODIFY;
UNTIL Emp1.NEXT=0;
codeunit2
empcu.check(rec);
if emp.sallary=0 then
emp.textfield(salary);
whenever i run 1 st codeunit then it checks post false then call 2nd codeunit .in second code unit checks salary is null then it shows error stop the execution else goes to step.but i need process all records except employee whose salary is 0.
i.e i have 50 employee if 10 th employee's salary=0 then show error and stop the execution but i need process the next employee records also execept 10th employee
Why just do not calc the salary and skip the records with salary 0? Is the calculation of the salary so complex step? Or it is just some field? This way of "catching" error is good when you expect many errors you cannot handle before calling the needed function (like posting function) through code and you can do all the steps as separate transaction.
Comments
With an error, the DBMS makes a rollback of the current transaction, for example your posting. Why you will stop this and risk inconsistent transactions :?: ](*,) [-X
IF CodeUnit.RUN() THEN
MESSAGE('No Error in this')
ELSE
MESSAGE('There was an error');
Of course You lose the rest of CodeUnit.RUN code, but still You are able to handle an error appearance. I don't remember any other way of not stopping Your code. Maybe this will help You.
If you take this approach you must also handle the rollback. NAV will see this has a successful transaction and commit any changes.
But only for what was done before the Codeunit.RUN...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
In version 5.0 of Navision they've implemented GETLASTERRORTEXT and CLEARLASTERROR functions. These can be used in conjuction with the programming patter described here using the IF CODEUNIT.RUN() to return the actual error that would be propagated to the users screen.
This is vastly superior to just logging an error has occurred or trying to guess what could have caused the error.
Epimatic Corp.
http://www.epimatic.com
Actually my requirement is i have emp table with Eno,Ename,salary,post(boolean).i write two codeunits like below
codeunit1
IF Emp1.FIND('-') THEN
REPEAT
IF Emp1.Post=FALSE THEN
IF EmpCu.check(Emp1) THEN
Emp1.Post:=TRUE;
Emp1.MODIFY;
UNTIL Emp1.NEXT=0;
codeunit2
empcu.check(rec);
if emp.sallary=0 then
emp.textfield(salary);
whenever i run 1 st codeunit then it checks post false then call 2nd codeunit .in second code unit checks salary is null then it shows error stop the execution else goes to step.but i need process all records except employee whose salary is 0.
i.e i have 50 employee if 10 th employee's salary=0 then show error and stop the execution but i need process the next employee records also execept 10th employee
Lakshman Routu
http://lakshman-routu.blogspot.in/
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.