Are you utilizing batch for your daily business operations? I've been thinking about blogging about batch in AX for a long time, and a few weeks ago I attended one of the Microsoft webinars sessions where the topic was batch in AX. The support engineer had a brilliant flowchart and I was allowed to publish it. I've reworked it a bit, hoping it will fit the blog space better, but the credit goes to Microsoft's support engineers. :-)
Batch is just yet another great feature of Dynamics AX where you can have operations scheduled to run, sort of like Task Scheduler in Windows. You can have the task be repeated automatically and perhaps have it run during night time when your users are sleeping or partying.
Each Batch Task exists inside what is called a Batch Job, and a Batch Job can have one or more tasks, and the tasks may even be dependent on each other. You may want one task to wait until another one has completed before it starts, and both of them are part of the same Batch Job.
Another important feature of batch is that it runs the operations on the server only. In AX2012 and above, this means it will run the operations in CIL (.Net), which improves performance. That's nice!
I find it interesting to know that the AOS kernel looks for new tasks to fire up every 60 seconds, and it will spawn two threads per CPU core. Also, any AOS can run batch tasks, so you can define dedicated AOSes for batch and perhaps cluster multiple AOSes together. If your AOSes are spread over multiple timezones you can have the same AOS handle users on daytime and batch on nighttime, and visa versa for your other AOSes. Pretty neat!
Back in 2011 Tariq Bell wrote this nice post on how Batch works under the hood. It explains the steps and parts of the code that is involved in the processing of batch tasks. Having a flowchart while reading the textual outline is always helpful.
Understanding how batch works in AX is especially helpful when investigating why tasks remain in Executing Status. In my upgrade projects, batch is heavily involved for running the upgrade scripts, and understanding batch is essential.
From the flowchart above, you see there are tables holding the tasks (Batch) and the "header" of the tasks (BatchJob). There is also a table, BatchGlobal, to help the framework keep track of any tasks running across multiple AOSes. The potential constraints and dependencies between tasks in a job is persisted in the BatchConstraints-table. These are just a few of the elements involved in this framework, as there are quite a few elements involved.
The Premier Field Engineers blogged about tweaking the batch threads settings for improved performance for AX2009, but I expect the post to be just as interesting for those who want to learn for AX2012.
Feel free to reuse the flowchart. Thanks for reading!
I have been working with Dynamics AX, now Dynamics 365, since 2009 and I am excited to work with such an amazing platform for building business solutions.
Showing posts with label AX2009. Show all posts
Showing posts with label AX2009. Show all posts
Saturday, November 29, 2014
Thursday, June 5, 2014
Delete Company in AX 2009 using SQL
One of the potential tasks when upgrading to a new version of Dynamics AX (like from AX2009 to AX2012) is getting rid of obsolete companies. Microsoft shared a SQL for this a few years back. I enhanced it a little bit and added some additional statements.
Just one important remark - DO NOT RUN THIS AGAINST AX2012!
In the interest of sharing, here it is:
Use at own risk (of course), and let me know if you find any issues with it.
Just one important remark - DO NOT RUN THIS AGAINST AX2012!
In the interest of sharing, here it is:
/******************************************************** REMOVE COMPANYID IN DYNAMICS AX 2009 USE AT OWN RISK! MAKE SURE YOUR TRANSACTION LOG IS PERMITTED TO GROW Inspired by: http://blogs.msdn.com/b/emeadaxsupport/archive/2010/12/09/how-to-delete-orphaned-data-remained-from-deleted-company.aspx Tommy Skaue http://yetanotherdynamicsaxblog.blogspot.com/ *********************************************************/ DECLARE @_TABLENAME NVARCHAR(40) DECLARE @_COMPANYID NVARCHAR(4) SET @_COMPANYID = N'TST'; -- COMPANY TO DELETE DECLARE CURSQLDICTIONARY CURSOR FOR SELECT A.SQLNAME FROM SQLDICTIONARY A INNER JOIN SQLDICTIONARY X ON X.TABLEID = A.TABLEID AND X.FIELDID = 61448 WHERE A.FIELDID = 0 AND A.FLAGS = 0 OPEN CURSQLDICTIONARY FETCH NEXT FROM CURSQLDICTIONARY INTO @_TABLENAME WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @_SQL NVARCHAR(4000) SET @_SQL = N'DELETE FROM ' + QUOTENAME(@_TABLENAME) + N' WHERE DATAAREAID = @_DATAAREAID' PRINT (CHAR(13) + 'Removing ' + @_COMPANYID + ' from ' + @_TABLENAME + '...') EXEC SP_EXECUTESQL @_SQL, N'@_DATAAREAID NVARCHAR(4)', @_DATAAREAID = @_COMPANYID FETCH NEXT FROM CURSQLDICTIONARY INTO @_TABLENAME END PRINT (CHAR(13) + 'Finalizing...') DELETE FROM DATAAREA WHERE DATAAREA.ID = @_COMPANYID DELETE FROM COMPANYDOMAINLIST WHERE COMPANYDOMAINLIST.COMPANYID = @_COMPANYID DELETE FROM VIRTUALDATAAREALIST WHERE VIRTUALDATAAREALIST.ID = @_COMPANYID PRINT (CHAR(13) + 'Done!') CLOSE CURSQLDICTIONARY DEALLOCATE CURSQLDICTIONARY
Use at own risk (of course), and let me know if you find any issues with it.
Subscribe to:
Posts (Atom)