The past few years I’ve ventured into the SCM code base of AX, and I most admit I found the physical operations easier to comprehend than their financial counterparts. Perhaps it is just the terminology, or perhaps its because I’m “just” an engineer. At any rate I discovered I’m not the only one struggling – so here is an high level overview of the Cost Management domain and how it is handled in Dynamics AX.
A company is profitable if it can sell its goods for a higher price than they paid for them. This difference is called the Gross profit, it can be found on the Income statement, and is the difference between Sales and Cost of goods sold (COGS). In other words, COGS directly influences the company’s profitability and the amount of tax to pay. The General accepted accounting principles (GAAP) describes several Costing principles, i.e. ways COGS can be measured. As the costing principle(s) used can have a significant impact on the company’s financial performance, there must be full disclosure to which costing principle(s) is used. For these reasons companies are inclined to stay with their current costing principle. The history of accounting for costs predates computer science and ERP systems. Several of the costing principles in use today reflects this fact – they are designed to be applied periodically (in the past by a book keeper with a pen in his hand). The inputs to the costing calculations are called cost elements. They include Direct cost (purchase price of finished goods or raw material) and Indirect cost (such as labor and equipment).
In Dynamics AX the Costing principles are called Inventory models. An Inventory model prescribes how Direct cost is determined. Indirect cost is always estimated. These estimations are provided by the Costing sheet.
In the following consider this sequence of event:
AX supports these Inventory models:
AX 2009 Costing models: http://www.microsoft.com/en-us/download/details.aspx?id=1041
Moving average: http://technet.microsoft.com/en-us/library/hh597235.aspx
More background: http://www.accountingcoach.com/inventory-and-cost-of-goods-sold/explanation
For illustrative purposes, I’ve created a small job. It updates the customer group to “40” for the customer with account number “4001”. This happens inside a transaction. I’ve also added a breakpoint statement to jump to the debugger inside the transaction.
When running the job the debugger opens:
Now, if we go the SQL Server Management Studio and execute a select statement to validate that the field was correctly updated, we will notice that it still has the old value:
This should not be a surprise, as the transaction has not been committed yet. However; that shouldn’t block our noble purpose. By adding the keyword “nolock” to the query, we instruct SQL to read the uncommitted data, and voila, we get the results we expect:
One additional piece of advice is related to more complicated SQL statements: You have to add the nolock keyword to every joined table.
This can be a true life saver when debugging. In fact I used this heavily the past few weeks where I've been working on the new Warehouse Management module in R3.
This is a post I’ve been waiting to write for quite a while – but it had to wait until R3 became available.
To be able to measure the impact of any changes I build a very simple test harness to exercise the SysExtension framework. A two level deep class hierarchy and one attribute that decorated the sub-class. I then compiled everything to IL, and wrote a small job to measure how many class instances I could spin up per second. This velocity measurement was around 3,400 classes/second.
Debugging through the code I quickly learned that a lot of things were going on. This included creating a key for the attribute for various caches. This key was constructed via reflection on the attribute class. I avoided using reflection by introducing a new interface (SysExtensionIAttribute) and I fixed a number of other minor issues. Now the velocity jumped to 40,000 classes/second.
Is this an acceptable velocity? Well, how fast can it possibly be? The logic is in essence just creating a class via reflection, so I did a measurement of DictClass.MakeObject(). This could give me 84,000 classes/second. Slightly about double of the my current implementation. After some investigation I discovered two expensive calls: “new DictClass()” and “dictClass.makeObject()”. Can you spot what they have in common? They both requires a call into the native AOS libraries. In other words an interop call. I tried various other calls into the AOS, such as “TTSBegin” (only the first is hitting the DB), and “CustParameters::Find()” (again, only the first one is hitting the DB). To my surprise the velocity of these calls where comparative to DictClass.MakeObject(). The interop overhead outweighs what the method is actually doing. In other words, there is a limit to how many native AOS methods you can call per second. Let us call this velocity: Speed-of-sound.
Being a bit intrigued I measured the fastest and rawest possible implementation: “new MyClass()”. This would run strictly in IL, no overhead of any kind, the result was a whooping 23,800,000 classes/second. Let us call this velocity: Speed-of-light. In the words of Barney Stinton: “Challenge accepted!”
To achieve this kind of velocity the code must run 100% as IL. No calls into native AOS code. Period. Naturally there are APIs in .NET allowing for dynamically creation of class instances – they are slower than a direct instantiation, but still much faster than calling native AOS code. One other challenge was that SysExtension also can execute as pCode, and then a call into IL would cause a similar slow interop – just in the opposite direction. After a few iterations I had an implementation that would not cause an interop calls, regardless of if the code runs as IL or pCode. Take a look at SysExtensionAppClassFactory.getClassFromSysExtAttribute in R3 for details. I was pleased with the velocity: 661,000 classes/second. Or about 200 times faster than R2. Or about 15 times faster than a call to CustParameters::Find(). Problem solved: The SysExtension framework no longer has performance issues.
For a long time we have been hunting for SQL and RPC calls when looking for performance. RPC calls are expensive, as communication between two components (Client and Server) occurs. Just like SQL calls are expensive as the Server communicates with SQL (and waits for the reply). We still need to hunt for unnecessary RPC and SQL calls! Nothing changed; except that a third culprit has been identified: Native AOS calls. Relatively speaking the cost of calls into native AOS code is insignificant when compared to RPC or SQL calls – in the absence of these, the impact is measurable and significant.
This is an ERP system, so there will always be SQL calls. So why be concerned with the performance of X++ code? Well, if you can minimize the time between SQL calls, then you will also limit the time SQL holds locks, and you will experience better overall performance and scalability. After all, do you want you code to run with the speed-of-sound or speed-of-light?
Update 11-05-2014: Here is the test harness I used: PrivateProject_SysExpProject.xpo
For business and IT leaders in today’s digitally-connected world who want to deliver amazing customer experiences, your solution – Microsoft Dynamics AX 2012 R3 – is now available in 36 countries!
Brand new modules: Call center, Transportation Management and Warehouse Management - and new and improved capabilities in General Ledger, Inventory costing, Master planning, Procurement and sourcing, Retail, Production control, Public sector, Project and Trade. See all the details here: What's new in R3.
If you like to take R3 for a spin - it has never been easier. You can deploy an Azure instance of R3 for demo purposes in a matter of minutes. Read more here: Deploy Microsoft Dynamics AX 2012 R3 on Azure using Lifecycle Services
You can download R3 from CustomerSource or PartnerSource today.
It is today! Make sure to join the online Launch Event.
Read more here.
Today and tomorrow the SCM team from the Microsoft Dynamics AX R&D division is hosting a workshop on the upcoming Warehouse and Transportation management functionality in Dynamics AX 2012 R3. 140 partners and customers are gather from over 80 different companies at DGI Byen in Copenhagen.
We have 2 busy days ahead of us with short presentations followed by hands-on-labs. No one will leave Copenhagen without a first hands experience of WMS and TMS including:
During the event, we will show our new solutions that will help you better engage with your customers.
Join the CFO of Kathmandu, the CIO of Ashley Furniture and the IT director of Kent Corporation as they discuss their “reimagined customer experience” and the success they’re achieving with Microsoft Dynamics AX. We’ll share a “digital view” of a dynamic business solution (Microsoft Dynamics AX 2012 R3) that helps you engage with your customers on their terms, run dynamics operations and expand rapidly to better serve your customers.
Now is the time to transform your company into a dynamic business that delivers amazing customer experiences!
Date: April 10, 2014 Time(s):
Fully updated for Microsoft Dynamics AX 2012 R3!
Dig into the architecture and internals of Microsoft Dynamics AX 2012 R3 - with firsthand insights from the team that designed and developed it. Deepen your knowledge of the underlying frameworks, components, and tools - and deliver custom ERP applications with the extensibility and performance your business needs. Useful for Microsoft Dynamics AX solution developers at all levels, this guide will provide max benefit to those who understand OOP, relational database, and Transact-SQL concepts.
And this time it comes with a picture of a tool on the cover that I’ve actually used before – but I must admit (so far) never in a work related situation!
Today is a big day for the engineering teams at Microsoft working on R3. We are reaching the important ZBB milestone. ZBB is one of the final internal checkpoints before releasing. It signals that there are zero active product defects known and planned for the release. Reaching ZBB is by no means an easy win. It requires maintaining a bug fix rate higher than the bug discovery rate for a lengthy period of time. It also requires significant coordination and team collaboration to have all teams reach this criteria at the same time.
One part of reaching ZBB is to have zero best practice errors across the entire code base. I’m happy to announce that R3 will ship with zero best practice errors despite the significant increase in code base.
Once again; I’m awestruck by the energy, effort, diligence and dedication demonstrated by the Microsoft Dynamics teams to bring this important release to market.
More to follow, as the release draws nearer…
First things first – I work for Microsoft, and I will not claim to be unbiased. Yet, I bought my Surface out of my own pocket in a regular Microsoft Store – I was even in line for 3 hours to get it. Just like everyone else could.
Secondly, I primarily blog about AX – this is an exception, you don’t have to read it if you don’t want to.
With the formalities out of the way, let me begin. I’ve had the device for about 1 year now. I wanted to use it primarily for entertainment – I did not go for any of the keyboard options. Let me share my experiences.
The Surface had not been in our home more than a few days when my 4 year old kid came running with it. He tripped over a toy, and the device came flying through the air towards our massive oak table. I’ve hit my toes many times on the table – always with the same result: Pain and Agony in well sized portions. Hearing the thud as the Surface collided with the table I closed my eyes. Game over. My kid was already crying. Bracing my self to clean up and comfort my kid – it was just a piece of hardware after all – I inspected the damages. The Surface was intact. I couldn’t even find the place where it had hit the table. It still worked flawlessly. The table – on the other hand – had lost a small chip of wood. The small disaster turned into a simple “Ooops – up again!” situation.
First time I brought the Surface to some friends’ place, they said: “That is cool – how did you get that on your iPad?” I just smiled back.
The kick-stand is amazingly pleasant as it allows for a much more convenient usage.
We have 3 users of the Surface. My now 8 year old girl and my now 5 year old boy – and myself. We each have an account, we each have our own apps, games and settings. I started out by just setting up one account, but quickly we ended up in situations where little-brother deleted (or moved) the games his sister liked. With 3 accounts that stopped right there.
My 4 year old quickly learned how to login – just press your eyes and your nose. Had the system required a keyboard+password login it would have been usable for him.
Both my kids accounts are monitored by the built in family safety feature in Windows 8. This means I get a weekly report showing how much they used the device and for what purposes. And even better, the data is aggregated across all our Microsoft devices, so it also includes X-Box, the wall-mounted touch-all-in-one PC we have in the kitchen, and the regular workstation. Here is a picture of some of the info the weekly report contains:
The system is highly configurable – you can enforce time limits, ratings etc – you can even excluded some apps (like those used for homework) to count against the time limit. As a parent I feel in control – without feeling I’m spying (too much)
I simply adore the UI – the amount of energy that has been put into the aesthetic look of Windows 8 leaves me humbled. The result leaves me with a feeling of being spoiled. If you haven’t read the story behind the design – you should do so. The competition is ages behind.
Every time I visit Bellevue Square Mall I visit the Mac store – just to see what is brewing. Since Windows 8 came out I’ve not been able to find anything that awakes the even smallest desire in me in Mac land.
I find the same experience elsewhere too: In my pocket (Windows 8 phone), at work (Windows Server 2012), at my Laptop (Windows 8.1) and my X-Box (360 – soon to be One).
The tiles are extremely powerful. They give me information at a glance - I don’t waste my time opening apps to check empty in-boxes.. The Data Sense App (on my phone) tells me my current network usage, the Stock portfolio App tells me how Wall-Street is doing, the weather app tells me the weather, the People app tells me if I have new messages aggregated across social networks, like Facebook, Linked-in. Without even opening a single app I get all this info. That is sheer power!
The Surface has a USB port. This enables me to attach my Kindle to upload documents and charge. This enables me to attach a mouse and keyboard. This enables me to attach a printer. This enables me to attached a USB Drive. This enables me to attach my phone.
What impresses me is that everything just works. All drivers are available for all devices even on Windows RT. I have a Keyspan USB to RS232 – and even that highly specialized niche product has a driver on Windows RT. Connect and use.
When I’ve taken a picture with my phone, it is immediately available on my Surface. When my kids ask: “Can I see the pictures you took?” – we look at them on the Surface – it is better than on the smaller phone.
Skydrive enables many other scenarios too – the one with pictures is my favorite.
The Surface has a desktop – just like you know it from any other version of Windows. You can open File Explorer, Control Panel, Regedit, Task Manager etc. All the built in functionality of Windows is available. And on top of that you get Office.
Some find it limiting that you cannot install 3rd party apps on the desktop in RT mode. This does not concern me. I actually try to install as few as possible across all my PCs – it just makes them easier to maintain and less subject to malware.
For the past year we have not had any problems with the battery life time. I’m not sure how many hours we get out of it, but it is never a problem. Not even on our 3 week vacation in car across Europe this summer.
There are plenty of apps and games – at least for my taste. There are a few titles missing – but then again, there are also some exclusive titles – like FreshPaint.