Your SlideShare is downloading. ×
Microsoft Dynamics AX 2012 - Development Introduction Training - Part 2/3
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Microsoft Dynamics AX 2012 - Development Introduction Training - Part 2/3

3,281
views

Published on

Microsoft Dynamics AX 2012 - Development Introduction Training - Part 2/3

Microsoft Dynamics AX 2012 - Development Introduction Training - Part 2/3

Published in: Technology

1 Comment
11 Likes
Statistics
Notes
  • Excellent presentation. Good job guys.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
3,281
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
1
Likes
11
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Fabio FilardiDynamics AX Technical Architectffilardi@msbsgroup.com
  • 2. Microsoft Dynamics AX 2012Development Introduction Features Architecture Data Dictionary User Interface X++ Intro X++ Control Statements Objects and Classes Accessing the Database Exception Handling
  • 3. USER INTERFACE Microsoft Dynamics AX 2012 Topics  Forms  Design & Templates  Data Sources  Fact Boxes  Menu Items
  • 4. User InterfaceMicrosoft Dynamics AX 2012FormsForms are the primary method of interaction between Microsoft Dynamics AX and the end-user.Forms are composed of multiple object categories.The basic object categories of a form include:  Methods  Data Sources  Parts  Designs  Permissions
  • 5. User InterfaceMicrosoft Dynamics AX 2012Form Designs and TemplatesForm Templates allow you to create a new form with a predefined layout.Several different standard form designs are available for use in different situations. Form Template Use ListPage Main entry into a module. DetailsFormMaster View and edit master data. DetailsFormTransaction View and edit transactional and worksheet data. SimpleListDetails Reference and setup data. SimpleList Basic inquiry. TableOfContents Module configuration parameters. Dialog Quick user interaction.
  • 6. User InterfaceMicrosoft Dynamics AX 2012Form Designs and TemplatesExamples of templates:ListPage : Accounts receivable > Common > Customers > All CustomersDetailsFormMaster : Accounts receivable > Common > Customers > All Customers > EditDetailsFormTransaction : Sales and marketing > Common > Sales Orders > All sales orders > EditSimpleListDetails : General ledger > Setup > Currency > CurrenciesSimpleList : Master planning > Inquiries > Processes > Planned orders logTableOfContents : Accounts payable > Setup > Accounts payable parametersDialog : Product information management > Products > Products > New product
  • 7. User InterfaceMicrosoft Dynamics AX 2012Form Data SourcesBecause forms present data to users, they must provide a source for the data.These collections of data are called data sources and they link to the Tables in the AOT.
  • 8. User InterfaceMicrosoft Dynamics AX 2012FactBoxesA FactBox is a small selection of data related to the current record inthe list page. Three types of Factbox exist:Info part: This has its own data source and a number of controls. It islimited in what can be displayed.Form part: This is a link to a form. The form can have the samecontrols as a standard form.Cues: This is a count of a number of records related to the currentrecord in the list page.
  • 9. User InterfaceMicrosoft Dynamics AX 2012Menu ItemsThey are used to activate application objects from the user interface.Three types of menu items can be created:  Display: used for forms;  Output: used for reports;  Action: used for running processes (classes).
  • 10. X++ INTROMicrosoft Dynamics AX 2012 Topics  Introduction  Development Tools  Reverse Engineering  BestPratices
  • 11. X++ IntroMicrosoft Dynamics AX 2012Introduction X++ is the programming language used in MorphX IDE. X++ resembles other popular languages such as C# and Java. X++ includes many integrated SQL commands; X++ is object-oriented language and provides a clean and efficient object-based development platform.
  • 12. X++ IntroMicrosoft Dynamics AX 2012Characteristics Reliable: X++ provides extensive compile-time checking, followed by a second level of run-time checking. Interpreted and Dynamic: Benefit from faster development cycles - prototyping, experimentation, and rapid development, versus the traditional compile, link, and test cycles. Interoperable: Components in Microsoft Dynamics AX are seamlessly available to any application supporting .NET, and conversely X++ is able to consume external managed code and COM objects.
  • 13. X++ IntroMicrosoft Dynamics AX 2012Development ToolsX++ Editor Editor Color-Codes Blue: Reserved words Green: Comments Dark Red: Strings Bright Red: Numbers Purple: Labels Black: Everything else
  • 14. X++ IntroMicrosoft Dynamics AX 2012Development ToolsCompilerThe compiler is a translation program that converts X++ into a language that can be interpreted.Compiler Output Result Types: Error : These are compile errors, and must be resolved before code can be run. Warning : These are compile warnings, and should be resolved, but will not prevent the code from being run. Best Practice : These are found when an element contains code or properties that deviate from the list of MS Dynamics AX Developer Best Practices and are only found by the compiler when the Diagnostic level is set to Level 4. Task : Tasks are placeholders that can be added to remind developers that something is unfinished. To create a task, use a single line comment, followed by the word ToDo and a description of the task.
  • 15. X++ IntroMicrosoft Dynamics AX 2012Development ToolsDebuggerMicrosoft Dynamics AX includes a powerful stand-alone debugging tool for X++ code. Use the Debugger todebug X++ code running on the Client or Object Server (AOS):
  • 16. X++ IntroMicrosoft Dynamics AX 2012Development ToolsCompareUse the compare tool to highlight differences between versions of a single element:  In two different layers  In an old version of an element  In two different elements  An element that will be imported
  • 17. X++ IntroMicrosoft Dynamics AX 2012Development ToolsType Hierarchy Browser
  • 18. X++ IntroMicrosoft Dynamics AX 2012Reverse EngineeringReverse engineering is used to retrieve detailed information about the structures and relationships.The feature handles both reverse engineering of the data model and the object model. Data Model Object Model Tables X X Table Group Property X Table Fields X X Table Index Information X Table Methods and Parameters X Classes (extended and referenced) X All Extended Data Types X X All Base Enums X X All X++ Data Types X X
  • 19. X++ IntroMicrosoft Dynamics AX 2012Reverse EngineeringReverse engineering is used to retrieve detailed information about the structures and relationships.The feature handles both reverse engineering of the data model and the object model. Data Model Object Model Tables X X Table Group Property X Table Fields X X Table Index Information X Table Methods and Parameters X Classes (extended and referenced) X All Extended Data Types X X All Base Enums X X All X++ Data Types X X
  • 20. X++ IntroMicrosoft Dynamics AX 2012Best PraticesBest practices involve understanding all the things that you should do and distinguishing them from thethings that you can do.Some benefits of using best practices include:  They guarantee consistency throughout the code. This lets other developers more easily read and understand your code.  Code is more secure.  There is no redundant code.  Upgrading is easier and quicker, and has less risk of errors.
  • 21. X++ IntroMicrosoft Dynamics AX 2012Best PraticesNaming 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)}Examples:  CustJournalPrintOutInvoice  PriceDiscAdmDelete  PriceDiscAdmSearch  PriceDiscAdmName  PriceDiscAdmTrans
  • 22. X++ IntroMicrosoft Dynamics AX 2012Best PraticesNaming ConventionsAdditionally:  All names must be in U.S. English.  Identifier names have a limit of 40 characters.  Names must be spelled correctly.  Names must be used consistently.  All texts that appear in the user interface must be defined by using a label.  Do not begin a name with nonsensical or confusing prefixes, such as "aaa" or "CopyOf".  Do not begin a name with "DEL_" unless it is a table, extended data type or enum, and it is needed for data upgrade purposes - doing this may cause unexpected results.
  • 23. X++ IntroMicrosoft Dynamics AX 2012Best PraticesCode PlacementWhen deciding where to place code, ask the following questions:  Is the code related to the forms appearance or to the data that is entered through the form?  Can I use the codes functionality elsewhere in the application or in a different application?  Does the code execute on the client or on the server?
  • 24. X++ IntroMicrosoft Dynamics AX 2012Best PraticesCode PlacementThe placement of code depends on the code you are writing.Rule 1: The preferred procedure in an object-oriented programming language is to place code in a class thatcan be reused and called when it is needed. You can place code in classes to have better control over wherethe code is executed.Rule 2: Performance considerations frequently dictate where code should run, and so controlling this isdesirable. Code included in forms always runs on the client, and this could cause excessive client/servercommunication where it might not be necessary.BEST PRACTICE: Always place the code nearest to the source so that it can be more easily manipulated. Forexample, code that manipulates a table should be placed in that tables methods.
  • 25. X++ IntroMicrosoft Dynamics AX 2012Best PraticesCommentsIt is important when developing X++ programs in Microsoft Dynamics AX to use comments and documentwhat the code does and how parameters are used. It is also good to know who made the change and why.Note the following about how to use comments:  Comments can be inserted directly into the lines of code.  Comments are ignored by the compiler.  Comments turn the code green in the editorSome of the comments include the following:  Single line "//"  Block comments "/* */"  XML documentation comments
  • 26. X++ CONTROL STATEMENTS Microsoft Dynamics AX 2012 Topics  Variables  Operators  Conditional Statements  Loops  Communication Tools
  • 27. X++ Control StatementsMicrosoft Dynamics AX 2012VariablesVariables hold data when a block of code executes. All variables have scope: Scope Description Global (to a class) These are variables defined in the classDeclaration of a class. Local (to a method) These are variables defined in a method of a class. Local (to an embedded function) These are variables defined in a function embedded in a method of a class.  Use the type of variable that matches the type of data that you want to store;  Do not use names the system already uses, such as commands or keywords.  Always give a variable a meaningful name so its use is easier to identify when reading the code.
  • 28. X++ Control StatementsMicrosoft Dynamics AX 2012VariablesDeclaration  All variables must be declared before use.  The syntax of the declaration is the always same;  You cannot mix variable declarations with other X++ statements;  X++ supports initialization of variables in the declaration statement.Rules when declaring:  Declare all variables before anything else in the code;  Use a semicolon after each declaration;  Variable type can be any of the data types in X++, and you can also declare them as an extended data type.
  • 29. X++ Control StatementsMicrosoft Dynamics AX 2012Simple Data Types Data Type Description Example Declaration Keyword String A string is a number of characters. The maximum Name str length of a string is 999 characters. Integer An integer (natural) figure, is a number without a 1090 int decimal point. Real Reals (decimals), are numbers with a decimal point. 3.14 real Date The date type contains day, month, and year. 14/03/2012 date UTC DateTime Contains year, month, day, hour, minute and second. 14/03/2012 07:11:02 am utcDateTime Enum Enum values are represented internally as integers. NoYes Must be declared as a You can use enums as integers in expressions. BaseEnum first Boolean Booleans can only contain the values false and true. TRUE boolean Time Contains hours, minutes, and seconds. 15:23:08 timeOfDay GUID Global Unique Identifier is a reference number which {3F2504E0-4F89-11D3-9A0C-0305E82C3301} guid is unique in any context. Int64 A large integer, represented by 64 bits. 5637144579 Int64
  • 30. X++ Control StatementsMicrosoft Dynamics AX 2012VariablesComposite Data TypesThe following composite data types are available: Data Ttype Description Array* An array is a list of items with the same data type and the same name; only the index differs. Container* A container is a dynamic list of items that can contain primitive data types and some composite data types. Classes A class is a type definition that describes both variables and methods for instances (objects) of the class. Tables All tables defined in the database (in the data dictionary) can be handled as class definitions.
  • 31. X++ Control StatementsMicrosoft Dynamics AX 2012VariablesArraysArrays can be declared by adding brackets [ ].You can set the maximum number of array elements by putting the number in the brackets.Array values can be set by specifying the index when assigning the value.
  • 32. X++ Control StatementsMicrosoft Dynamics AX 2012VariablesContainersA container variable can contain different types and values of simple and extended data types, includingarrays and other container variables.Classes cannot be put into containers.
  • 33. X++ Control StatementsMicrosoft Dynamics AX 2012VariablesContainersThere are many functions that manipulate container variables: Function Description conPeek Returns the value being held in a specific position in the container. conDel Removes a value from a specific position in the container. conNull Returns an empty container. conFind Finds the position in the container that a certain value is being held (if found). conIns Inserts a value into a specific position in the container. conPoke Replaces the value in a specific position in the container with a new value. conLen Returns the number of elements in the container.
  • 34. X++ Control StatementsMicrosoft Dynamics AX 2012OperatorsOperators are used to manipulate variable and field values and to control the logical program flow based onthe values in variables and fields.The following types of operators are available: Assignment operators: modify the contents of a variable or field. Arithmetic operators: perform mathematical operations on the values in a variable or field. Relational operators: evaluate how two values relate to one another and return either True or False according to the result
  • 35. X++ Control StatementsMicrosoft Dynamics AX 2012OperatorsAssignment Operators Operator Description = Assigns the expression on the right of the equal sign to the variable on the left. += Assigns the variable on the left the current variable value plus the expression on the right. ++ Increments the variable by one. -= Assigns the variable on the left the current variable value minus the expression on the right. -- Decrements the variable by one.
  • 36. X++ Control StatementsMicrosoft Dynamics AX 2012OperatorsArithmetic Operators Operator Term Description << Left shift Performs expression2 left shift (a multiplication by 2) on expression1. >> Right shift Performs expression2 right shift (a division by 2) on expression1. * Multiply Multiplies expression1 by expression2. / Divide Divides expression1 by expression2. DIV Integer division Performs an integer division of expression1 by expression2. MOD Integer remainder Returns the remainder of an integer division of expression1 by expression2. ~ Not Unary operator. Performs a binary not-operation. & Binary AND Performs a binary and-operation on expression1 and expression2. ^ Binary XOR Performs a binary XOR-operation on expression1 and expression2. | Binary OR Performs a binary or-operation on expression1 and expression2. + Plus Adds expression1 to expression2. - Minus Subtracts expression2 from expression1. ? Ternary operator Takes three expressions: expression1 ? expression2 : expression3. If expression1 is true, expression2 is returned; otherwise, expression3 is returned.
  • 37. X++ Control StatementsMicrosoft Dynamics AX 2012OperatorsArithmetic OperatorsExamples: Evaluated Expression Return Value i++ Increments the i variable by one. i-- Decrements the i variable by one. i += 2 Increments the i variable by two every time. i -= 3 Decrements the i variable by three every time. i = 3 << 3 i = 24 (i = 3*2*2*2) i = 24 >> 2 i = 6 (i = 24/2/2) i = 80 DIV 13 i = 6 (6 is the largest number that 13 can be multiplied by, where the result is less than or equal to 80. In this case, 6*13 = 78, remainder 2) i = 80 MOD 13 i = 2 (2 is the remainder after dividing 80 by 13)
  • 38. X++ Control StatementsMicrosoft Dynamics AX 2012OperatorsRelational Operators Operator Meaning Description like like Returns true if expression1 is like expression2. This can use * as a wildcard for zero or more characters and ? as a wildcard for one character. == equal Returns true if both expressions are equal. >= greater than or equal to Returns true if expression1 is greater than or equal to expression2. <= less than or equal to Returns true if expression1 is less than or equal to expression2. > greater than Returns true if expression1 is greater than expression2. < less than Returns true if expression1 is less than expression2. != not equal Returns true if expression1 is different from (that is, not equal to) expression2. && and Returns true if both expression1 and expression2 are true. || or Returns true if expression1 or expression2 or both are true. ! not A unary operator. Negates the expression. Returns true if the expression is false; false if the expression is true.
  • 39. X++ Control StatementsMicrosoft Dynamics AX 2012OperatorsRelational OperatorsExamples: Evaluated Expression Return Value abcdef like abc* TRUE: the * is equal to any string of characters. abcdef like abc? FALSE: the ? is equivalent to one character. 9 != 10 TRUE: these values are not equal to one another. (10 > 9) && (11 <= 11) TRUE: both expressions are true. !(abc = = def) || (8 > 9) TRUE: the first expression returns true.
  • 40. X++ Control StatementsMicrosoft Dynamics AX 2012OperatorsRelational OperatorsExamples: Evaluated Expression Return Value abcdef like abc* TRUE: the * is equal to any string of characters. abcdef like abc? FALSE: the ? is equivalent to one character. 9 != 10 TRUE: these values are not equal to one another. (10 > 9) && (11 <= 11) TRUE: both expressions are true. !(abc = = def) || (8 > 9) TRUE: the first expression returns true.
  • 41. X++ Control StatementsMicrosoft Dynamics AX 2012Conditional StatementsConditional statements in programming define conditions under which certain functions are performed.Conditional statements use logical expressions that are evaluated and return a value of either true or false.There are three primary conditional statements:  If..Else statement  Switch statement  Ternary operators
  • 42. X++ Control StatementsMicrosoft Dynamics AX 2012LoopsLoops are repetitive statements, conditionally control data input and output.There are three main loops in X++:  While loop  Do..While loop  For statement
  • 43. X++ Control StatementsMicrosoft Dynamics AX 2012Communication ToolsThe main types of communication include: Forms and reports used for input and output of larger amounts of data. Print statements, Boxes, Infologs and dialog boxes generally used for specific data input and output.Examples: print "This is a test message."; Box::info("Main Text", "Title", "This is the help text"); Box::warning("This is a warning message.", "Title text", "Help text"); Box::yesNo("Choose Yes or No", DialogButton::Yes, "Yes No Box Example", "Answer Yes or No"); info("This is an info infolog"); warning("Infolog text"); error("Infolog text");