CodeUnit return code

Hi, I have a problem what is very weird. I created a new CodeUnit and would like to use it as in Report 297 (Batch Post). In this report in the OnAfterGetRecord trigger there is a line such as: if SalesPost.run then … When I do that with my own function: ‘If CreateOrders.Run’ Navision gives me an error message regarding a COMMIT statement. I’m using Navision Attain 3.10. Please help. Thanks, Roelof.

SalesPost.RUN does not give any error 'cos on codeunit 80 there’s a commit at the end of the codeunit and a few more on the begining, so the commit is already being called. Regards,

No, thats not the issue. I also have a commit statement in my own function. It’s already giving me that error message when I try to call my function. Who can help me out. Roelof.

quote:


Originally posted by Roelof
No, thats not the issue. I also have a commit statement in my own function. It’s already giving me that error message when I try to call my function. Who can help me out.


Where are you having your commit… on the beginning, at the end?.. what error message is giving to you? What is the codeunit doing inside? it’s your report also processing only or is showing data?.. well… it’s not really easy to help with that much information as you’ve provided. It’s like “my car is stopping when i’m driving it on the highway, can somebody tell me what to do for fixing it?”

Hi, Well, the basic issue here is: all what I want to do is to call a CodeUnit from a report. This function is coded in the OnAfterGetRecord loop. When I try to call my CodeUnit as: ‘IF CreateOrders then…’ it gives me an error that I’m not allowed to use in that way (to capture a boolean back regarding the if … statement). If you look at report 297, Navision is doing the same thing. My question is, why doesn’t it work in the way I do it? Roelof. PS: Error message is: 'The following C/AL functions can be used only to a limited degree during write transactions (because one or more tables will be locked). CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, ‘OK := CodeUnit.Run() is not allowed.’ See what I mean? The way I do it is not allowed, but why is it working in Report 297??? (because codeunit 80 is also writing).

PS: I also used a COMMIT statement in my CodeUnit. Where ever I use it, it has no effect.