ERP (Enterprise Resource Planning) : AX Training Documentation
ERP (Enterprise Resource Planning) : AX Training Documentation
2
AX Training Documentation
ERP (Enterprise Resource Planning)
Enterprise resource planning (ERP) is business process management software that allows a
0rganization to use a system of integrated applications to manage the business and automate many
back office functions related to technology, services and human resources. ERP software integrates
all facets of an operation including product planning, development, manufacturing, and sales and
marketing in a single database, application and user interface.
Types of ERP’s:
There are different types of ERP systems ranging from industry-specific ERP solutions such as
those offered by large business ERP to small business ERP. The type of ERP system that will work
best for your business depends on the size of your organization and the functions of the ERP
solution that can best support your business requirements. Some of the ERP’s are SAP, Oracle and
Microsoft Dynamics.
Microsoft Dynamics AX is an enterprise resource planning (ERP) solution for midsize and larger
organizations that helps people to work effectively, manage change, and compete globally.
3
AX Training Documentation
Architecture of Dynamics AX
The Microsoft Dynamics is a three tier Architecture.
Client: Allows user to access data from the database and run the business logic on the
server.
Server: Responsible for running the application business logic.
Database: For the purpose of storing data.
Client (User Interface): The end user accesses the application through the user Interface which
is the Microsoft Dynamics rich client or Enterprise Portal.
Server (Application Object Server –AOS): The AOS runs the business logic of the application.
Database (SQL Server Database): Microsoft Dynamics AX application uses data and data model
stored in the SQL Server Database.
4
AX Training Documentation
Client Workspace
The client workspace has the following components: The following image shows the highlighted
areas of Client Workspace:
Title bar: The Title bar is located at the top of the window. This standard Microsoft
Windows feature displays the application name, license name, server name, and the
company code.
Address bar: The Address bar is located underneath the Title bar. It gives a "breadcrumb"
trail that shows where you have been in the program and how to return.
File menu: The File menu is located under the Address bar. t gives access to general
functions and tools available in the application.
Windows: menu lets you open a new application workspace or a new developer
workspace.
View: menu lets you personalize your workspace.
Help: menu gives multiple options to get help with using the application.
Navigation pane: is located on the left and displays the application menu.
Content pane: is the main area. Role centers, Area pages and List pages are displayed
within the content pane.
Status bar: is located at the bottom of the application window. The Status bar can display
information such as the user ID, date, time, company and help text. Information displayed
on the status bar.
5
AX Training Documentation
Development Environments:
Morphx IDE:
Visual Studio
Any Manage Code will be written here Report Customization and Development
Remote Debugging Tools. Application Explorer
Microsoft Dynamics AX users are internal employees of your organization, or external customers
and vendors, who require access to Microsoft Dynamics AX to perform their jobs.
6
AX Training Documentation
AOT (Application Object Tee)
The application object tree (AOT) is a hierarchically structure where all the Dynamics AX objects
are defined. If you open the AOT by launching the development environment (CTRL-D) you will
see the following folder structure. Each different type of object will be stored in these subfolders
(or nodes) depending on its nature.
7
AX Training Documentation
Datatypes
Data type specifies the size and type of values that can be stored in an identifier
Data types in AX are classified into two types:
Extended data types (EDTs) are user-defined types, based on the primitive data types boolean,
integer, real, string, and date, and the composite type container. You can also base EDTs on other
EDTs.
Benefits of EDT’s:
Base Enums are fixed values or simply we can defined as list of literals. The value of Base Enums
starts with 0 and the range of Base Enums that we can add up to is 0 to 255.
8
AX Training Documentation
Tables
Tables are the foundation objects in Microsoft Dynamics AX and store data used by the system.
A table is made up of records (or rows) that contain information about a single entry in the table.
For example, a specific customer or product. A record consists of one or more fields (or columns)
that contain a discrete piece of data of a specific data type.
In Microsoft Dynamics AX, tables are located in the Application Object Tree (AOT) under
the Data Dictionary\Tables node. Each table contains the following primary elements:
Fields
Field Groups
Indexes
Relations
DeleteActions
Methods
A table name can contain letters and numbers but must begin with a letter. Spaces and special
characters are not allowed.
Creation of Tables:
Tables are created under AOT > Data Dictionary > Tables
In order to create a new record in the table we use shortcut key as Crtl + N
Property Description
9
AX Training Documentation
CacheLookup Determines how to cache the records retrieved during a lookup
operation.
This CacheLookup property exists only on tables that do not
inherit from another table.
CreatedBy Indicates whether the system maintains the CreatedBy field for
the records in a table. This field contains information about who
created a particular record.
Extends Derives the table from another table that is chosen as the
property value.
The value is null when the SupportInheritance property is set
to Yes.
ListPageRef Specifies a display menu item that points to a form that can show
a list of this record type.
ModifiedBy Indicates whether the system maintains the ModifiedBy field for
the records in a table. This field records the person who
performed the last modification to a record.
ReplacementKey Specifies the fields to display as the identifier for data in some
form controls.
SaveDataPerCompany Indicates whether the data for the current company is saved.
If you set the property to No, data is saved without a company
identifier (DataAreaId).
11
AX Training Documentation
SaveDataPerPartition Shows whether the table has a system field named Partition. This
is meant to be a read-only system field.
If the table has a Partition field, each record is assigned to one
partition. Each record is kept hidden from data access operations
that are run under the context of other partitions.
SupportInheritance Setting this property to Yes enables you to set a value for other
inheritance related properties such as Extends and Abstract.
Visible Specifies the access rights when the table is used as a data source
in a form or a report.
Fields:
The Fields node contains all the fields in the table. By specifying a field's data type, you define the
type of data that can be stored in it. Each field in a table has a number of properties that describe
the behavior of the field. The Type property contains the native data type of the field.
Properties of Fields:
Every field has some important properties based on the types of field you choose you must
follow these properties
12
AX Training Documentation
Property Description
AllowEditOnCreate Determines whether users are allowed to enter data in the field
when a new record is created from a form.
ExtendedDataType Determines the extended data type to be used for this field.
HelpText Specifies the help string for the field. The help string is displayed
when the field is used in a form.
Label Specifies a label for the field. This will appear in forms and reports.
See also AnalysisLabel (in a previous row).
Visible Determines whether the field should be visible in the user interface.
13
AX Training Documentation
Indexes
Indexes are created on tables for faster retrieval of data and it also enhances the better performance.
Each table must have one or more indexes.
Types of Indexes:
Unique Indexes: Unique indexes will not allow duplicates. An index can be set to unique
when the property ‘AllowDuplicates’ is set to ‘No’.
Non-unique Indexes: Non-Unique indexes will allow duplicates. This can be done when
the property of index ‘AllowDuplicates’ is set to ‘Yes’.
Create an Index:
1. In the AOT, locate the table that you want to add an index to, right-click the Indexes node,
and then click New Index.
2. Right-click the new index, and then click New Field.
3. Right-click the field you added in step 3, click Properties, and then select a field from the
DataField property list.
4. Right-click the new index, and then click Properties.
5. Specify that the index is a non-unique index, confirm that the AllowDuplicates property is
set to Yes.
14
AX Training Documentation
Relations
Relations can be created between two tables only if there is a related data. Generally relations are
defined on child tables.
1. Normal Relation
2. Related Fixedfield Relation
3. Fixed Field Relation
4. Foreignkey Relation
Normal Relation:
In the Field property, select the field in the primary table that relates to a field in the present table.
In the RelatedField property, select the field in the related table.
Field fixed:
In the Field property, select the field in the primary table to use to restrict the records. In the Value
property, enter the value of the selected field as the filter. This relates only records in the primary
table that match that field value.
In the Value property, enter the filter value of the selected field. This causes only records in the
related table that match that field value to be related. In the Field property, select the field in the
related table to restrict the records. Each of the related fields are AND'ed in the table relation
ForeignKey Relation:
To specify a correspondence between a foreign key field in the present table to the primary key
field in another parent table.
15
AX Training Documentation
Delete Actions
Delete actions are added in the AOT, by right-clicking on the DeleteActions node of a Table AOT
element. Select New Delete Action and then select the table on which this delete action will be
based.
None
Cascade
Restricted
Cascade + Restricted
None:
A none deletion action will delete selected row in the table but nothing occurs to the table that
relate to this table.
Cascade:
A cascading deletion action will delete all records in the related table, where the foreign key is
equivalent to the primary key of the current table. That is, deleting the parent record will also delete
the child record(s) in the related table.
Restricted:
In cascade delete action if you try to delete any records in parent table it populates a warning
message that records cannot be deleted as the related data is child table.
Cascade + Restricted:
In The delete action performs a restricted, if the record of the table will be deleted directly and
performs a cascade, if the record of the table will be deleted through a cascade delete action of a
other table.
16
AX Training Documentation
Types of tables
There are three types of table in AX they are;
Value Description
Temporary InMemory A temporary table that exists as an indexed sequential access method
(ISAM) file. The ISAM file can exist on either the client tier of the
Application Object Server (AOS) tier. The underlying Microsoft SQL
Server has no connection to the ISAM file.
The system does allow you join an InMemory table in the X++ SQL
syntax. However, joins and other set operations with InMemory tables
are usually inefficient.
Temporary TempDB A temporary table that resides in the TempDB database of the
underlying SQL Server. The nonstandard format of a TempDB table
causes the table to be dropped when it is no longer in use by the
current method. Joins and other set operations on TempDB tables can
be efficient.
Jobs:
17
AX Training Documentation
Conditional Statements
In programming languages such as X++, you can specify conditions under which a block of code
must be executed or skipped. Each conditional test evaluates to either true or false.
The if statement evaluates a question (a condition) and executes a statement or set of statements if
the condition is true. You can provide an alternative statement or set of statements that are executed
if the condition is false (the else statement).
Syntax:
if ( expression ) statement [ else statement ]
Example
Without else With else
if (a>4) if (a>4)
{ {
print a; print a;
} }
else
{
print "a is less than or equal to 4";
}
Switch Statements:
The switch statement is a multi-branch language construct. You can create more than two branches
by using the switch statement. This is in contrast to the if statement. You have to nest statements
to create the same effect.
Syntax
switch ( Expression )
{
case Constant :
Statement ;
break;
...
default:
Statement ;
break;
}
18
AX Training Documentation
Example:
switch (Cust.AccountNo)
{
case "1000" :
do_something;
break;
case "2000" :
do_something_else;
break;
default:
default_statement;
break;
}
Ternary Operator:
The ternary operator is a conditional statement that resolves to one of two expressions. This means
that a ternary operation statement can be assigned to a variable.
Syntax
expression1 ? expression2 : expression3
19
AX Training Documentation
Loops
Loops are repetitive constructs. X++ has three kinds of loops:
while loops
do...while loops
for loops
While Loops:
A while loop enables you to repeatedly execute one or more statements, as long as a condition is
true. The statement is executed from zero (not at all) to many times, depending on how many times
the condition is met.
Syntax
while ( expression ) statement
statement can be replaced by a block of statements.
Do...while Loops:
The do...while loop is similar to the while loop, but differs in that the condition follows the
statement. The statement is always performed at least once. The do...while loop is well suited for
tasks that always must be done at least once
Syntax
do
{ statement }
while
( expression ) ;
statement can be a block of statements.
For Loops:
The for loop is very similar to the while loop, but has the following additions:
The initial value to a control variable can be assigned.
There is a statement for incrementing or decrementing the variable.
Syntax
Variables are the data for the class. Variables in an X++ class are specific to objects that are
constructed from that class. Every object constructed from the class declaration has its own copy
of the variables. Such variables are known as instance variables. You cannot declare static
variables in X++.
Syntax of Class:
Class classname( )
{
public Methods that are declared as public are accessible anywhere the class is accessible
and can be overridden by subclasses. Methods that have no access modifier are
implicitly public.
protected Methods that are declared as protected can only be called from methods in the
class and in subclasses that extend the class where the method is declared.
private Methods that are declared as private can be called only from methods in the class
where the private method is declared.
21
AX Training Documentation
Methods in X++
Methods is a collection of statements that are grouped together to perform an operation.
Instance methods
Static methods
Main methods
Instance Methods
Instance methods, or object methods, are embedded in each object that is created from the class.
They are called by using the following syntax:
objectHandleName.methodName();
You must instantiate the object before you can use the method.
Static Methods
Static methods, or class methods, belong to a class and are created by using the keyword static.
They are called by using the following syntax:
ClassName::methodName();
You do not need to instantiate an object before you use static methods. Static methods are widely
used in Microsoft Dynamics AX to work with data that is stored in tables.
Main Methods
A main method is a class method that is executed directly from a menu option.
The method should only create an instance of the object and then call the necessary member
methods. The _args parameter allows you to transfer data to the method.
22
AX Training Documentation
Select Statements
X++ uses select statements to fetch data from the database. And the advantage of X++ is that Select
statements can be written from code like any other statements.
1. Declare variable: In order to use a select statement you must first declare variables for the
tables being referenced
2. While select: A special form of the while statement, while select, can be used to create a loop
that will fetch all of the records that fulfill specific criteria.
3. Selection criteria: The selection criteria are defined using expressions based on operators and
variables. Just prepare a criteria based on your requirements and while select will take care of
rest.
CustTable custTable;
void printTel()
{
CustTable custTable;
;
23
AX Training Documentation
Table Methods
Whenever records are changed, inserted or deleted from a table various default methods are
executed. We can change the default methods and by doing so we are overriding the default
methods. To override a method go to the Methods node of a table, right click and choose Override
Method. Below are few examples of Overriding commonly used Table methods:
System-defined
Description
method
initValue Executed when a new record is added. If you want initializing some default
values in the time of creating new record initvalue ( ) method is called.
modifiedField Each time the value of a field is changed the method modifiedField ( )
is called. It is useful to initialize the values of other fields if the value of
the current field is changed.
validateWrite Executed when a record is written to the database, before the data change is
committed in the database.
The super() call examines all fields for the setting of
the Mandatory property.
24
AX Training Documentation