mfp's two cents

...on Dynamics AX Development!
  • mfp's two cents

    X++ Debugging Tips and Tricks #4 - Reading uncommitted data

    • 2 Comments

     X   Debugging - tall 2

    This next trick in the X++ Debugging Tip and Tricks series is invaluable when stuck deep in a debugging session, and want to verify that the SQL statements being executed has the intended behavior.

    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:

    image

    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:

    image

    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:

    image

    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.

  • mfp's two cents

    X++ Pedal To The Metal

    • 7 Comments

    This is a post I’ve been waiting to write for quite a while – but it had to wait until R3 became available.

    T-Shirt-Fast Xpp The SysExtension framework offers some great capabilities, but unfortunately it also comes with a performance penalty (in R2). A while ago I set out to understand where the time was spent, and hoping to optimize it. As an engineer this is a typical task with an expected outcome: A few days spent, an optimization of 10-20 percent is found. This time the task turned out to completely consume me for the better part of a week, I learned some important lessons, and the outcome exceeded my wildest imagination. This blog shares my findings.

    Starting point

    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.

    First success

    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.

    First physical limit

    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.

    Ultimate physical limit

    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!” 

    Final success

    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.

    image

    Conclusion

    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

  • mfp's two cents

    Dynamics AX R3 is here, on-prem and in the cloud!

    • 0 Comments

    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.

     

  • mfp's two cents

    Dynamics AX 2012 R3 Launch Events

    • 2 Comments

    image

    It is today! Make sure to join the online Launch Event.

    • Session 1: 11:00 AM SGT (Asia: GMT +8)
    • Session 2: 15:00 GMT/16:00 CET (Europe)
    • Session 3: 12:00 PM CDT (North America: GMT -6)

     

    Read more here.

  • mfp's two cents

    Microsoft Dynamics AX WMS/TMS Workshop

    • 2 Comments

    image

    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:

    • Reservation Hierarchies,
    • New Inventory dimensions: License Plate and Inventory Status,
    • Product configuration,
    • Warehouse setup of Location, Zones and Profiles,
    • Warehouse flow,
    • Outbound warehouse processes using mobile devices,
    • Warehouse integration with Discrete manufacturing and Kanban,
    • Transportation setup of Carrier, Rating Profiles, Rate Master, Override Charges, and Routes and Routing Constraints.
    • Freight reconciliation
  • mfp's two cents

    Register for the Dynamics AX 2012 R3 Launch Event

    • 0 Comments

     

     

    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.             

    • Hear why Principal Analyst Nigel Montgomery of Gartner talking about how Business Decision Makers respond to today’s rapidly changing market conditions.
    • Discover how organizations are simplifying their supply chain, giving timely business insight to the board room and increasing employee productivity.
    • See our new capabilities in action and how mobile, devices and the cloud are helping businesses be highly responsive to evolving customer preferences and changing market conditions.

    Now is the time to transform your company into a dynamic business that delivers amazing customer experiences!

    Date: April 10, 2014

    Time(s):

    • Session 1: 11:00 AM (Asia/Singapore)
    • Session 2: 3:00 PM (Europe/London)
    • Session 3: 12:00 PM (Central Standard Time)

    Register here.

  • mfp's two cents

    Inside Microsoft Dynamics AX 2012 R3

    • 0 Comments
    The 4th book in the “Inside Microsoft Dynamics AX” series will be released June 25th 2014.
    image

    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!

  • mfp's two cents

    Microsoft Dynamics AX R3 is coming

    • 0 Comments
    AX Logo

    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…

  • mfp's two cents

    10 reasons I love my Microsoft Surface

    • 4 Comments

    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. 

    1. It is sturdy

    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.

    2. The kick stand

    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.

    3. User accounts and Picture login

    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.

    4. Family safety

    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:
    image

    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)

    5. The modern UI.

    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!

    6. USB

    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.

    7. Skydrive

    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.

    8. Desktop

    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.

    9. Battery

    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.

    10. Microsoft Store

    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.

    WP_000337

  • mfp's two cents

    X++ Debugging Tips and Tricks #3–Conditional breakpoints

    • 0 Comments

    The Dynamics AX Debugger doesn’t support conditional breakpoints. Once in a while this limitation can be quite annoying – but there is a simple workaround. The third trick in the series of X++ Debugging Tips and Tricks shows you how.

    This trick requires code instrumentation – I strongly discourage using this trick on a production system. Only use this trick in a test or development sandbox!        

    By using the breakpoint keyword, you can write X++ logic that triggers a breakpoint exactly as you want.

    Consider this example. It is a recursive implementation of the mathematical function: Factorial. On a 32 bit system it will overflow when called with a sufficient high value. The example shows how to a breakpoint when an overflow occurs.

        static void ConditionalBreakpointExample(Args args)
        {
            int factorial(int _value)
            {
                int result = 1;
                int prevResult;
                int i;
            
                for (i=1; i<=_value; i++)
                {
                    result = result * i;
                
                    if (result < prevResult)
                    {
                        breakpoint; //Overflow occurred
                    }
    prevResult = result; } return result; } factorial(maxInt()); }

    The same approach can be used in many other scenarios too. Here is another example – I’d like a breakpoint to fire when a Released Product with Item Id “1000” is inserted in the database. To achieve that I add the following to the insert method on the InventTable table.

        if (this.ItemId == "1000")
        {
            breakpoint;
        }

    There is another way to achieve the same result. You can also insert a no-op line, like i=i; and set a normal breakpoint on that line using F9. This approach has the benefit that only the user setting the breakpoint will hit it – but at the risk of leaving some “silly looking code” behind. In contrast the breakpoint statement triggers a best practice error – so they are easy to clean out again.

    Bonus trick

    There is another usage of the breakpoint statement. Sometimes regular breakpoints in forms don’t fire – here the breakpoint statement also comes in handy. Instead of setting a breakpoint using F9 – just type “breakpoint;” in the code. This will trigger the debugger.

    This post is provided AS-IS, and confers no rights or warranties.

    X   Debugging banner 2

Page 1 of 19 (182 items) 12345»

mfp's two cents

...on Dynamics AX Development!