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

What does this mean: "The form datasource query object does not support changing its AllowCrossCompany property after the form has executed the query."?

I have made a form with datasources vendtable and vendtrans. Inside vendtable_ds.executequery() looks like this: QueryBuildDataSource queryBuildDatasource ,queryBDS_VendTrans_Invoice; ; queryBuildDatasource = this.query().dataSourceTable(tablenum(vendtable)); queryBDS_VendTrans_Invoice = this.query().dataSourceTable(tablenum(vendtrans)); if (curext() == "MASTERCOMP") { this.query().allowCrossCompany(true); } else { this.query().allowCrossCompany(false); } //FilterVendorName = stringedit control on form if (FilterVendorName.text()) { queryBuildDatasource.addRange(fieldNum(VendTable,Name)).value(strfmt("*%1*", FilterVendorName.text())); } else { queryBuildDatasource.clearRange(fieldNum(VendTable,Name)); } //FilterInvoiceNumber = stringedit control on form if (FilterInvoiceNumber.valueStr() == "") { queryBDS_VendTrans_Invoice.enabled(false); } else { queryBDS_VendTrans_Invoice.enabled(true); queryBDS_VendTrans_In...

Credit Note [Dynamics AX] using X++

This post will help to create credit note for a sales order based on the invent lot id. All the invoices raised for a particular sales line – Lot Id will be raised back as a credit note. Information on Credit Note: A credit note or credit memorandum (memo) is a commercial document issued by a seller to a buyer. The seller usually issues a Credit Memo for the same or lower amount than the invoice, and then repays the money to the buyer or sets it off against a balance due from other transactions Below Code will help to create credit note for all the invoices raised against the sales line -lot id. Please note: This code can be customized as per your requirements. This is just a template to help creating credit note using X++ code. Please test the code before use. static void SR_CreateCreditNote_Sales(Args _args) { // Coded by Sreenath Reddy CustInvoiceTrans custInvoiceTrans; Dialog dialog = new Dialog(“Create credit note – for sales.”); DialogField dfInv...