SlideShare a Scribd company logo
1 of 68
Introduction to
X++
X++ is a programming language used in Microsoft Dynamics AX (now known as Dynamics 365 Finance and Operations)
for developing business applications. It's a powerful language tailored for working with data in the context of enterprise
resource planning (ERP) systems.
What is Data-Aware Programming?
It is application aware because it includes keywords such as client, server, changecompany, and display that are useful for writing
client/server enterprise resource planning (ERP) applications.
It is data aware because it includes keywords such as firstFast, forceSelectOrder, and forUpdate, as well as a database query syntax,
that are useful for programming database applications.
You use the Microsoft Dynamics AX designers and tools to edit the structure of application types. You specify the behavior of
application types by writing X++ source code in the X++ editor.
The X++ compiler compiles this source code into bytecode intermediate format. Model data, X++ source code, intermediate bytecode,
and .NET common intermediate language (CIL) code are stored in the model store.
The Microsoft Dynamics AX runtime dynamically composes object types by
loading overridden bytecode from the highest-level definition in the model layering
stack. Objects are instantiated from these dynamic types. Similarly, the compiler
produces .NET CIL from the X++ source code from the highest layer.
.NET supports two kind of coding
1. Managed Code
2. Unmanaged Code
Managed code is the one that is executed by the CLR of the . NET framework while unmanaged or
unsafe code is executed by the operating system.
The managed code provides security to the code while undamaged code creates security threats.
Managed Code
The resource, which is with in your application domain is, managed code. The resources that are within domain are faster.
Unmanaged Code
The code, which is developed outside .NET, Framework is known as unmanaged code.
Syntax Basics
● X++ is case-insensitive, meaning uppercase and lowercase letters are treated the same.
● Statements are terminated with a semicolon (;).
● Curly braces ({}) are used to define code blocks, such as loops and functions.
● Comments can be added using double slashes (//) for single-line comments or slash-asterisk (/* */) for multiline
comments.
Variables and Data Types:
● Variables are declared using the "var" keyword, followed by the variable name and its data type.
● Common data types in X++ include int, real, str, date, time, container, etc.
Operators:
● X++ supports various operators, including arithmetic, assignment, logical, comparison, etc.
● Arithmetic operators: +, -, *, /, %
● Assignment operator: =
● Comparison operators: ==, !=, >, <, >=, <=
● Logical operators: && (AND), || (OR), ! (NOT)
Control Flow Statements:
● Conditional statements:
● The "if" statement is used for basic conditional branching.
● The "switch" statement is used for multiple conditional branches.
Loops:
● X++ provides several types of loops, such as "for," "while," and "do-while" loops.
● The "for" loop is used when you know the number of iterations in advance.
● The "while" loop is used when the number of iterations is uncertain.
● The "do-while" loop is similar to the "while" loop, but it guarantees at least one execution.
Functions:
● Functions allow you to encapsulate a block of code for reuse.
● Functions in X++ are declared using the "public" or "private" access modifiers, followed by the return type, function
name, and parameters (if any).
● The "void" keyword is used as the return type for functions that don't return a value.
Jobs
Jobs are globally defined functions that execute in the Windows client run-time environment. Developers
frequently use jobs to test a piece of business logic because they are easily executed from within the MorphX
development environment, by either pressing F5 or selecting Go on the command menu. However, you shouldn’t
use jobs as part of your application’s core design. The examples provided in this chapter can be run as jobs.
Jobs are model elements that you create by using the Application Object Tree (AOT).
The next slide
X++ code provides an example of a job model element that prints the string “Hello World” to an automatically
generated window. The pause statement stops program execution and waits for user input from a dialog box.
static void myJob(Args _args)
{
print "Hello World";
pause;
}
The type system
The Microsoft Dynamics AX runtime manages the storage of value type data on the call stack and reference type objects on the
memory heap. The call stack is the memory structure that holds data about the active methods called during program execution.
The memory heap is the memory area that allocates storage for objects that are destroyed automatically by the Microsoft Dynamics AX
runtime.
Reference types
Reference types include the record types, class types, and interface types:
● The record types are table, map, and view. User-defined record types are dynamically composed from application model
layers. Microsoft Dynamics AX runtime record types are exposed in the system application programming interface (API).
● Although the methods are not visible in the AOT, all record types implement the methods that are members of the system xRecord type,
a Microsoft Dynamics AX runtime class type.
● User-defined class types are dynamically composed from application model layers and Microsoft Dynamics AX runtime
class types exposed in the system API.
● Interface types are type specifications and can’t be instantiated in the Microsoft Dynamics AX runtime. Class types can,
however, implement interfaces.
Type hierarchies
The X++ language supports the definition of type hierarchies that specify generalized and specialized relationships between class types
and table types. For example, a check payment method is a type of payment method. A type hierarchy allows code reuse. Reusable code
is defined on base types defined higher in a type hierarchy because they are inherited, or reused, by derived types defined lower in a
type hierarchy.
The anytype type
The Microsoft Dynamics AX type system doesn’t have a single base type from which all types ultimately derive. However, the anytype
type imitates a base type for all types. Variables of the anytype type function like value types when they are assigned a value type
variable and like reference types when they are assigned a reference type variable.
You can use the SysAnyType class to explicitly box all types, including value types, and make them function like reference types.
The anytype type, shown in the following code sample, is syntactic sugar that allows methods to accept any type as a parameter or allows a method to return different types:
static str queryRange(anytype _from, anytype _to)
{
return SysQuery::range(_from,_to);
}
You can declare variables by using anytype. However, the underlying data type of an anytype variable is set to match the first
assignment, and you can’t change its type afterward, as shown here:
anytype a = 1;
print strfmt("%1 = %2", typeof(a), a); //Integer = 1
a = "text";
print strfmt("%1 = %2", typeof(a), a); //Integer = 0
The common type
The common type is the base type of all record types. Like the anytype type, record types are context-dependent types whose variables
can be used as though they reference single records or as a record cursor that can iterate over a set of database records.
By using the common type, you can cast one record type to another (possibly incompatible) record type, as shown in this example:
//customer = vendor; //Compile error
common = customer;
vendor = common; //Accepted
Declaring variables with the same name as their type is a best practice. At first
glance, this approach might seem confusing. Consider this class and its
getter/setter method to its field:
Class Person
{
Name name;
public Name Name(Name _name = name)
{
name = _name;
return name;
}
}
Expressions
X++ expressions are sequences of operators, operands, values, and variables
that yield a result.
this //Instance member access
element //Form member access
<datasource>_ds //Form data source access
<datasource>_q //Form query access
x.y //Instance member access
E::e //Enum access
a[x] //Array access
[v1, v2] = c //Container access
Table.Field //Table field access
Table.(FieldId) //Table field access
(select statement).Field //Select result access
System.Type //CLR namespace type access
System.DayOfWeek::Monday //CLR enum access
x = y + z // Addition
x = y - z // Subtraction
x = y * z // Multiplication
x = y / z // Division
x = y div z // Integer division
x = y mod z // Integer division remainder
x = y & z // Bitwise AND
x = y | z // Bitwise OR
x = y ^ z // Bitwise exclusive OR (XOR)
x = ~z // Bitwise complement
x ? y : z
Logical operators
if (!obj) // Logical NOT
if (a && b) // Logical AND
if (a || b) // Logical OR
Method invocations
super() //Base member invocation
MyClass::m() //Static member invocation
myObject.m() //Instance member invocation
this.m() //This instance member invocation
myTable.MyMap::m(); //Map instance member invocation
f() //Built-in function call
new MyClass() //X++ object creation
new System.DateTime() //CLR object wrapper and
//CLR object creation
new System.Int32[100]() //CLR array creation
Parentheses
(x)
Relational operators
x < y // Less than
x > y // Greater than
x <= y // Less than or equal
x >= y // Greater than or equal
x == y // Equal
x != y // Not equal
select t where t.f like "a*" // Select using wildcards
x = y << z // Shift left
x = y >> z // Shift right
String concatenation
"Hello" + "World"
Values and variables
"string"
myVariable
Statements
X++ statements specify object state and object behavior.
Statement
.NET CLR interoperability statement
Example
System.Text.StringBuilder sb;
sb = new System.Text.StringBuilder();
sb.Append("Hello World");
print sb.ToString();
pause;
Data-aware statements
The X++ language has built-in support for querying and manipulating database
data. The syntax for database statements is similar to Structured Query Language
(SQL), and this section assumes that you’re familiar with SQL.
The following code shows how a select statement is used to return only the first selected
record from the MyTable database table and how the data in the record’s myField field is
printed:
static void myJob(Args _args)
{
MyTable myTable;
select firstOnly * from myTable where myTable.myField1 == "value";
print myTable.myField2;
pause;
}
The “* from” part of the select statement in the example is optional. You can
replace the asterisk (*) character with a comma-separated field list, such as
myField2, myField3. You must define all fields, however, on the selection table
model element, and only one selection table is allowed immediately after the from
keyword. The where expression in the select statement can include any number of
logical and relational operators. The firstOnly keyword is optional and can be
replaced by one or more of the optional keywords.
Introduction to X++ Programming Language

More Related Content

What's hot

Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.netDeep Patel
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsAshwin Dinoriya
 
FP304 DATABASE SYSTEM FINAL PAPER
FP304    DATABASE SYSTEM FINAL PAPERFP304    DATABASE SYSTEM FINAL PAPER
FP304 DATABASE SYSTEM FINAL PAPERSyahriha Ruslan
 
Developer's guide to customization
Developer's guide to customizationDeveloper's guide to customization
Developer's guide to customizationAhmed Farag
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2Mohd Tousif
 
Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handoutsjhe04
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb netZishan yousaf
 
AX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideAX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideBiswanath Dey
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentationdimuthu22
 
Conditional formatting in excel v2
Conditional formatting in excel v2Conditional formatting in excel v2
Conditional formatting in excel v2m182348
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Achmad Solichin
 

What's hot (20)

Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.net
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
Sql task
Sql taskSql task
Sql task
 
FP304 DATABASE SYSTEM FINAL PAPER
FP304    DATABASE SYSTEM FINAL PAPERFP304    DATABASE SYSTEM FINAL PAPER
FP304 DATABASE SYSTEM FINAL PAPER
 
Developer's guide to customization
Developer's guide to customizationDeveloper's guide to customization
Developer's guide to customization
 
Sap scripts
Sap scriptsSap scripts
Sap scripts
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2
 
Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handouts
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb net
 
JSP
JSPJSP
JSP
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
AX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideAX 2012 R3 Installation Guide
AX 2012 R3 Installation Guide
 
SAP Smart forms
SAP Smart formsSAP Smart forms
SAP Smart forms
 
ASP.NET Web form
ASP.NET Web formASP.NET Web form
ASP.NET Web form
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
sap script overview
sap script overviewsap script overview
sap script overview
 
Conditional formatting in excel v2
Conditional formatting in excel v2Conditional formatting in excel v2
Conditional formatting in excel v2
 
Asp Architecture
Asp ArchitectureAsp Architecture
Asp Architecture
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
 

Similar to Introduction to X++ Programming Language

Similar to Introduction to X++ Programming Language (20)

unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java script
 
C#
C#C#
C#
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
CSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdfCSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdf
 
C intro
C introC intro
C intro
 
C++ language
C++ languageC++ language
C++ language
 
Asp.net main
Asp.net mainAsp.net main
Asp.net main
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
 
434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# program
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
Csharp generics
Csharp genericsCsharp generics
Csharp generics
 
LEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMTLEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMT
 
PRELIM-Lesson-2.pdf
PRELIM-Lesson-2.pdfPRELIM-Lesson-2.pdf
PRELIM-Lesson-2.pdf
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
 
E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
 

Recently uploaded

Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Deliverybabeytanya
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 

Recently uploaded (20)

Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 

Introduction to X++ Programming Language

  • 2. X++ is a programming language used in Microsoft Dynamics AX (now known as Dynamics 365 Finance and Operations) for developing business applications. It's a powerful language tailored for working with data in the context of enterprise resource planning (ERP) systems.
  • 3.
  • 4. What is Data-Aware Programming? It is application aware because it includes keywords such as client, server, changecompany, and display that are useful for writing client/server enterprise resource planning (ERP) applications. It is data aware because it includes keywords such as firstFast, forceSelectOrder, and forUpdate, as well as a database query syntax, that are useful for programming database applications.
  • 5. You use the Microsoft Dynamics AX designers and tools to edit the structure of application types. You specify the behavior of application types by writing X++ source code in the X++ editor. The X++ compiler compiles this source code into bytecode intermediate format. Model data, X++ source code, intermediate bytecode, and .NET common intermediate language (CIL) code are stored in the model store.
  • 6. The Microsoft Dynamics AX runtime dynamically composes object types by loading overridden bytecode from the highest-level definition in the model layering stack. Objects are instantiated from these dynamic types. Similarly, the compiler produces .NET CIL from the X++ source code from the highest layer.
  • 7.
  • 8.
  • 9. .NET supports two kind of coding 1. Managed Code 2. Unmanaged Code
  • 10. Managed code is the one that is executed by the CLR of the . NET framework while unmanaged or unsafe code is executed by the operating system. The managed code provides security to the code while undamaged code creates security threats.
  • 11. Managed Code The resource, which is with in your application domain is, managed code. The resources that are within domain are faster.
  • 12. Unmanaged Code The code, which is developed outside .NET, Framework is known as unmanaged code.
  • 13. Syntax Basics ● X++ is case-insensitive, meaning uppercase and lowercase letters are treated the same. ● Statements are terminated with a semicolon (;). ● Curly braces ({}) are used to define code blocks, such as loops and functions. ● Comments can be added using double slashes (//) for single-line comments or slash-asterisk (/* */) for multiline comments.
  • 14.
  • 15. Variables and Data Types: ● Variables are declared using the "var" keyword, followed by the variable name and its data type. ● Common data types in X++ include int, real, str, date, time, container, etc.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. Operators: ● X++ supports various operators, including arithmetic, assignment, logical, comparison, etc. ● Arithmetic operators: +, -, *, /, % ● Assignment operator: = ● Comparison operators: ==, !=, >, <, >=, <= ● Logical operators: && (AND), || (OR), ! (NOT)
  • 26. Control Flow Statements: ● Conditional statements: ● The "if" statement is used for basic conditional branching. ● The "switch" statement is used for multiple conditional branches.
  • 27. Loops: ● X++ provides several types of loops, such as "for," "while," and "do-while" loops. ● The "for" loop is used when you know the number of iterations in advance. ● The "while" loop is used when the number of iterations is uncertain. ● The "do-while" loop is similar to the "while" loop, but it guarantees at least one execution.
  • 28. Functions: ● Functions allow you to encapsulate a block of code for reuse. ● Functions in X++ are declared using the "public" or "private" access modifiers, followed by the return type, function name, and parameters (if any). ● The "void" keyword is used as the return type for functions that don't return a value.
  • 29. Jobs Jobs are globally defined functions that execute in the Windows client run-time environment. Developers frequently use jobs to test a piece of business logic because they are easily executed from within the MorphX development environment, by either pressing F5 or selecting Go on the command menu. However, you shouldn’t use jobs as part of your application’s core design. The examples provided in this chapter can be run as jobs. Jobs are model elements that you create by using the Application Object Tree (AOT). The next slide X++ code provides an example of a job model element that prints the string “Hello World” to an automatically generated window. The pause statement stops program execution and waits for user input from a dialog box.
  • 30. static void myJob(Args _args) { print "Hello World"; pause; }
  • 31. The type system The Microsoft Dynamics AX runtime manages the storage of value type data on the call stack and reference type objects on the memory heap. The call stack is the memory structure that holds data about the active methods called during program execution. The memory heap is the memory area that allocates storage for objects that are destroyed automatically by the Microsoft Dynamics AX runtime.
  • 32. Reference types Reference types include the record types, class types, and interface types: ● The record types are table, map, and view. User-defined record types are dynamically composed from application model layers. Microsoft Dynamics AX runtime record types are exposed in the system application programming interface (API).
  • 33. ● Although the methods are not visible in the AOT, all record types implement the methods that are members of the system xRecord type, a Microsoft Dynamics AX runtime class type. ● User-defined class types are dynamically composed from application model layers and Microsoft Dynamics AX runtime class types exposed in the system API. ● Interface types are type specifications and can’t be instantiated in the Microsoft Dynamics AX runtime. Class types can, however, implement interfaces.
  • 34. Type hierarchies The X++ language supports the definition of type hierarchies that specify generalized and specialized relationships between class types and table types. For example, a check payment method is a type of payment method. A type hierarchy allows code reuse. Reusable code is defined on base types defined higher in a type hierarchy because they are inherited, or reused, by derived types defined lower in a type hierarchy.
  • 35. The anytype type The Microsoft Dynamics AX type system doesn’t have a single base type from which all types ultimately derive. However, the anytype type imitates a base type for all types. Variables of the anytype type function like value types when they are assigned a value type variable and like reference types when they are assigned a reference type variable. You can use the SysAnyType class to explicitly box all types, including value types, and make them function like reference types.
  • 36. The anytype type, shown in the following code sample, is syntactic sugar that allows methods to accept any type as a parameter or allows a method to return different types: static str queryRange(anytype _from, anytype _to) { return SysQuery::range(_from,_to); }
  • 37. You can declare variables by using anytype. However, the underlying data type of an anytype variable is set to match the first assignment, and you can’t change its type afterward, as shown here: anytype a = 1; print strfmt("%1 = %2", typeof(a), a); //Integer = 1 a = "text"; print strfmt("%1 = %2", typeof(a), a); //Integer = 0
  • 38. The common type The common type is the base type of all record types. Like the anytype type, record types are context-dependent types whose variables can be used as though they reference single records or as a record cursor that can iterate over a set of database records.
  • 39. By using the common type, you can cast one record type to another (possibly incompatible) record type, as shown in this example: //customer = vendor; //Compile error common = customer; vendor = common; //Accepted
  • 40. Declaring variables with the same name as their type is a best practice. At first glance, this approach might seem confusing. Consider this class and its getter/setter method to its field:
  • 41. Class Person { Name name; public Name Name(Name _name = name) { name = _name; return name; } }
  • 42. Expressions X++ expressions are sequences of operators, operands, values, and variables that yield a result.
  • 43. this //Instance member access element //Form member access <datasource>_ds //Form data source access <datasource>_q //Form query access
  • 44. x.y //Instance member access E::e //Enum access a[x] //Array access [v1, v2] = c //Container access Table.Field //Table field access Table.(FieldId) //Table field access (select statement).Field //Select result access System.Type //CLR namespace type access System.DayOfWeek::Monday //CLR enum access
  • 45. x = y + z // Addition x = y - z // Subtraction x = y * z // Multiplication x = y / z // Division x = y div z // Integer division x = y mod z // Integer division remainder
  • 46. x = y & z // Bitwise AND x = y | z // Bitwise OR x = y ^ z // Bitwise exclusive OR (XOR) x = ~z // Bitwise complement
  • 47. x ? y : z Logical operators if (!obj) // Logical NOT if (a && b) // Logical AND if (a || b) // Logical OR Method invocations super() //Base member invocation MyClass::m() //Static member invocation myObject.m() //Instance member invocation this.m() //This instance member invocation myTable.MyMap::m(); //Map instance member invocation f() //Built-in function call
  • 48. new MyClass() //X++ object creation new System.DateTime() //CLR object wrapper and //CLR object creation new System.Int32[100]() //CLR array creation Parentheses (x)
  • 49. Relational operators x < y // Less than x > y // Greater than x <= y // Less than or equal x >= y // Greater than or equal x == y // Equal x != y // Not equal select t where t.f like "a*" // Select using wildcards
  • 50. x = y << z // Shift left x = y >> z // Shift right String concatenation "Hello" + "World" Values and variables "string" myVariable
  • 51. Statements X++ statements specify object state and object behavior.
  • 52. Statement .NET CLR interoperability statement Example System.Text.StringBuilder sb; sb = new System.Text.StringBuilder(); sb.Append("Hello World"); print sb.ToString(); pause;
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65. Data-aware statements The X++ language has built-in support for querying and manipulating database data. The syntax for database statements is similar to Structured Query Language (SQL), and this section assumes that you’re familiar with SQL.
  • 66. The following code shows how a select statement is used to return only the first selected record from the MyTable database table and how the data in the record’s myField field is printed: static void myJob(Args _args) { MyTable myTable; select firstOnly * from myTable where myTable.myField1 == "value"; print myTable.myField2; pause; }
  • 67. The “* from” part of the select statement in the example is optional. You can replace the asterisk (*) character with a comma-separated field list, such as myField2, myField3. You must define all fields, however, on the selection table model element, and only one selection table is allowed immediately after the from keyword. The where expression in the select statement can include any number of logical and relational operators. The firstOnly keyword is optional and can be replaced by one or more of the optional keywords.

Editor's Notes

  1. The code, which is developed in .NET framework, is known as managed code. This code is directly executed by CLR with help of managed code execution. Any language that is written in .NET Framework is managed code. Managed code uses CLR which in turns looks after your applications by managing memory, handling security, allowing cross - language debugging, and so on.
  2. Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system. Background compatibility with code of VB, ASP and COM are examples of unmanaged code. Unmanaged code can be unmanaged source code and unmanaged compile code. Unmanaged code is executed with help of wrapper classes. Wrapper classes are of two types: CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper). Wrapper is used to cover difference with the help of CCW and RCW. COM callable wrapper unmanaged code execution