not able to capture the error

bharathnan
Member Posts: 92
Hi All,
I getting the following error message when i try to capture the error while transferring of data from one field to other field whose datatype lengths are different .I want to capture the error in a separate field .
totable.DELETEALL;
fromtable.RESET;
fromtable.FINDFIRST;
REPEAT
totable.INIT;
totable.TRANSFERFIELDS(fromtable);
totable.INSERT;
MESSAGE(FORMAT('Error Successfully Captured'));
IF NOT errorcapture1.RUN(fromtable) THEN
totable.errortable :=COPYSTR(GETLASTERRORTEXT,250);
totable.INSERT;
//errorcapture2.RUN;
UNTIL fromtable.NEXT =0;
when i was running i got the following error mesage.
Microsoft Dynamics NAV Classic
The following C/AL functions can be used only to a limited degree during write transactions because one or more tables will be locked.
Form.RunModal is not allowed in write transactions.
CodeUnit.Run is allowed in write transactions only if the return value is not used. For example, 'OK := CodeUnit.Run()' is not allowed.
Report.RunModal is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'Report.RunModal(...,FALSE)' is allowed.
DataPort.RunModal is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'DataPort.RunModal(...,FALSE)' is allowed.
Use the COMMIT function to save the changes before this call, or structure the code differently.
OK
I getting the following error message when i try to capture the error while transferring of data from one field to other field whose datatype lengths are different .I want to capture the error in a separate field .
totable.DELETEALL;
fromtable.RESET;
fromtable.FINDFIRST;
REPEAT
totable.INIT;
totable.TRANSFERFIELDS(fromtable);
totable.INSERT;
MESSAGE(FORMAT('Error Successfully Captured'));
IF NOT errorcapture1.RUN(fromtable) THEN
totable.errortable :=COPYSTR(GETLASTERRORTEXT,250);
totable.INSERT;
//errorcapture2.RUN;
UNTIL fromtable.NEXT =0;
when i was running i got the following error mesage.
Microsoft Dynamics NAV Classic
The following C/AL functions can be used only to a limited degree during write transactions because one or more tables will be locked.
Form.RunModal is not allowed in write transactions.
CodeUnit.Run is allowed in write transactions only if the return value is not used. For example, 'OK := CodeUnit.Run()' is not allowed.
Report.RunModal is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'Report.RunModal(...,FALSE)' is allowed.
DataPort.RunModal is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'DataPort.RunModal(...,FALSE)' is allowed.
Use the COMMIT function to save the changes before this call, or structure the code differently.
OK
0
Answers
-
start the debugger and see from where you are getting error0
-
The error message already explains it:
CodeUnit.Run is allowed in write transactions only if the return value is not used. . . . Use the COMMIT function to save the changes before this call, or structure the code differently.
Insert a commit beforeIF NOT errorcapture1.RUN(fromtable) THEN
but be aware that there is no roll back if another error occurs. All records will be written permanently until this point.0 -
USE COMMIT, it will solve your case.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0 -
Hi mohana after running the debugger its throwing error here
IF NOT errorcapture1.RUN(fromtable) THEN
0 -
I'm not 100% sure, but I think in this type of a call to a codeunit, the debugger stops when finding an error. Without debugger it works as designed, meaning the caller of the codeunit handles the error.0
-
I did the following things to capture the error in nav using getlasterrortext but its throwing some error which i Have posted above.Please provide me some help..
Warm regards,
Bharath.K0 -
FromTable.RESET; FromTable.FINDFIRST; REPEAT IF NOT ErrorCapture.RUN(FromTable) THEN BEGIN ToTable.INIT; ToTable.Field1 := 'prim_key'; ToTable.ErrorText := COPYSTR(GETLASTERRORTEXT, 1, MAXSTRLEN(ToTable.ErrorText)); ToTable.INSERT; END;
The message says: Do not do any write-transactions to the database before calling "ErrorCapture.RUN" or when you have to do it, put a COMMIT before "ErrorCapture.RUN".My blog - https://www.HannesHolst.com/0 -
HannesHolst wrote: »
FromTable.RESET; FromTable.FINDFIRST; REPEAT IF NOT ErrorCapture.RUN(FromTable) THEN BEGIN ToTable.INIT; ToTable.Field1 := 'prim_key'; ToTable.ErrorText := COPYSTR(GETLASTERRORTEXT, 1, MAXSTRLEN(ToTable.ErrorText)); ToTable.INSERT; END;
The message says: Do not do any write-transactions to the database before calling "ErrorCapture.RUN" or when you have to do it, put a COMMIT before "ErrorCapture.RUN".
Thanks Hannes Its working for me .. thanks a lot0 -
bharathnan wrote: »HannesHolst wrote: »
FromTable.RESET; FromTable.FINDFIRST; REPEAT IF NOT ErrorCapture.RUN(FromTable) THEN BEGIN ToTable.INIT; ToTable.Field1 := 'prim_key'; ToTable.ErrorText := COPYSTR(GETLASTERRORTEXT, 1, MAXSTRLEN(ToTable.ErrorText)); ToTable.INSERT; END;
Without using the code given below is it possible to get the error captured,Since here we are hardcoding the value to the particular field
ToTable.Field1 := 'prim_key';
any suggestions please advice0
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