Dynamics AX 2009 Development Presentation

download Dynamics AX 2009 Development Presentation

If you can't read please download the document

Transcript of Dynamics AX 2009 Development Presentation

Microsoft Dynamics Ax Development Introduction

By

Sohaib Muhammad Product Development [email protected]

Maison Consulting & Solutionshttp://www.maison-global.com/

Contents Objective. Prerequisite for Audience Dynamics Ax Microsoft Dynamics AX 2009 Architecture Data Dictionary User Interfaces Report Adjustments X++ Overview X++ Control Statements Classes and Objects Accessing the database Exception Handling Conclusion

Objective

"To present profoundly overview of Microsoft Dynamics Ax Development Introduction.

Prerequisite for Audience

What audience should know to understand Ax Development.

Algorithms, Usage Object oriented paradigm/programming Any Programming Language.

Dynamics AxMicrosoft Dynamics AX 2009 is: customizable multiple-language multiple-currency Enterprise Resource Planning (ERP) solution.Developer(s)Stable release Development status Operating system Platform Available in

Microsoft Corporation5.0.593.0 (2009) / June 2, 2008; 2 years ago Active Windows Server 2003/2008 (AOS), Microsoft Windows (Clients) x86Arabic, Chinese (Simplified), Czech, Danish, Dutch (Netherlands), English, Estonian, Finnish, Dutch (Belgium), French, German, Hungarian, Icelandic, Italian, Japanese, Latvian, Lithuanian, Norwegian, Polish, Portuguese, Russian,Spanish, Swedish, Thai, Turkish

Type License Website

Enterprise resource planning MS-EULA (End User License Agreement)

http://www.microsoft.com/dynamics/ax/default.mspx

MICROSOFT DYNAMICS AX ARCHITECTURE

Advantages of using Microsoft Dynamics AX 2009 Microsoft Dynamics AX 2009 excels in: Manufacturing E-business Wholesale Services industries completely integrated solution. Web-enabled supports Microsoft SQL Server and Oracle

Features of Microsoft Dynamics AXFunctional FeaturesSingle database architecture is for all companies in the organization Dimension-based system for Manufacturing and Financial modules A highly integrated design between functional areas such as resource planning, sales Advanced features such as Forecasting and Master Planning are available

Development Environment FeaturesMicrosoft Dynamics AX 2009 MorphX is an IDE for developing Projects help organize and track customized Applications. The .NET Business Connector provides access to the Microsoft Dynamics AX 2009

Drag-and-drop functionality for many programming tasks

Elements of Dynamics Microsoft AX Development1) Microsoft Dynamics AX 2009 Object Server three-tier environment is divided as follows: First Tier - Intelligent ClientThe thin client is the first tier and it handles the user interface and necessary program logic.

Second Tier AOS:Handles the business logic .

Third Tier - Database Server:Database runs on a server as the third tier.

Elements of Dynamics AX Development (Contd.)2) Application Object Tree(AOT) The Application Object Tree (AOT) is a tree view of all the application objects within Microsoft Dynamics AX 2009. Viewing Repository The AOT contains everything needed to customize the look and functionality of a Microsoft Dynamics AX 2009 application.

Elements of Dynamics AX Development (Contd.)

3) IntelliMorph IntelliMorph is the technology that controls the user interface in Microsoft Dynamics AX 2009. IntelliMorph controls the layout of the user interface and makes it easier to modify forms, reports, and menu.

4) MorphX The MorphX Development Suite is the integrated development environment (IDE). An IDE integrates development functions such as designing, editing, compiling, and debugging within a common environment.

Elements of Dynamics AX Development (Contd.)

5) Inheritance Think of inheritance as a child object receiving properties from a parent object.

6) X++ X++ is the object-oriented programming language that is used in the MorphX environment.

NAVIGATION

Working with Data in FormsCreating New Records Sorting Records Filtering Records Global Search: Click Basic > Setup > Data Crawler > Table Setup.

Microsoft Dynamics AX 2009 Layered Architecture The method used by Microsoft Dynamics AX 2009 to separate and control the updates and modifications made in the application is known as "layering. Layers are a hierarchy of levels in the application The standard application is never overwritten

Label Files system which systematizes all the labels (for buttons, forms, dialog boxes, and more) for a specific language in one file; a label file A label is the text that appears in the user interface. Create New Label File: Tools > Development Tools > Label > Label File Wizard.

Security (Security Structure)Four items control security in Microsoft Dynamics AX 2009: License codes include the company's purchased features. These license codes enable the whole company access to those areas purchased Configuration keys Are used to enable or disable features in the application. These keys control access for the whole company Security keys Are assigned to user groups and control access to features within Microsoft Dynamics AX 2009 at a user group level Record level security Controls access to records in tables. This means that different user groups can have different access to different records in the same table .

Inquiry and ReportsStandard Reports: Standard reports in Microsoft Dynamics AX 2009 contain predefined tables, fields, and layouts Auto Reports: Auto reports are more flexible than standard reports Select which fields to print Define report layouts Define the summation of fields Define criteria for the fields

DATA DICTIONARY

DATA DICTIONARY(Contd.)Tables: Tables store data in the system. They are organized in fields. These are assigned to different data types, depending on the type of data they hold. Data is entered, edited, and deleted through forms. Tables are discussed in more detail later in the section. Creating a Table: 1. Create a table. 2. Create extended data types. 3. Add fields to the table. Drag relevant extended data types to the Fields node of the relevant table. 4. Create relations on extended data types. 5. Create indexes.

DATA DICTIONARY(Contd.)Indexes : The indexes in the Microsoft Dynamics AX 2009 table definition are the physical indexes that exist on the tables in the database. There are two types of indexes: Unique Non-Unique Relations: Relations are a method that helps secure business rules to enforce existing properties between field values existing in different tables. This is known as referential integrity.

DATA DICTIONARY(Contd.)Data Types Primitive and Extended Microsoft Dynamics AX 2009 has built in primitive and extended data types associated with the information in the database. Primitive Data Types

Extended Data Types Extended Data types can inherit either from primitive types or other Extended Data Types, which enables properties to be inherited.

DATA DICTIONARY(Contd.)

Delete Actions: Microsoft Dynamics AX 2009 uses a category of methods called Delete Actions to govern how data is handled when a deletion event occurs in a parent tableRelations. Methods: Microsoft Dynamics AX 2009 uses methods within the table node to perform a variety of functions such as contact person and currency name lookup.

DATA DICTIONARY(Contd.)

Maps Views Extended Data Types

DATA DICTIONARY(Contd.)Base Enums : Base enums are a list of literals. They can be used throughout the development environment in MorphX.

Table Collections: Table collections do not contain any data. Virtual companies are built on table collections. They contain tables shared by more than one company. A table can be a part of more than one table collection. Perspectives : Perspectives organize tables, folders, fields, and roles, in subsets according to application modules in an intuitive way

USER INTERFACESProjects: Projects organize new or customized application objects. Think of a Project as a reference folder for related objects. Advantage of Projects is the ability to save a project's contents and state separately for each user by using Private Projects.

Forms Forms are the primary method of interaction between Microsoft Dynamics AX 2009 and a user. Elements that Compose a Form

Forms(Contd.)Creating Forms:

Menus ItemsTo enable activation of application objects from the user interface. key properties: Name - The name of this menu item Label - The label appearing on the menu item ObjectType- The type of object this item points to Object - The object name that this item points to RunOn - The location (Client or Server) where the object will run Security Key - A key defined in the data dictionary that defines the security access for the menu item Menu items type Display Output Action

Menus Items(Contd.)Creation Of Menu Item:

Menus Items(Contd.)Navigation Pane and Area Pages/Menue

Menus Items(Contd.)Adding Menue to MainMenu

New > Menu Reference

Microsoft Dynamics AX Non-graphical ObjectsClasses: Classes have the following characteristics: Classes allow reuse common functionality or business logic. Classes are a design or blueprint for a programming object. Classes can be run directly from the AOT if a Main method is defined. Classes in Microsoft Dynamics AX 2009 share the same attributes a class in C# has, such as inheritance, polymorphism, and encapsulation

Microsoft Dynamics AX Non-graphical Objects(Contd.)

Macros : Macros act as a container for defining variables used for frequent tasks. The purpose of macros is to make statements easy to reuse. A macro cannot be executed independently of a class.

Microsoft Dynamics AX Non-graphical Objects(Contd.)Jobs The jobs node on the application object tree contains small X ++ programs that are executed as batch jobs. They are useful when developing and testing new functionality for Microsoft Dynamics AX 2009. Queries Queries ask questions about data stored in a database. The information selected by a query can be used as the basis for a form, auto report.

Microsoft Dynamics AX Non-graphical Objects(Contd.)Help Documentation: System Documentation contains links to manuals for the development environment. Application Developer Documentation links to reference documentation for application tables and classes. Application Documentation contains reference documentation for the Microsoft Dynamics AX 2009 application.

REPORT ADJUSTMENTSDesign reports using the visual report Designer

REPORT ADJUSTMENTS(Contd.)Reporting Best Practices : The size of the paper in the printer The length or the contents of the labels used in the user's language The length of the fields and extended data types at the user's installation The number of dimensions at the user's installation How dates and numbers are formatted The size of amounts in the user's system The sort order of the data sent to the report If the user wants to print only the totals or subtotals What font and size the user has set up as report defaults

REPORT ADJUSTMENTS(Contd.)Report Design: AutoDesignSpecs GeneratedDesign Sections within a Report : Prolog PageHeader Section Group(Header, Footer, Body) PageFooter Epilog ProgrammableSection

REPORT ADJUSTMENTS(Contd.)How Report Looks:

X++ OVERVIEWX++ is the programming language that is used in the MorphX Development environment. key features Reliable - X++ provides extensive compile-time checking, followed by a second level of run-time checking. High Performing Interpreted and Dynamic Interoperable - Components in Microsoft Dynamics AX are seamlessly accessible to any application supporting the Component Object Model (COM) standard and .NET assembles.

Development Tools

Code Editor Jobs Compiler The Debugger Compare

Development Tools(Contd.)

Development Tools(Contd.)

Reverse Engineering Simplify collection Extract relationships Integrate and view collections in Microsoft Office Visio as UML diagrams

Naming conventionsNaming conventions contribute to consistency and to making the application easier to understand. {business area name} + {business area description} + {action performed (for classes) or type of contents (for tables)} e.g. CustInvoicePrintout All names must be in U.S. English. The default rule is to use logical and descriptive names if no other specialized rules apply. Identifier names have a limit of 40 characters. Names in the Application Object Tree (AOT) and in X++ code must correspond to the names in the U.S. English user interface. Names must be spelled correctly. Names must be used consistently. Do not begin a name with aaa, or CopyOf.

Comments

Single line // Block comments /* */ To do comments TODO. To do comments appear in the compilers Tasks tab page. /// /// This is an XML comment with tags to distinguish sections. ///

X++ CONTROL STATEMENTSData Type String Integer Real Date Enum Declaration Keyword str int Real date Must be declared as a Base Enum first boolean timeOfDay utcDateTime guid Int64 Description/Example any string 2356 3.14 24\11\2010 Enum values are represented internally as Integers. True/False 15:23:08 9/28/2008 07:11:02 am Global Unique Identifier, a reference number which is unique in any context A large integer, represent by 64 bits.

Boolean Time utcDateTime Guid Int64

X++ CONTROL STATEMENTS(Contd.)Composite Date Types

Variable Declaration: dataType variableIdentifier; Array Declaration: real realUnlimtedArray[]; real realLimitedArray[10];

// Unlimited index values // maximum of 10 values

X++ CONTROL STATEMENTS(Contd.)Containers: A variable that can contain different types and values of simple and extended data types, including arrays and other container variables. Classes cannot be put into containers. container c; int i, j; str txt; ; c = [10, 20, "test"]; print conPeek(c, 3); [i,j,txt] = c; // the container is declared

// the container has 3 values set // the third element is printed // Variables being set

X++ CONTROL STATEMENTS(Contd.)Operators: a) Assignment operatorsOperator = += ++ -= -Term Becomes equal to Description Assigns the expression on the right of the equal sign to the variable on the left. Increments the variable on the left by the value on the right. Increments the variable on the left by 1. Decrements the variable on the left by the value on the right. Decrements the variable on the left by 1.

X++ CONTROL STATEMENTS(Contd.)Operators: b) Arithmetic operators

X++ CONTROL STATEMENTS(Contd.)Operators: c) Relational operators

X++ CONTROL STATEMENTS(Contd.)Operator Precedence:

X++ CONTROL STATEMENTS(Contd.)Conditional Statements a) If Statement

Code syntex is just like c#, c++ if (condition) { //if true these statements are executed } else { //if false these statements are executed }

X++ CONTROL STATEMENTS(Contd.)Conditional Statements b) Switch statementswitch (expression) { case 'Choice1': Statement1; Statement2; break; case 'Choice2': Statement3; break; case 'Choice3': Statement4; Statement5; Statement6; break; default : DefaultStatement; }

X++ CONTROL STATEMENTS(Contd.)Conditional Statements c) Ternary Operator condition ? statement1 : statement2;

X++ CONTROL STATEMENTS(Contd.)Loops a) while loop

while (condition) { //statement; }

X++ CONTROL STATEMENTS(Contd.)Loops b) Do...while statement do { //statement; } while (condition);

X++ CONTROL STATEMENTS(Contd.)Loops c) For loop for ( initial value ; condition ; increment) { //statement; }

X++ CONTROL STATEMENTS(Contd.)Built-in functions: Built-in functions can be used anywhere in X++ code. These functions can be typed manually or accessed by using the context (right-click) menu in the code editor and selecting List Builtin Functions, or by pressing Shift+F4. Example str letters; ; letters ="ABCDEFG"; print subStr(letters, 2, 4); print subStr(letters, 5, -3); Result : BCDE CDE

X++ CONTROL STATEMENTS(Contd.)

Communication Tools: Communicating with the end-user Main types of communication are the following: Forms and reports which are used for input and output of larger amounts of data Print commands, infologs and dialog boxes which are generally used for specific data input and output

X++ CONTROL STATEMENTS(Contd.)Communication Tools: The print command print "This is a test message."; pause;

X++ CONTROL STATEMENTS(Contd.)Communication Tools: Infolog Infolog is the most common method of communicating to the user information about how a process has been executed. Boxes can output a message to a user, but sometimes multiple messages are generated during processing. Usage Example: Info ("This is an info infolog");

X++ CONTROL STATEMENTS(Contd.)Communication Tools: Boxes Boxes display brief messages to application users. There are many different box types and each has their own box method. Methods in the box class take the following parameters The main text The title bar text Help text Example box::info('Main Text', 'Title', 'This is the help text');

X++ CONTROL STATEMENTS(Contd.)Communication Tools: Dialog Dialog boxes are a simplified type of form in Microsoft Dynamics AX. They are generated from the Dialog class. Examplestatic void Simple_Dialog(Args _args) { dialog dlg; dialogGroup dlgGroup; dialogField dlgField; ; dlg = new dialog("Simple Dialog"); dlgGroup = dlg.addGroup("Customer"); dlgField = dlg.addField(TypeID(custAccount),"Account Number"); if (dlg.run()) { print dlgField.value(); pause; } }

CLASSES AND OBJECTS A class is a software construct that defines the data (state) and methods (behavior) of the specific concrete objects that are subsequently constructed from that class. How to create a Class1. Open the AOT. 2. Locate the Classes node. 3. Right-click the Classes node and select New Class in the context menu. The new class looks as shown below. 4. A new class named Class1 is created and contains one node: the classDeclaration node. It is empty by default. 5. Double-click the classDeclaration node. 6. Enter the declarations between the two { } braces. 7. Right-click on the class and select New Method. 8. Rename the method. 9. Type code between the two { } braces.

CLASSES AND OBJECTSInheritance: Inheritance is a concept where one class can inherit all the methods and variables from another class. A child class inherits the methods of the parent class. Syntex: class Child extends Parent { }

CLASSES AND OBJECTSMethod Types: a) Static Methods Static methods are methods that are attached to a class, but do not need that class to be instantiated to execute that method. They are not within the scope of the class, so any class variables are not available in a static method.static void myStaticMethod() { } myClass::myStaticMethod()

b) Main Method c) Display MethodsDisplay methods are used on forms and in reports. Display methods return a value.display itemName itemName() { inventTable inventTable ; select name from inventTable where inventTable.itemId == this.itemId; return inventTable.name; }

CLASSES AND OBJECTSMethod Types: d) Accessor Accessor methods enable other elements to set or get the values of variables in a class. It is common that they do both. str myName(str _myName = myName) { ; myName = _myName; return myName; }

CLASSES AND OBJECTSTables as Classes A place for a table buffer is automatically assigned in a table (in classes the new method is used). A table cannot inherit from other tables. Fields in tables are public; they can be referred to from everywhere. Fields in tables can be referred to directly; for example, in a report, whereas variables in a method can only be referred to using accessor methods.

ACCESSING THE DATABASEThe objectives are: Retrieve data from the database using a select statement Create, update and delete data in the database Use and build queries using kernel classes

ACCESSING THE DATABASE (Contd.)Selectstatic void Q1_Select1(Args _args) { CustTable CustTable; ; select Address from CustTable; where CustTable.AccountNum == '1102'; print CustTable.Address; pause; }

// To Loop Recordswhile select AccountNum, Name, Address from CustTable { print CustTable.AccountNum+ ": " + CustTable.Name + ": " + CustTable.Address; } pause;

ACCESSING THE DATABASE (Contd.)Createstatic void Q13_Insert(Args _args) { CustTable CustTable; ; CustTable.AccountNum = "supposedAccount1"; CustTable.Name = "SupposedName1"; CustTable.insert(); info("Inserted"); }

Countselect count(AccountNum) from CustTable; print CustTable.AccountNum; pause;

SortCustTable CustTable; ; while select CustTable Index AccountIdx //while select CustTable Order By AccountNum desc { Print CustTable.AccountNum; } pause;

ACCESSING THE DATABASE (Contd.)Update:static void Q14_Update(Args _args) { SalesTable SalesTable; ; ttsbegin; while select forupdate SalesTable where SalesTable.CustAccount == "1102" { SalesTable.SalesName = "aaaaa"; SalesTable.update(); info("Updated Successfully"); } ttscommit; }

SalesTable SalesTable; ; update_recordset SalesTable setting salesName = "Update RecordSet", DeliveryStreet = "New Address" where SalesTable.CustAccount == "1102 ; info("Updated Successfully via RecordSet");

ACCESSING THE DATABASE (Contd.)Deletestatic void Q16_Delete(Args _args) { CustTable CustTable; ; ttsbegin; select forupdate CustTable where CustTable.AccountNum == "supposedAccount1"; CustTable.delete(); info("Deleted"); ttscommit; } CustTable CustTable; ; while select forupdate CustTable where CustTable.AccountNum == "4018" delete_from CustTable where CustTable.AccountNum == "4018";

ACCESSING THE DATABASE (Contd.)

Transaction Integrity Checking It is important to ensure the integrity of all transactions within the system. When a transaction begins, to ensure data consistency, it must finish completely with predictable results. The following keywords help in integrity checking: ttsbegin Indicates the beginning of the transaction. ttscommit Indicates the successful end of a transaction. This ensures the transaction performed as intended upon completion. ttsabort Used as an exception to abort and roll back a transaction to the state before the ttsbegin.

ACCESSING THE DATABASE (Contd.)Queries: A query is an application object in the AOT A query performs the same function as the select statements, but is a better option as it allows for more flexible user interaction when defining which records are to be retrieved. Queries Using X++: Queries can also be created and manipulated using X++. There are a number of classes available that you can use to achieve this. Two important classes when executing a query are: Query() The Query() class provides the framework for the query

QueryRun() QueryRun() class starts this framework dynamically.

ACCESSING THE DATABASE (Contd.)Queries Using X++:static void Q20_ViaXPlusPlus(Args _args) { Query query; QueryBuildDataSource qbds; QueryBuildRange qbr; QueryRun queryrun; CustTable CustTable; ; query = new Query(); qbds = query.addDataSource(TableNum(CustTable)); qbr = qbds.addRange(FieldNum(CustTable,AccountNum)); qbr.value('1101'); qbds.addSortField(FieldNum(CustTable,AccountNum)); queryrun = new QueryRun(query); while(queryrun.next()) { CustTable = queryrun.get(TableNum(CustTable)); Print CustTable.AccountNum + ": " + CustTable.Name; } Pause; }

ACCESSING THE DATABASE (Contd.)Accessing data from Different Companies:static void Q10_CrossCompanies1(Args _args) { Container ConComapnies = ['cee','ceu']; CustTable CustTable; ; while select crossCompany : ConComapnies CustTable { Print CustTable.Name; } pause; }

EXCEPTION HANDLINGException: When code is running, errors can occur due to user input, setup, data, code, or installation problems. Users need a clear indication of when errors occur so they can resolve the problem or report it to an administrator or systems developer, who can investigate what went wrong.

EXCEPTION HANDLINGException Example:static void Exception3(Args _args) { CustTable custTable; ; try { custTable.AccountNum = '54299'; custTable.CustGroup = '50'; custTable.Address = 'Lahore Pakistan'; if(!custTable.validateWrite()) throw error("1. Record Failed during Validation."); custTable.insert(); info("2. Record saved in database successfully, while passing validation"); } catch(Exception::Error) { error("3. There was an error, while inserting the record."); } }

Questions

If you have any question/problem, I am here to answer [email protected] 0092 333 653 2823