SlideShare ist ein Scribd-Unternehmen logo
1 von 56
MICROSOFT DYNAMICS AX 2012
DEVELOPMENT INTRODUCTION
By

Ali Raza Zaidi
Alirazaz.zaidi@systemsltd.com
Contents
•
•
•
•
•
•
•
•
•
•
•
•

Objective.
Prerequisite for Audience
Dynamics Ax
Microsoft Dynamics AX 2012 Architecture
Data Dictionary
User Interfaces
X++ Overview
X++ Control Statements
Classes and Objects
Accessing the database
Exception Handling
Conclusion
X++ OVERVIEW
 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.
 Data Aware Includes keywords such as firstFast, forceSelectOrder,
and forUpdate, as well as a database query syntax application
aware client, server, changecompany, and display
Code Editor

Jobs
Compiler
The Debugger
Compare
Development Tools(Contd.)

Reverse Engineering
 Simplify collection
 Extract relationships
 Integrate and view collections
in Microsoft Office Visio as UML
diagrams
Naming conventions
Naming 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
Comments

 Single line “//”
 Block comments “/* */”
 To do comments “TODO.” To do comments appear in the compilers

Tasks tab page.
 /// <summary>
/// This is an XML comment with tags to distinguish
sections.
/// </summary>
X++ CONTROL STATEMENTS
Data Type

Declaration
Keyword

Description/Example

String

str

“any string”

Integer

int

2356

Real

Real

3.14

Date

date

24112010

Enum

Must be declared
as a Base Enum
first

Enum values are represented
internally as Integers.

Boolean

boolean

True/False

Time

timeOfDay

15:23:08

utcDateTime

utcDateTime

9/28/2008
07:11:02 am

Guid

guid

Global Unique Identifier, a reference
number which is unique in any context

Int64

Int64

A large integer, represent by 64 bits.
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
• Containers There are many functions that manipulate container
• 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.
X++ CONTROL STATEMENTS(Contd.)
Operators:
a) Assignment operators
Operator

Term

Description

=

Becomes equal
to

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 statement
switch (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 (rightclick) menu in the code editor and selecting List Built-in 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.
Example
static 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 Class
1. 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.
Method Access
There are three modifiers available:
• Public allows the method to be called from any code in
the application.
• Protected allows the method to be called only by
methods in the same class or subclasses of the class in
which the method is defined.
• Private allows the method to be called only by methods in
the same class in which the method is defined.
CLASSES AND OBJECTS
Inheritance:
 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.
Syntax:
class Child extends Parent
{
}
multiple inheritance is not support. Use interfaces and/or composition
instead.
CLASSES AND OBJECTS
Method 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()
Main Method
It is used by the system when the class is run directly from a menu item
and it takes a parameter of type args.
static void main(Args args){}Args
is a class that is used to pass parameters between objects, for
instance, various parameters can beset on the properties on a menu
item.When the menu item calls a class, the args class containing those
property values is passed to the main
method using the args parameter.
Display Methods

Display 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 OBJECTS
Method 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 OBJECTS
Tables as Classes
• A place for a table buffer is automatically assigned in a table in
classes the new method is used.
• 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 access or methods.
ACCESSING THE DATABASE

In Dynamics Ax 2012
• Retrieve data from the database using a select statement
Table Buffers:
A table buffer is declared like a variable – the table name is specified
in the declaration.
A table buffer stores complete records in a variable.
Select Statements:
Select statements are used to retrieve data from a database.
The pure select statement returns records to a table buffer.
ACCESSING THE DATABASE (Contd.)
Select
static void Q1_Select1(Args _args)
{
CustTable CustTable;
;
select Address from CustTable;
where CustTable.AccountNum == '1102';
print CustTable.Address;
pause;
}

// To Loop Records
while select AccountNum, Name, Address
from CustTable
{
print CustTable.AccountNum+ ": " + CustTable.Name + ": " + CustTable.Address;
}
pause;
Sort
You can sort data retrieved from the database in many ways. This
includes:
• Using existing indexes on the tables.
• Using the order by clause in a select statement.
• Using the group by clause in a select statement.

while select custTable index AccountIdx { print
custTable.AccountNum, " ", custTable.currency; }
Inner join
while select ledgerTable
join ledgerTrans
where ledgerTrans.accountNum ==
ledgerTable.accountNum
{
amountMST += ledgerTrans.amountMST;
}
Exist
while select AccountNum, Name from custTable
order by AccountNum
exists join * from ctr
where (ctr.AccountNum ==
custTable.AccountNum)
notExists
while select AccountNum, Name from custTable
order by AccountNum
notExists join * from ctr
where (ctr.AccountNum ==
custTable.AccountNum)
outer
while select AccountNum from custTable order by
AccountNum outer join * from custBankAccount where
custBankAccount.AccountNum
== custTable.AccountNum { print
custTable.AccountNum, " , ",
custBankAccount.DlvMode; } pause;
Count
CustTable xCT;
int64 iCountRows; ;
Select COUNT(RecID) from xCT;
iCountRows = xCT.RecID;
ACCESSING THE DATABASE (Contd.)
Create
static void Q13_Insert(Args _args)
{
CustTable CustTable;
;
CustTable.AccountNum = "supposedAccount1";
CustTable.Name = "SupposedName1";
CustTable.insert();
info("Inserted");
}
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.)
Delete
static 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 HANDLING
Exception:
 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 HANDLING
Exception 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
Microsoft Dynamics AX 2012 Development Introduction

Weitere ähnliche Inhalte

Was ist angesagt?

X++ advanced course
X++ advanced courseX++ advanced course
X++ advanced courseAlvin You
 
Ax 2012 x++ code best practices
Ax 2012 x++ code best practicesAx 2012 x++ code best practices
Ax 2012 x++ code best practicesSaboor Ahmed
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQLTayyab Hussain
 
Class template
Class templateClass template
Class templateKousalya M
 
Developing ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-axDeveloping ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-axNicc Ngo
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#foreverredpb
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Khaled Anaqwa
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpcasestudyhelp
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class libraryPrem Kumar Badri
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptxRAGAVIC2
 
Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...
Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...
Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...Edureka!
 

Was ist angesagt? (20)

X++ advanced course
X++ advanced courseX++ advanced course
X++ advanced course
 
Ax 2012 x++ code best practices
Ax 2012 x++ code best practicesAx 2012 x++ code best practices
Ax 2012 x++ code best practices
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
 
Class template
Class templateClass template
Class template
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Developing ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-axDeveloping ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-ax
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class library
 
Msaccess
MsaccessMsaccess
Msaccess
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptx
 
.Net Assemblies
.Net Assemblies.Net Assemblies
.Net Assemblies
 
Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...
Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...
Talend Interview Questions and Answers | Talend Online Training | Talend Tuto...
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 

Andere mochten auch

Task recorder control
Task recorder controlTask recorder control
Task recorder controlAli Raza Zaidi
 
Integration with dynamics ax 2012
Integration with dynamics ax 2012Integration with dynamics ax 2012
Integration with dynamics ax 2012Ali Raza Zaidi
 
AX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideAX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideBiswanath Dey
 
Introduction to ERP & Microsoft Dynamics AX overview
Introduction to ERP & Microsoft Dynamics AX overviewIntroduction to ERP & Microsoft Dynamics AX overview
Introduction to ERP & Microsoft Dynamics AX overviewSaptha Wanniarachchi
 
An Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration FrameworkAn Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration FrameworkFolio3-Dynamics-Services
 
positive thinking
positive thinkingpositive thinking
positive thinkingAli Raza Zaidi
 
Dynamics AX Finance Concepts - For Beginners
Dynamics AX Finance Concepts - For BeginnersDynamics AX Finance Concepts - For Beginners
Dynamics AX Finance Concepts - For BeginnersFolio3-Dynamics-Services
 
Whomovedmycheese
WhomovedmycheeseWhomovedmycheese
WhomovedmycheeseAli Raza Zaidi
 
The Businss Analyst Training .
The Businss Analyst Training .The Businss Analyst Training .
The Businss Analyst Training .batrainingschool
 
Microsoft Dynamics ERP - A Smarter Way to Business integration
Microsoft Dynamics ERP - A Smarter Way to Business integrationMicrosoft Dynamics ERP - A Smarter Way to Business integration
Microsoft Dynamics ERP - A Smarter Way to Business integrationBhavik Doshi
 
Business intelligence in microsoft dynamics ax
Business intelligence in microsoft dynamics axBusiness intelligence in microsoft dynamics ax
Business intelligence in microsoft dynamics axAlfaPeople US
 
Microsft Dynamics AX Introduction
Microsft Dynamics AX IntroductionMicrosft Dynamics AX Introduction
Microsft Dynamics AX IntroductionMohamed Samy
 
Microsoft dynamics
Microsoft dynamicsMicrosoft dynamics
Microsoft dynamicsAdeel Siddiqui
 

Andere mochten auch (14)

Task recorder control
Task recorder controlTask recorder control
Task recorder control
 
Integration with dynamics ax 2012
Integration with dynamics ax 2012Integration with dynamics ax 2012
Integration with dynamics ax 2012
 
AX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideAX 2012 R3 Installation Guide
AX 2012 R3 Installation Guide
 
Introduction to ERP & Microsoft Dynamics AX overview
Introduction to ERP & Microsoft Dynamics AX overviewIntroduction to ERP & Microsoft Dynamics AX overview
Introduction to ERP & Microsoft Dynamics AX overview
 
An Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration FrameworkAn Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration Framework
 
Ax Presentation
Ax PresentationAx Presentation
Ax Presentation
 
positive thinking
positive thinkingpositive thinking
positive thinking
 
Dynamics AX Finance Concepts - For Beginners
Dynamics AX Finance Concepts - For BeginnersDynamics AX Finance Concepts - For Beginners
Dynamics AX Finance Concepts - For Beginners
 
Whomovedmycheese
WhomovedmycheeseWhomovedmycheese
Whomovedmycheese
 
The Businss Analyst Training .
The Businss Analyst Training .The Businss Analyst Training .
The Businss Analyst Training .
 
Microsoft Dynamics ERP - A Smarter Way to Business integration
Microsoft Dynamics ERP - A Smarter Way to Business integrationMicrosoft Dynamics ERP - A Smarter Way to Business integration
Microsoft Dynamics ERP - A Smarter Way to Business integration
 
Business intelligence in microsoft dynamics ax
Business intelligence in microsoft dynamics axBusiness intelligence in microsoft dynamics ax
Business intelligence in microsoft dynamics ax
 
Microsft Dynamics AX Introduction
Microsft Dynamics AX IntroductionMicrosft Dynamics AX Introduction
Microsft Dynamics AX Introduction
 
Microsoft dynamics
Microsoft dynamicsMicrosoft dynamics
Microsoft dynamics
 

Ähnlich wie Microsoft Dynamics AX 2012 Development Introduction

3 functions and class
3   functions and class3   functions and class
3 functions and classtrixiacruz
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3Atif Khan
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Abou Bakr Ashraf
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingRenas Rekany
 
Chapter 13 introduction to classes
Chapter 13 introduction to classesChapter 13 introduction to classes
Chapter 13 introduction to classesrsnyder3601
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
C++ language
C++ languageC++ language
C++ languageHamza Asif
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java scriptmichaelaaron25322
 
Mca 2nd sem u-2 classes & objects
Mca 2nd  sem u-2 classes & objectsMca 2nd  sem u-2 classes & objects
Mca 2nd sem u-2 classes & objectsRai University
 
03 oo with-c-sharp
03 oo with-c-sharp03 oo with-c-sharp
03 oo with-c-sharpNaved khan
 
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsBca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsRai University
 
polymorphism.ppt
polymorphism.pptpolymorphism.ppt
polymorphism.pptShubham79233
 
Lecture02-OOP-Review.ppt
Lecture02-OOP-Review.pptLecture02-OOP-Review.ppt
Lecture02-OOP-Review.ppt02LabiqaIslam
 

Ähnlich wie Microsoft Dynamics AX 2012 Development Introduction (20)

OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Csharp generics
Csharp genericsCsharp generics
Csharp generics
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Chapter 13 introduction to classes
Chapter 13 introduction to classesChapter 13 introduction to classes
Chapter 13 introduction to classes
 
Java 2
Java   2Java   2
Java 2
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
C++ language
C++ languageC++ language
C++ language
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(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
 
Mca 2nd sem u-2 classes & objects
Mca 2nd  sem u-2 classes & objectsMca 2nd  sem u-2 classes & objects
Mca 2nd sem u-2 classes & objects
 
03 oo with-c-sharp
03 oo with-c-sharp03 oo with-c-sharp
03 oo with-c-sharp
 
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsBca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objects
 
C++ tutorials
C++ tutorialsC++ tutorials
C++ tutorials
 
C#ppt
C#pptC#ppt
C#ppt
 
polymorphism.ppt
polymorphism.pptpolymorphism.ppt
polymorphism.ppt
 
Lecture02-OOP-Review.ppt
Lecture02-OOP-Review.pptLecture02-OOP-Review.ppt
Lecture02-OOP-Review.ppt
 

KĂźrzlich hochgeladen

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂşjo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

KĂźrzlich hochgeladen (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Microsoft Dynamics AX 2012 Development Introduction

  • 1. MICROSOFT DYNAMICS AX 2012 DEVELOPMENT INTRODUCTION
  • 3. Contents • • • • • • • • • • • • Objective. Prerequisite for Audience Dynamics Ax Microsoft Dynamics AX 2012 Architecture Data Dictionary User Interfaces X++ Overview X++ Control Statements Classes and Objects Accessing the database Exception Handling Conclusion
  • 4. X++ OVERVIEW  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.  Data Aware Includes keywords such as firstFast, forceSelectOrder, and forUpdate, as well as a database query syntax application aware client, server, changecompany, and display
  • 6.
  • 7. Development Tools(Contd.) Reverse Engineering  Simplify collection  Extract relationships  Integrate and view collections in Microsoft Office Visio as UML diagrams
  • 8. Naming conventions Naming 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
  • 9. Comments  Single line “//”  Block comments “/* */”  To do comments “TODO.” To do comments appear in the compilers Tasks tab page.  /// <summary> /// This is an XML comment with tags to distinguish sections. /// </summary>
  • 10. X++ CONTROL STATEMENTS Data Type Declaration Keyword Description/Example String str “any string” Integer int 2356 Real Real 3.14 Date date 24112010 Enum Must be declared as a Base Enum first Enum values are represented internally as Integers. Boolean boolean True/False Time timeOfDay 15:23:08 utcDateTime utcDateTime 9/28/2008 07:11:02 am Guid guid Global Unique Identifier, a reference number which is unique in any context Int64 Int64 A large integer, represent by 64 bits.
  • 11. 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
  • 12. 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
  • 13. • Containers There are many functions that manipulate container • 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.
  • 14. X++ CONTROL STATEMENTS(Contd.) Operators: a) Assignment operators Operator Term Description = Becomes equal to 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.
  • 18. 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 }
  • 19. X++ CONTROL STATEMENTS(Contd.) Conditional Statements b) Switch statement switch (expression) { case 'Choice1': Statement1; Statement2; break; case 'Choice2': Statement3; break; case 'Choice3': Statement4; Statement5; Statement6; break; default : DefaultStatement; }
  • 20. X++ CONTROL STATEMENTS(Contd.) Conditional Statements c) Ternary Operator condition ? statement1 : statement2;
  • 21. X++ CONTROL STATEMENTS(Contd.) Loops a) while loop while (condition) { //statement; }
  • 22. X++ CONTROL STATEMENTS(Contd.) Loops b) Do...while statement do { //statement; } while (condition);
  • 23. X++ CONTROL STATEMENTS(Contd.) Loops c) For loop for ( initial value ; condition ; increment) { //statement; }
  • 24. 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 (rightclick) menu in the code editor and selecting List Built-in Functions, or by pressing Shift+F4. Example str letters; ; letters ="ABCDEFG"; print subStr(letters, 2, 4); print subStr(letters, 5, -3); Result : BCDE CDE
  • 25. 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
  • 26. X++ CONTROL STATEMENTS(Contd.) Communication Tools: The print command print "This is a test message."; pause;
  • 27. 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");
  • 28. 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');
  • 29. 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. Example static 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; } }
  • 30. 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 Class 1. 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.
  • 31. Method Access There are three modifiers available: • Public allows the method to be called from any code in the application. • Protected allows the method to be called only by methods in the same class or subclasses of the class in which the method is defined. • Private allows the method to be called only by methods in the same class in which the method is defined.
  • 32. CLASSES AND OBJECTS Inheritance:  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. Syntax: class Child extends Parent { } multiple inheritance is not support. Use interfaces and/or composition instead.
  • 33. CLASSES AND OBJECTS Method 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()
  • 34. Main Method It is used by the system when the class is run directly from a menu item and it takes a parameter of type args. static void main(Args args){}Args is a class that is used to pass parameters between objects, for instance, various parameters can beset on the properties on a menu item.When the menu item calls a class, the args class containing those property values is passed to the main method using the args parameter.
  • 35. Display Methods Display 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; }
  • 36. CLASSES AND OBJECTS Method 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; }
  • 37. CLASSES AND OBJECTS Tables as Classes • A place for a table buffer is automatically assigned in a table in classes the new method is used. • 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 access or methods.
  • 38. ACCESSING THE DATABASE In Dynamics Ax 2012 • Retrieve data from the database using a select statement Table Buffers: A table buffer is declared like a variable – the table name is specified in the declaration. A table buffer stores complete records in a variable. Select Statements: Select statements are used to retrieve data from a database. The pure select statement returns records to a table buffer.
  • 39. ACCESSING THE DATABASE (Contd.) Select static void Q1_Select1(Args _args) { CustTable CustTable; ; select Address from CustTable; where CustTable.AccountNum == '1102'; print CustTable.Address; pause; } // To Loop Records while select AccountNum, Name, Address from CustTable { print CustTable.AccountNum+ ": " + CustTable.Name + ": " + CustTable.Address; } pause;
  • 40. Sort You can sort data retrieved from the database in many ways. This includes: • Using existing indexes on the tables. • Using the order by clause in a select statement. • Using the group by clause in a select statement. while select custTable index AccountIdx { print custTable.AccountNum, " ", custTable.currency; }
  • 41. Inner join while select ledgerTable join ledgerTrans where ledgerTrans.accountNum == ledgerTable.accountNum { amountMST += ledgerTrans.amountMST; }
  • 42. Exist while select AccountNum, Name from custTable order by AccountNum exists join * from ctr where (ctr.AccountNum == custTable.AccountNum)
  • 43. notExists while select AccountNum, Name from custTable order by AccountNum notExists join * from ctr where (ctr.AccountNum == custTable.AccountNum)
  • 44. outer while select AccountNum from custTable order by AccountNum outer join * from custBankAccount where custBankAccount.AccountNum == custTable.AccountNum { print custTable.AccountNum, " , ", custBankAccount.DlvMode; } pause;
  • 45. Count CustTable xCT; int64 iCountRows; ; Select COUNT(RecID) from xCT; iCountRows = xCT.RecID;
  • 46. ACCESSING THE DATABASE (Contd.) Create static void Q13_Insert(Args _args) { CustTable CustTable; ; CustTable.AccountNum = "supposedAccount1"; CustTable.Name = "SupposedName1"; CustTable.insert(); info("Inserted"); }
  • 47. 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");
  • 48. ACCESSING THE DATABASE (Contd.) Delete static 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";
  • 49. 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.
  • 50. 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.
  • 51. 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; }
  • 52. 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; }
  • 53. EXCEPTION HANDLING Exception:  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.
  • 54. EXCEPTION HANDLING Exception 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."); } }