NAS Error Message

Dear All,

I have a NAS which executes several task in the following way:

Codeunit1 -> Codeunit50000 -> Codeunit50001 -> Report50000 

Step 1: Codeunit1 is where the parameter call of my NAS located.

Step 2: Codeunit50000 only act as an intermediate to call all my functions stored in Codeunit 50001.

Step 3: Codeunit50001 contains few functions which will be executed one by one, then lastly run another Report50000.

Step 4: Report50000 will write some data into tables.

The problem is I get the following error in the Windows Event Viewer:

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 ret.

Hope someone can give me some advice on this. Thanks in advance!

  • The error tells you what your problem is.  You are usign one of the mentioned commands in a manner that is not allowed. The solution is to restructure your code.

     

     

  • In reply to babrown:

    Hi babrown,

         Thank you for spending time reading my post and providing your opinion.

         Yes, no doubt restructuring the whole code will be the best way. But due to my lack of experience and expertise. I think restructuring the code might not be helpful as I might repeat the same programming mistake that will caused the same error.

         Do you mind to share with me some of your opinion on what kind of programming structure should not be used when dealing with NAS?

         What I have did so far is as followed:

         1. In report, disable request form and processing only = TRUE.

         2. No Form.RUN or Form.RUNMODAL is used.

         3. When using Codeunit.RUN, I did not use the return value.

         Hope that helps to narrow down the possibilities in identifying the root cause to my error message.

         Any further suggestion/opinion is greatly appreciated.

         Thanks and have a nice day ahead.

  • In reply to cmchin:

    Hi cmchin,

    The first thing you should remember when working with NAS is that it does not support any UI events.  Anything that would display content to the user should be removed or redesigned so that nothing would appear on the screen as your processes run.

    Without knowing the exact content of each of your codeunits and the report, I can't get very precise on what you should change.  In general though (and this is only personal preference, more of a style consideration) I would look closely at the nature of the two codeunits to determine whether I could accomplish the same work in a single codeunit.  Aside from appealing to my sense of order, it would save the consumption of an expensive Navision object.  I would also look at the report to consider replicating the functionality in a function within the codeunit.  Remember that if all of your various coding designs work, the simplest among them is usually the best choice.

  • In reply to George Love:

    What table does your report writes the data into.

  • In reply to Manish:

    Hi George Love,

         Thank you for spending time reading though this post and share your valuable experience. Throughout my coding in the objects mentioned in the first post, plus Codeunit80 and Codeunit90, I've put the "IF GUIALLOWED THEN" wherever there are MESSAGE or WINDOW used.

         Previously, I run the two different task using 2 different NAS using the developer license, and everything seems fine. Now, these 2 tasks had been combined and run using 1 NAS.

         I've exported few objects which is used by my NAS and uploaded to the following link http://www.sendspace.com/file/dwe18m. Hope you can help me to have a look if you are free.

     

    Hi Manish,

         Thanks for spending time reading to my post. For your information, I do write data into the following tables:

         1. Posted Sales Shipment Header

         2. Posted Sales Invoice Header.

         3. Posted Purchase Receive Header

         4. Posted Purchase Invoice Header.

         After I change the license from developer to customer own license, I do face some permission issue. Therefore, I had assign permission in the Report50002 to be able to RIM the above mentioned table.

     

    Hope my reply does provide you all with sufficient information. Thanks again for all the effort! Have a nice day ahead.

     

  • In reply to cmchin:

    cmchin

    ....

    Hi Manish,

         Thanks for spending time reading to my post. For your information, I do write data into the following tables:

         1. Posted Sales Shipment Header

         2. Posted Sales Invoice Header.

         3. Posted Purchase Receive Header

         4. Posted Purchase Invoice Header.

         After I change the license from developer to customer own license, I do face some permission issue. Therefore, I had assign permission in the Report50002 to be able to RIM the above mentioned table.

     

    Hope my reply does provide you all with sufficient information. Thanks again for all the effort! Have a nice day ahead.

     

    Why are you writing data into these table?  These tables should be written by CodeUnits 80 and 90 ONLY.  Which alreay has the proper permissions.  No user process should write directly to these tables.

     

     

  • In reply to babrown:

    Hi babrown,

         First of all, thanks for spending replying to my post. Thanks for your sharing that I should not write into posted table through my own codeunit. I will try to avoid it next time.

         For your information, I've created some fields in the Posted Sales Shipment table and Posted Purchase Receive table. These few will store the inter-related Posted Sales Shipment No. and Posted Purchase Receive No. Do you think I can use my own codeunit/Report to write into these posted table if I assign the necessary permission to the codeunit/Report?

         Hope to hear from you soon. Thanks in advance!

     

Related