Skip to main content

Microsoft Dynamics AX 2009 : The MorphX Tools - Debugger

Like most development environments, MorphX features a debugger. The debugger is a stand-alone application, not part of the Dynamics AX shell like the rest of the tools . As a stand-alone application, the debugger allows you to debug X++ in any of the Dynamics AX components in the following list:•
Microsoft Dynamics AX client


Application Object Server (AOS)


Enterprise Portal


Business Connector


Using the Debugger

For the debugger to start, a breakpoint must be hit during execution of X++ code. You set breakpoints by using the X++ code editor in the Microsoft Dynamics AX client. The debugger starts automatically when any component hits a breakpoint.

You must enable debugging for each component as follows:

In the Microsoft Dynamics AX client, click the Microsoft Dynamics AX drop-down menu, point to Tools and then Options. On the Development tab, select When Breakpoint in the Debug Mode list.


For the AOS, open the Microsoft Dynamics AX Server Configuration utility under Start\Administrative Tools. Create a new configuration (if necessary), and select the check box labeled Enable Breakpoints To Debug X++ Code Running On This Server.


For Batch jobs, open the Microsoft Dynamics AX Server Configuration utility under Start\Administrative Tools. Create a new configuration (if necessary), and select the check box labeled Enable Global Breakpoints To Debug X++ Code Running In Batch Jobs.


For Enterprise Portal and Business Connector, open the Microsoft Dynamics AX Configuration utility under Start\Administrative Tools. Select one of two check boxes on the Developer tab: Enable User Breakpoints For Debugging Code Running In The Business Connector or Enable Global Breakpoints For Debugging Code Running In The Business Connector Or Client. The latter is useful for debugging incoming Web requests.



Caution




We recommend that you do not enable any of the debugging capabilities in a live environment. If you do, execution will stop when it hits a breakpoint, and users will experience a hanging client.



The debugger allows you to set and remove breakpoints by pressing F9. You can set a breakpoint on any line you want. If you set a breakpoint on a line without an X++ statement, however, the breakpoint will be triggered on the next X++ statement in the method. A breakpoint on the last brace will never be hit.

You can enable or disable a breakpoint by pressing Ctrl+F9. For a list of all breakpoints, press Shift+F9.

Breakpoints are persistent in the SysBreakpoints database table. Each developer has his or her own set of breakpoints. This means that your breakpoints are not cleared when you close Dynamics AX and that other Dynamics AX components can access them and break where you want them to.

Debugger Interface

The main window in the debugger initially shows the point in the code where a breakpoint was hit. You can control execution one step at a time while variables and other aspects are inspected. Figure 1 shows the debugger opened to a breakpoint with all the windows enabled.


Figure 1. Debugger with all windows enabled


In the following subsections, we briefly describe the debugger’s various windows and some of its other features.

Main Window

The main debugger window shows the current X++ code. Each variable has a ScreenTip that reveals its value. You can drag the next-statement pointer in the left margin. This pointer is particularly useful if the execution path isn’t what you expected or if you want to repeat a step.

Variables Window

In this window, local, global, and member variables are shown. Local variables are variables in scope at the current execution point. Global variables are the global classes that are always instantiated: Appl, Infolog, ClassFactory, and VersionControl. Member variables make sense only on classes, and they show the class member variables.

The Variables window shows the name, value, and type of each variable. If a variable is changed during execution stepping, it is marked in red. Each variable is shown associated with a client or server icon. You can modify the value of a variable by double-clicking the value.


Tip




As a developer, you might want to provide more information in the value field than what is provided by default. For a class, the defaults are New and Null. You can change the defaults by overriding the toString method. If your class doesn’t explicitly extend object (the base class of all classes), you must add a new method named toString, returning str and taking no parameters, to implement this functionality.



Call Stack Window

The Call Stack window shows the code path followed to arrive at a particular execution point. Clicking a line in the Call Stack window opens the code in the Code window and updates the local Variables window. A client or server icon indicates the tier on which the code is executed.

Watch Window

In the Watch window, you can inspect variables without the scope limitations of the Variables window. You can drag a variable here from the Code window or the Variables window.

The Watch window shows the name, value, and type of the variables. Five different Watch windows are available. You can use these to group the variables you’re watching in the way that you prefer.

Breakpoints Window

The Breakpoints window lists all your breakpoints. You can delete, enable, and disable the breakpoints via this window.

Output Window

The Output window shows the traces that are enabled and the output sent to the Infolog application framework. The Output window includes the following pages:

Debug You can instrument your X++ code to trace to this page by using the printDebug static method on the Debug class.


Infolog This page contains messages in the queue for the Infolog.


Database, Client/Server, and ActiveX Trace Any traces enabled on the Development tab in the Options dialog box appear on these pages.


Status Bar

The status bar at the bottom of the debugger offers the following important context information:

Current user The ID of the user who is logged on to the system. This information is especially useful when you are debugging incoming Web requests.


Current session The ID of the session on the AOS.


Current company accounts The ID of the current company accounts.


Transaction level The current transaction level. When reaching zero, the transaction is committed.


Debugger Shortcut Keys

Table 1 lists the most important shortcut keys available in the debugger.


Table 1. Debugger Shortcut Keys







Action

Shortcut

Description




Run

F5

Continue execution



Stop debugging

Shift+F5

Break execution



Step over

F10

Step over next statement



Run to cursor

Ctrl+F10

Continue execution but break at the cursor’s position



Step into

F11

Step into next statement



Step out

Shift+F11

Step out of method



Toggle breakpoint

Shift+F9

Insert or remove breakpoint



Variables window

Ctrl+Alt+V

Open or close Variables window



Call Stack window

Ctrl+Alt+C

Open or close Call Stack window



Watch window

Ctrl+Alt+W

Open or close Watch window



Breakpoints window

Ctrl+Alt+B

Open or close Breakpoints window



Output window

Ctrl+Alt+O

Open or close Output window

Popular posts from this blog

Dynamics Axapta: Sales Orders & Business Connector

Well, again folllowing my same idea of writting close to nothing and pasting code, I'll paste in some code to create a sales order from some basic data and the invoice it. I'll try to explain more in the future. AxaptaObject axSalesTable = ax.CreateAxaptaObject("AxSalesTable"); AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim"); AxaptaRecord rcCustTable = ax.CreateAxaptaRecord("CustTable"); rcCustTable.ExecuteStmt("select * from %1 where %1.AccountNum == '" + MySalesOrderObject.CustAccount + "'"); if (MySalesOrderObject.CurrencyCode.Trim().Length == 0) MySalesOrderObject.CurrencyCode = rcCustTable.get_Field("Currency").ToString().Trim(); string sTaxGroup = rcCustTable.get_Field("taxgroup").ToString().Trim(); //set header level fields axSalesTable.Call("parmSalesName", MySalesOrderObject.SalesName.Trim()); axSalesTable.Call("parmCustAccount", M

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }