Curso de Desarrollo Microsoft Dynamcis Ax 2012 4
Curso de Desarrollo Microsoft Dynamcis Ax 2012 4
Curso de Desarrollo Microsoft Dynamcis Ax 2012 4
DEVELOPMENT IV
IN MICROSOFT DYNAMICS® AX 2012
This courseware is provided “as-is”. Information and views expressed in this courseware, including URL and other
Internet Web site references, may change without notice.
Unless otherwise noted, the examples depicted herein are provided for illustration only and are fictitious. No real
association or connection is intended or should be inferred.
This courseware does not provide you with any legal rights to any intellectual property in any Microsoft product.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under
copyright, no part of this courseware may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means or for any purpose, without the express written permission of Microsoft
Corporation.
Microsoft®, Microsoft Dynamics®, Microsoft® PowerPoint®, Microsoft® SQL Server® data management software
and Microsoft Dynamics® AX are trademarks of the Microsoft group of companies. All other trademarks are
property of their respective owners.
Introduction 0-1
Welcome ............................................................................................................ 0-1
Microsoft Dynamics Courseware Contents ........................................................ 0-2
Documentation Conventions .............................................................................. 0-3
Student Objectives ............................................................................................. 0-4
Chapter 1: Number Sequences 1-1
Objectives ........................................................................................................... 1-1
Introduction ......................................................................................................... 1-1
Overview ............................................................................................................ 1-2
Set Up and Administration .................................................................................. 1-4
Extensibility Scenarios ..................................................................................... 1-10
Using Number Sequences in Forms ................................................................ 1-19
Lab 1.1 - Implement a New Number Sequence ............................................... 1-22
Summary .......................................................................................................... 1-31
Test Your Knowledge ....................................................................................... 1-32
Quick Interaction: Lessons Learned ................................................................. 1-33
Solutions ........................................................................................................... 1-34
Chapter 2: Framework Features 2-1
Objectives ........................................................................................................... 2-1
Introduction ......................................................................................................... 2-1
Event Handlers for Customization ...................................................................... 2-5
Integration with Microsoft Dynamics AX ........................................................... 2-16
Interop to X++ ................................................................................................... 2-23
Interop from X++ .............................................................................................. 2-30
Deploy .NET Assemblies for Interop ................................................................ 2-40
Summary .......................................................................................................... 2-45
Test Your Knowledge ....................................................................................... 2-46
Quick Interaction: Lessons Learned ................................................................. 2-48
Solutions ........................................................................................................... 2-49
Chapter 3: Application Foundation Features 3-1
Objectives ........................................................................................................... 3-1
Introduction ......................................................................................................... 3-1
Global Address Book .......................................................................................... 3-2
Extensible Data Security Policy Framework ..................................................... 3-12
Lab 3.1 - Extensible Data Security Policies ...................................................... 3-22
Financial Dimension Framework ...................................................................... 3-25
Organization Model Framework ....................................................................... 3-26
Case Management Framework ........................................................................ 3-34
Lab 3.2 - Extend Case Management ................................................................ 3-44
Policy Framework ............................................................................................. 3-49
Summary .......................................................................................................... 3-59
Test Your Knowledge ....................................................................................... 3-60
Quick Interaction: Lessons Learned ................................................................. 3-62
Solutions ........................................................................................................... 3-63
i
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
ii
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Table of Contents
iii
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
iv
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Introduction
INTRODUCTION
Welcome
We know training is a vital component of retaining the value of your Microsoft
Dynamics® AX 2012. investment. Our quality training from industry experts
keeps you up-to-date on your solution and helps you develop the skills necessary
for fully maximizing the value of your solution. Whether you choose Online
Training, Classroom Training, or Training Materials; there is a type of training to
meet everyone's needs. Choose the training type that best suits you so you can
stay ahead of the competition.
Online Training
Online Training delivers convenient, in-depth training to you in the comfort of
your own home or office. Online training provides immediate access to training
24 hours-a-day. It is perfect for the customer who does not have the time or
budget to travel. Our newest online training option, eCourses, combine the
efficiency of online training with the in-depth product coverage of classroom
training, with at least two weeks to complete each course.
Classroom Training
Classroom Training provides serious, in-depth learning through hands-on
interaction. From demonstrations to presentations to classroom activities, you
receive hands-on experience with instruction from our certified staff of experts.
Regularly scheduled throughout North America, you can be sure you will find a
class convenient for you.
Training Materials
Training Materials enable you to learn at your own pace, on your own time with
information-packed training manuals. Our wide variety of training manuals
feature an abundance of tips, tricks, and insights you can refer to again and again:
Look for a complete list of manuals available for purchase on the Microsoft
Dynamics website: www.microsoft.com/Dynamics.
0-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Challenge Yourself!
Level 3 exercises are the most challenging. These exercises are designed for the
experienced student who requires little instruction to complete the required task.
Step by Step
Level 1 exercises are geared towards new users who require detailed instructions
and explanations to complete the exercise. Level 1 exercises guide you through
the task, step by step, including navigation.
0-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Introduction
Documentation Conventions
The following conventions and icons are used throughout this documentation to
help you quickly and effectively navigate through the information.
CAUTION: Cautions are found throughout the training manual and are preceded by
the word CAUTION in bold. Cautions are used to remind you of a specific result of a
specific action which may be undesirable.
HINT: Hints are found throughout the training manual and are preceded by the word
HINT in bold. Hints are used to suggest time-saving features or alternative methods for
accomplishing a specific task.
NOTE: Notes are found throughout the training manual and are preceded by the word
NOTE in bold. Notes are used to provide information which, while not critical, may be
valuable to an end user.
BEYOND THE BASICS: Advanced information found throughout the training manual
is preceded by the words BEYOND THE BASICS in bold. Beyond the Basics provides
additional detail, outside of standard functionality, that may help you to more optimally
use the application.
EXAMPLE: Examples are found throughout the training manual and are preceded by
the word EXAMPLE in bold. Examples bring to light business scenarios that may better
explain how an application can be used to address a business problem.
0-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Student Objectives
What do you hope to learn by participating in this course?
1.
2.
3.
0-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
Introduction
Number sequencing is a necessary feature in an Enterprise Resource Planning
(ERP) system. Microsoft Dynamics AX uses a number sequence framework to
generate alphanumeric number sequences. These sequences can be used for
transaction documents such as sales orders, purchase orders, invoices, and
journals; or for master data entities such as customers, vendors, and employees.
The primary purpose of the number sequence framework is to provide unique,
user-friendly identifiers while maintaining a continuous or non-continuous
alphanumeric sequence.
1-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Overview
Microsoft Dynamics AX 2012 introduces two concepts to the number sequence
framework: segment and scope. A segment, which is synonymous with
parameter, is a data entity such as a legal entity, operating unit, or fiscal calendar
period that can be used to define a number sequence. In the enhanced number
sequence framework, a number sequence can have more than one segment. A
scope is a valid combination of segments used for a specific transaction or master
data entity. By using segment and scope, Microsoft Dynamics AX 2012 extends
the capabilities of the number sequence framework.
A unique number sequence code must be created for every possible combination
of legal entity and fiscal calendar period instances. For example, if there are two
legal entities with IDs 10 and 20, and there are fiscal calendar periods for every
calendar month in 2011, the user must define separate number sequences for each
combination. An example of a scope instance is 20-Jan11. An example of a
number sequence code for a journal might be JN-J-20-Jan11, in which JN
represents a journal. The number sequence format, J-20-Jan11, is a string that is
defined by the end-user to represent the identifier for the transactions for legal
entity 20 and fiscal calendar period January 2011. The actual instance of a
journal might have a generated number sequence such as J-20-Jan11-000340.
(The last number in the sequence, "000340," is a system-generated number.)
Supported Scopes
Microsoft Dynamics AX 2012 will convert a subset of existing transactions and
master data entities so they can use scopes such as a legal entity or global scope.
This enables Microsoft Dynamics AX 2012 to ship with predefined scopes for
this subset of entities. The rest of the data entities still have a default scope of
DataArea (or company).
1-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
TIP: Use the Legal entity scope when the underlying table does not include the
DataAreaID field and has a foreign key to the legal entity table, CompanyInfo.
For example, use this scope for the number sequence for the expense report
number that is in the expense report table, TrvExpTable.
Although the scope is predefined for a data entity, the segments within that scope
are configurable. This means if a scope consists of a legal entity and fiscal
calendar period, a user can decide to configure the scope to be only a legal entity
during implementation. However, there are some mandatory restrictions on scope
composition. If, for example, a fiscal calendar period is selected as part of a
scope, the inclusion of DataArea or legal entity is mandatory in that scope.
One limitation of the new number sequence framework is that the scope must
always be configured for a specific reference. You cannot define a scope based
on variations in the data. For example, suppose that the regulatory requirements
in France and China require you to generate a number sequence by using the
legal entity and fiscal calendar period segments. However, other countries or
regions might not have the same requirements. The administrator in a
multinational corporation might decide that it is not necessary to include both
segments for all countries or regions. However, you cannot define two different
scopes—one to be used in France and China that includes legal entity and fiscal
calendar period segments, and another to be used in all other countries or regions
that includes only the legal entity segment. You could use the framework in such
a way that all countries or regions have the scope of legal entity and fiscal
calendar period, but display the number sequence format based on both segments
only in France and China. However, the numbers generated would still be
partitioned based on both segments in all companies.
A second limitation is that no references are provided out-of-the box that has a
fiscal calendar period segment. Extending the framework to include a fiscal
calendar period currently requires customization of existing parameters forms in
specific modules. The new Number sequences setup form does support a fiscal
calendar segment.
1-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
With the Microsoft Dynamics AX 2012 number sequences framework, you can
use multiple segments, but legacy number sequence references do not support
this new capacity. Customers and partners who plan to perform customizations to
enable new segments, based on the new capabilities of the framework, will have
to use the Segment configuration form. This form can be used to view or
modify the default configuration of segments included out of the box.
Segment Configuration
An administrator can configure the segments that are allowed for his or her
requirements. For example, out of the box, the application could allow for two
segments such as legal entity and fiscal calendar period. However, only the legal
entity segment might be included by default. The administrator can enable both
segments for their scenario by using the Segment configuration form.
1-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
NOTE: You cannot modify scope segments for a number sequence that is
currently being used. It is not sufficient to stop the use of number sequences with
a scope segment that you need to modify. You must delete any number sequences
that are based on the current configuration before you can modify the scope
segments for a reference.
1-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You can use the Area, Reference, and Company drop-down lists to filter the
data that is displayed in the form.
TIP: The Company filter field only appears after you have selected an Area and
a Reference.
You can set up all required number sequences at the same time by using the Set
up number sequences wizard by clicking Generate in the New group of the
Action Pane, or you can create or modify individual number sequences by using
the Number sequences form.
1-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
NOTE: In the Hyper-V training environment, all number sequences are set up.
Therefore, you cannot run the wizard unless you first delete some number
sequences.
1-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: Use the Company scope when the underlying table includes the DataAreaId
field. For example, use this scope for the number sequence for the customer
account number in the customer table, CustTable.
TIP: Use the Legal entity scope when the underlying table does not include the
DataAreaId field and has a foreign key to the legal entity table, CompanyInfo.
For example, use this scope for the number sequence for the expense report
number that is in the expense report table, TrvExpTable.
1-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
Administration
The administration of number sequences is performed by using actions provided
in the Administration group on the Action Pane on the Number sequences list
page.
1-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Extensibility Scenarios
This section is primarily intended for developers who want to call an API that
extends the NumSeqApplicationModule class to handle changes that are required
by the enhanced number sequence framework. This API is called to create new
fields on documents or master data entities that will use a number sequence.
In a common extensibility scenario, a developer creates new fields and makes use
of the new number sequence framework to generate values for those fields. There
are two main extensibility scenarios:
In all extensibility scenarios, the assumption is that the developer is trying to set
up a new module, has already defined a field in a table, and is using the new
number sequence framework to generate values for that field.
1-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
He has already created a new extended data type, and the tables that will store the
vehicles and trip information. Now he must modify the NumberSeqModule base
enumeration, and create a new class that extends the
NumberSeqApplicationModule class that will store the information about the two
number sequences.
TIP: Make sure that you add the base enumeration and any other objects that
you create or modify to a project. This makes the promotion of changes to a
testing or production environment easier.
1-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Class declaration
public class NumberSeqModuleFleetManagement extends
NumberSeqApplicationModule
{
/* Vehicle Number */
datatype.parmDatatypeId(extendedtypenum(FMVehicleId));
datatype.parmReferenceHelp("Unique key for Fleet
Management vehicles");
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
//Use the DataArea segment
datatype.addParameterType(NumberSeqParameterType::DataArea,
true, false);
this.create(datatype);
/* Rental Number */
datatype.parmDatatypeId(extendedtypenum(FMRentalId));
datatype.parmReferenceHelp("Unique key for rentals");
datatype.parmWizardIsContinuous(false);
1-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
//Use the DataArea segment
datatype.addParameterType(NumberSeqParameterType::DataArea,
true, false);
this.create(datatype);
}
• Right-click the Data Dictionary node in the AOT, and then select
Synchronize.
TIP: Notice that the DataArea segment describes the default segment for the
extended data types that are used for both vehicle number and trip number.
IMPORTANT: You will have to synchronize the database after you create a new
class that extends the NumberSeqApplicationModule class. This may take several
minutes to complete.
void numberSeqPreInit()
{
numberSequenceModules =
[NumberSeqModule::FleetManagement];
numberSeqApplicationModule = new
NumberSeqModuleFleetManagement();
scope = NumberSeqScopeFactory::createDataAreaScope();
NumberSeqApplicationModule::createReferencesMulti(numberSeq
uenceModules, scope);
tmpIdRef.setTmpData
1-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
(NumberSequenceReference::configurationKeyTableMulti(number
SequenceModules));
}
NOTE: This form can only be used for references that have a scope of DataArea.
The administration forms described in the “Set Up and Administration” topic
can be used for references that have any scope. These forms can be found in
Organization Administration > Common > Number Sequences.
TIP: You must add several variable declarations to the class declaration of the
form that you are modifying for the code sample provided to compile. Use the
following code sample to guide you.
NumberSeqReference numberSeqReference;
NumberSeqScope scope;
NumberSeqApplicationModule numberSeqApplicationModule;
container numberSequenceModules;
TmpIdRef tmpIdRef;
NumberSeqScopeFactory::CreateDataAreaScope();
return
NumberSeqReference::findReference(extendedtypenum
(FMVehicleID));
1-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
You must repeat this process and create a second method for the trip
identification number on the FMSetup form.
Void setVehicleID()
{
NumberSeq num;
NumberSequenceReference numberSequenceReference;
numberSequenceReference =
FleetManagementParameters::numRefVehicleID();
if (numberSequenceReference)
{
num = NumberSeq::newGetNum(numberSequenceReference);
this.VehicleID = num.num();
}
}
NOTE: You must repeat this process for each number sequence.
He has created the classes for storing the number sequences and the code that is
required for the vehicle numbers already. He wants to make the trip ID number
sequence include the data area ID and the fiscal calendar period segments.
Now he must update the code to allow for the additional segments on the rental
ID number sequence.
1-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
...
/* Rental Number */
datatype.parmDatatypeId(extendedtypenum(FMRentalID));
datatype.parmReferenceHelp("Unique key for trips");
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
datatype.addParameterType(NumberSeqParameterType::DataArea,
true, false);
NOTE: The code sample only includes a section of the loadModule() method.
If you want to additional segments, you must add another call to the
addParameterType() method before the call to the create() method.
1-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
Void RentalID()
{
NumberSeq num;
NumberSequenceReference numberSequenceReference;
numberSequenceReference =
FleetManagementParameters::numRefRentalID();
If(numberSequenceReference)
{
num =
NumberSeq::newGetNum(numberSequenceReference);
this.RentalId = num.num();
}
}
Isaac, the Business Application Developer wants to change the vehicle number to
be global (or shared). The existing reference, FMVehicleID, has the scope of the
DataArea segment. But the developer wants to change this to the global scope.
The changes that are required to achieve this resemble those that are described in
the previous section.
First, Isaac must remove the call to the addParameterType() method in the
NumSeqModuleFleetManagment.loadModule() method for the vehicle ID. Then,
he must update the NumberSequenceReference method on the Fleet management
parameters table to create a global scope.
1-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
/* Vehicle Number */
datatype.parmDatatypeId(extendedtypenum(FMVehicleID));
datatype.parmReferenceHelp("Unique key for Fleet
Management vehicles");
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
//No longer need the Data Area Scope
//datatype.addParameterType(NumberSeqParameterType::DataAre
a, true, false);
this.create(datatype);
...
NOTE: In the code sample provided, the call to the addParameterType() method
is commented out. Also notice that the sample provided is only a part of the
method.
1-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
1-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler =
NumberSeqFormHandler::newForm(FleetManagementParameters::nu
mRefVehicleNumber().NumberSequenceId,
element,
FMVehicle_DS,
fieldNum(FMVehicle, VehicleID));
}
return numberSeqFormHandler;
}
Next you must override the create() method on the data source where the number
will be populated. Use the following code sample to guide you.
element.numberSeqFormHandler().formMethodDataSourceCreatePr
e();
super(append);
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate(t
rue);
}
}
1-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
The next step is to override the validateWrite() and write() methods on the data
source where the number sequence is being inserted into. Use the following code
samples to guide you.
void write()
{
ttsbegin;
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
ttscommit;
}
Next, you must override the delete() method on the data source where the number
sequence is being inserted. This is an important step that will make sure the
number sequence is canceled and deleted when a record is deleted from your
form that has a number sequence.
void delete()
{
ttsbegin;
element.numberSeqFormHandler().formMethodDataSourceDelete()
;
super();
ttscommit;
}
The last step is to override the close() method on the form to make sure that the
number sequence is canceled when the form is closed. Use the following code
sample to guide you.
void close()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
1-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Scenario
Challenge Yourself!
Isaac must implement a new number sequence for the customer contract ID. He
has already created a new extended data type(CustContractID), contract table
(CustContract), and form (CustContract) to store all the contract information.
Now you must create a new number sequence reference and add it into the
Accounts receivable parameters form. Make sure that you set up the number
sequence format and select it in the Accounts receivable parameters form.
When you are finished, implement the Form Handler on the CustContract form
and make sure that the system will populate the customer contract ID
automatically with the new number sequence when you are finished.
1-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_01_01_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
1-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
datatype.parmDatatypeId(extendedtypenum(CustContractID));
datatype.parmReferenceHelp("Unique key for Customer
Contracts");
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
datatype.addParameterType(NumberSeqParameterType::DataArea,
true, false);
this.create(datatype);
10. Click Save, and then close the Code Editor window.
11. Right-click the Data Dictionary node in the AOT window, and then
click Synchronize.
1-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
7. Save the method, and then close the Code Editor window.
1-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Void setCustContractID()
{
NumberSeq num;
NumberSequenceReference numberSequenceReference;
numberSequenceReference =
CustParameters::numRefContractID();
if (numberSequenceReference)
{
num =
NumberSeq::newGetNum(numberSequenceReference);
this.custContractID = num.num();
}
}
8. Save the method, and then close the Code editor window.
1-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
NumberSeqFormHandler numberSeqFormHandler;
}
5. Save the method and then close the Code Editor window.
To instantiate the number sequence form handler class in the customer contract
form, follow these steps.
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler =
NumberSeqFormHandler::newForm(CustParameters::numRefContrac
tID().NumberSequenceId,
element,
custContract_DS,
fieldNum(CustContract, CustContractID));
}
return numberSeqFormHandler;
}
8. Save the method and then close the Code Editor window.
element.numberSeqFormHandler().formMethodDataSourceCreatePr
e();
1-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
super(append);
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate(t
rue);
}
}
13. Save the method and then close the Code Editor window.
void write()
{
ttsbegin;
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
ttscommit;
}
5. Save the method and then close the Code Editor window.
1-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
5. Save the method and then close the Code Editor window.
void delete()
{
ttsbegin;
element.numberSeqFormHandler().formMethodDataSourceDelete()
;
super();
ttscommit;
}
void close()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
1-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To test that the number sequence for the customer contracts is populating
correctly, follow these steps.
1-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
Summary
This chapter provided an overview of how number sequences are set up in the
application. The chapter showed how the number sequence API works and how
to implement a number sequence API in a code. Additionally, the chapter
provided the steps that are required to implement a number sequence in a form.
The number sequence framework provides APIs that developers can implement
to create new number sequences with global scopes, company scopes, or other
organizational scopes. In addition the APIs can be used to implement number
sequence in a form so that when records are created the number record is updated
automatically with the next number available in the sequence.
1-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 1: Number Sequences
1.
2.
3.
1-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Solutions
Test Your Knowledge
1. TRUE or FALSE? Scope segments cannot be modified for a number
sequence that is currently being used.
(•) TRUE
( ) FALSE
MODEL ANSWER:
1-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
Introduction
There are many frameworks available in Microsoft Dynamics AX 2012. This
chapter provides descriptions of some frameworks, subsystems and features in
Microsoft Dynamics AX 2012. Frameworks are collections of design patterns,
interfaces, and code that provide support to you as a developer.
Eventing
For more information about Eventing, refer to the "Event Handlers for
Customization" topic in this chapter.
Address System
Addresses are handled by the Address subsystem. The global address book, or
address subsystem, can help you understand the relationships among people and
organizations that are associated with your organization. For example, a customer
can also be a vendor in a marketing campaign, or a worker in your organization
can also be a vendor.
2-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NOTE: For more information about the address system refer to the "Global
Address Book" topic in the Application Foundation Features chapter in this
course.
The Batch Journal framework can be used to run a group of tasks that is created
by using the RunBase framework.
TIP: There are individual tts transaction controls for each task.
• Query
• Dialog, with persistence of the last values entered by the user
• Validate
• Batch execution for users to schedule jobs. This functionality uses
the RunBaseBatch class and the pack() and unpack() methods with
versioning.
• Progress bar
• Run
• Client/server-optimized
2-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
For more information about the BOF, refer to the "Business Operation
Framework" topic in this chapter.
The Consistency Check Framework helps validate the consistency of the data in
the production database and helps fix the inconsistencies that it finds.
Dimension
You can use the Dimension subsystem to work with financial dimensions. Use
the InventDim subsystem to work with inventory dimensions.
For more information about the financial dimensions subsystem, refer to the
"Dimensions" topic in the Application Foundation Features chapter.
Note fields should not be put on your own tables, instead use the document
management system's text notes.
Infolog
Information and messages to the user are located in the Infolog. It also contains
contextual information and supporting Help and actions. For more information
see the "Using the Infolog (http://go.microsoft.com/fwlink/?LinkId=238165)"
page on MSDN.
Number Sequence
NOTE: For more information, refer to the Number Sequences chapter in this
course.
2-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Operation Progress
You can inform the user that a process will take some time by using the
Operation Progress framework.
BEST PRACTICE: Use a progress indicator during operations that take more
than two seconds.
Use an hourglass mouse pointer if the process takes two to seven seconds.
NOTE: For more information, see the "How to: Create Progress Indicators
(http://go.microsoft.com/fwlink/?LinkId=238166)" page on MSDN.
Reporting
SQL Server Reporting Services (SSRS) is the primary reporting platform for
Microsoft Dynamics AX. The default, out of the box reports provided with
Microsoft Dynamics AX run on the Reporting Services platform. The new report
development environment takes advantage of extended SQL Server tools and
components. The report development environment is fully integrated into
Microsoft Visual Studio®.
NOTE: For more information, refer to the Reporting chapter in this course.
Application Integration
NOTE: For more information about services, AIF, and the BOF, refer to the
Application Integration Framework and Services in Microsoft Dynamics® AX
course.
2-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
You can reduce the cost of creating and upgrading customizations by using
events. Developers creating code customized by other users should create events
in places where customizations typically occur. Then, those developers
customizing the original functionality in another layer can subscribe to an event.
When the customized functionality is tied to an event, the underlying application
code can be rewritten and it will have little effect on the customization, because
the same events are raised in the same sequence from one version to the next.
2-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: There are some differences in how X++ and C# implement the event design
pattern. For more information, refer to the "X++ and C# Comparison: Event
(http://go.microsoft.com/fwlink/?LinkId=238167)" page on MSDN.
Terminology
X ++ events in Microsoft Dynamics AX 2012 are modeled after .NET eventing
concepts. The following table lists the terms in Microsoft Dynamics AX 2012
related to events.
Term Definition
Producer The producer is the logic that contains the code that
causes a change. It is an entity that emits events.
Consumer The consumer is the application code that represents an
interest in being notified when a specific event occurs.
It is an entity that receives events.
Event An event is a representation of a change that happened
in the producer.
Event payload The event payload is the information the event carries
with it. When a person is hired, for example, the
payload might include the employee's name and date of
birth.
Delegate A delegate is the definition of the information passed
from the producer to the consumer when an event
occurs.
2-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
Coded Events
In X++, you can add delegates as members of a class. The syntax for defining a
delegate is the same as the syntax used for defining a method, except for the
following.
For example, a delegate for an event that is raised when a person is hired could
be expressed as follows.
TIP: You can right-click a class and select New > Delegate to create a new
delegate or you can click the New icon from the Code Editor and type the code.
TIP: The lightning bolt icon indicates that this is a delegate and not an X++
method.
2-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When the application code has to signal that a new person is hired, it uses the
delegate as a method call, supplying the event payload as parameters, as shown
in the following code sample.
{
while select * from Employees where
Employees.hiredDate == today
{
this.hired(employees.Name,
employees.FirstWorkingDay);
}
}
NOTE: The code sample provided is only an example. This code will not compile
in Microsoft Dynamics AX because there is no Employee table.
The parameters that are defined in the parameter profile can be any type allowed
in X++. It is useful to pass an object instance, and to have the handlers modify
the state of that object, so that the publisher can ask for values from the
subscribers. Event handlers are run within the caller's transaction context.
Subscribers can be added to the event in one of two ways—through modeling for
example, in the Application Object Tree (AOT) or through X++ code execution.
Automatic Events
Automatic events are triggered by the environment as the result of something
occurring. Currently, a developer can indicate an event is triggered when a
method is called. This is described in the following sections.
Pre and Post are predefined events that occur when methods are called. The pre-
event handlers are called before the execution of the designated method, and the
post-event handlers are called after the method call has ended. It might be useful
to understand this to augment the existing method with methods called before
and after the normal body, as shown in the following figure.
Calls to the pre- and post-event handlers are inserted into the code generated for
the delegate when that delegate is compiled. Therefore, there is no overhead
penalty incurred by accessing metadata at runtime. In other words, the additional
code in the pre and post handlers has the same overhead as adding the same code
into the original method.
2-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
Each of the pre-event handlers can access the original values of the parameters
and modify them as required. The post-event handlers can modify the return
value of the called method.
Event Handlers
Event handlers are the methods that are called when the delegate is called, either
directly through code (for the coded events) or from the environment (in the
modeled events). The relationship between the delegate and the handlers can be
maintained in the code or in the AOT.
A developer must identify a static method to handle the event on the delegate.
Only static methods can be used in this context. Event handlers can be added to
the delegate by dragging the event handler to the delegate node that represents
the event to be handled. The handler can be removed by using the Delete menu
item available for any node in the AOT.
Event handlers can be added to or removed from events by using special X++
syntax. The delegate name appears on the left side of the += (for adding) or the -
= (for removing) operator. On the right side the keyword eventhandler is given,
together with the qualified name of the handler to add or remove. The compiler
will check that the parameter profiles of the delegate and the handler match.
You can subscribe to methods as event handlers in two locations in the AOT—
under a delegate node or under a method node.
2-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
A class node, such as AOT > Classes > MyClass, can have delegate nodes
directly underneath it. The following rules apply to delegates in the AOT.
In the AOT, you can assign a method as an event handler for the pre-method
event or the post-method event of another method. The event handler subscribes
to an event of the host method.
The nodes that represent the subscription of an event handler to a host method are
underneath the node for the host method. AOT elements such as classes, tables,
and forms can have methods.
All event handlers that subscribe to a method must return void. Event handlers
for host methods can use one of two parameter signatures.
2-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
c. EventHandlerType = X++
d. Method = the static method that you created in step 2.
2-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When an XppPrePostArgs object is used, the values of the parameters and the
return value can be changed by the event handler. The values can be changed
even if the parameters and return type are value types, such as an integer or
string. If a parameter or a return type is a reference to an object, the event handler
can call methods on the object and could change the state of the object.
There are two types of parameters that are treated differently by event handlers:
A pre-method event handler receives the same parameter values that the host
method receives. However, this event handler cannot modify the value of any
value type parameters that refer to the host method.
A post-method event handler receives the same parameter values that the host
method received. However, this event handler does not receive the return value
from the host method.
2-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
The before-method event handler can modify the parameter values that are
passed by the caller method, before the called method receives them. To modify
the pre-method event handler, follow these steps.
3. Create a new static method for the event handler and use the
following code sample.
// CalledWhen = Pre.
static public void formatWholeNameEhBefore(XppPrePostArgs
ppArgs)
{
str firstName;
firstName = ppArgs.getArg("_firstName");
if ("Dave" == firstName)
{
ppArgs.setArg("_firstName", "David");
}
else if ("Bill" == firstName)
{
ppArgs.setArg("_firstName", "William");
}
}
2-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
d. EventHandlerType = X++
e. Method = formatWholeNameEhBefore
7. Create a new job to run the new class and call the method. Use the
following code sample.
The post-method event handler can modify the return value of the completed
method, before the return value is given to the method caller.
2-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
2. Create a new static method for the event handler and use the
following code sample.
// CalledWhen = Post.
static public void numberOfExpectedAttendeesEhAfter
(XppPrePostArgs ppArgs)
{
int intAttendees;
intAttendees = any2Int(ppArgs.getReturnvalue());
info(strFmt("%1 = intAttendees raw, in event
handler.", intAttendees));
if (0 > intAttendees)
{
intAttendees = 0;
ppArgs.setReturnValue(intAttendees);
}
}
2-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• Try to raise an event from outside the class in which the event is
defined. The X++ compiler disallows raising events from outside the
class by design.
• Make customizations that rely on the order in which event handlers
are executed. No guarantees are made by the runtime environment
about the order in which the event handlers are called.
2-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
• X++ development
• .NET languages development with weakly typed .NET interop to
X++ (Also referred to as .NET Business Connector)
• .NET languages development with strongly typed .NET interop to
X++ (Also referred to as .NET Proxies)
• Services
The integration components in all these methods interact with the Application
Object Server (AOS), shown in the following figure.
If the functionality that you need is not available in a service that ships with
Microsoft Dynamics AX 2012, you can use the declarative attributes to expose
existing X++ classes and methods as a service interface.
2-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
X++ Development
X++ development is the programming model in which the developer directly
adds or alters Microsoft Dynamics AX metadata and/or X++ source code. This
model provides complete access to all the base functionality implemented in the
lower layers in the system. This is the most commonly used programming model
in Microsoft Dynamics AX development.
Advantages:
Disadvantages:
Advantages:
Disadvantages:
2-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
Advantages:
Disadvantages:
Services
Exposes Microsoft Dynamics AX functionality through WS-* standards-
compliant service interfaces. In addition to exposing functionality through
services that ship with Microsoft Dynamics AX 2012, Microsoft Dynamics AX
2012 also provides declarative language constructs (X++ attributes) and
development tools so that you can quickly expose existing X++ business logic as
services without additional coding.
Advantages:
Disadvantages:
2-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• Services: With AIF you can expose any business logic as a service to
be consumed by other applications. Within Microsoft Dynamics AX
you can create, customize, and publish services.
• Document services: A specific implementation of services in which
the Microsoft Dynamics AX business logic is exposed through
document services. Document services are typically used to
exchange data with other systems.
NOTE: For more information about standard document services and how to
create your own document services, refer to the Services and AIF development
(http://go.microsoft.com/fwlink/?LinkId=238168) page on MSDN.
TIP: Internet Information Services (IIS) only needs to be installed if you are
configuring an “Enhanced Inbound Port”. IIS is not required for basic ports,
because they are hosted by the AOS itself.
2-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
• Custom Services are services that you create to expose X++ logic
through a service interface. You can use the business logic with
inbound or outbound transfers. The types of services are developed
by using the Business Operation Framework (BOF). This is done by
creating X++ classes that expose their logic through the use of
attributes available within the BOF.
• Document Services represent data and business logic within
Microsoft Dynamics AX. You can use or customize the over 70
standard Axd document services that are included with Microsoft
Dynamics AX. If standard document services do not meet your
needs, you can create a new document service by using the AIF
Document Service Wizard. Each document is represented by a class.
The name of a document class is preceded by Axd. For example,
AxdSalesOrder is the name of the document and also the name of the
document class. The terms "document" and "Axd document" and
"document class" are used interchangeably.
• System Services cannot be customized. The Query Service,
Metadata Service, and User Session Service are Windows
Communication Foundation (WCF)-based services included with
Microsoft Dynamics AX. They provide access to data returned in
queries, metadata for AOT objects such as tables and extended data
types (EDTs), and data about the calling user such as default
language and default company.
With Microsoft Dynamics AX, you can consume external web services from
X++ code, and consume web services hosted by Microsoft Dynamics AX from
.NET Framework languages such as Microsoft Visual C#.
2-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
BOF uses services to call from the client to the server so application “chattiness”
is reduced. The BOF classes separate the user interface, business logic, and data
contract logic. You can use BOF to write applications that have reduced client to
server communication. Because BOF uses services, there is no calling from the
client back to the server, and an open connection from the server to the client
cannot be maintained. The user interface for input parameters can be auto-
generated.
To create a Business Operation Framework service, you must follow these steps.
NOTE: For more information about services, AIF, and the BOF, refer to the
Application Integration Framework and Services in Microsoft Dynamics® AX
course.
NOTE: Additional examples of how to use the BOF can be found in the
Workflow and Reporting chapters later in this course.
2-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
Interop to X++
A proxy class is a .NET Framework class that provides access to one X++ item
type of Microsoft Dynamics AX. You can build proxies for the following X++
item types:
CAUTION: You cannot build a proxy for an X++ interface. If you try, a proxy is
generated for a .NET Framework class which at best approximates the interface.
This incorrect translation into a class causes some common scenarios to fail, and
it might create problems in future releases.
You can generate the proxy C# or Visual Basic source code by using the
Application Explorer in Microsoft Visual Studio. Proxies are usually a better
alternative to .NET Business Connector. .NET Business Connector requires your
C# code to use a late-bound programming model. Proxies provide an early-bound
programming model. With the early-bound model the Code Editor can provide
IntelliSense, and it can also catch misspellings and other errors at compile time,
that is, before the code is run.
There are different scenarios for constructing a proxy object from a proxy class
that is written in C# or in another .NET Framework language. The following
topics describe three possible scenarios.
classId = classnum(DateTimeUtil);
dictClass2 = new DictClass(classId);
2-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The C# Method
using System; // C#
namespace CSharpDll
{
public class CSharpClass
{
static public string CalledFromXppDc
(DictClass pxyDictClass)
{
return pxyDictClass.name();
}
}
}
In the following example, at run time your C# code has an instance of the proxy
class Finance.TownBank. But your code must pass an Economics.TownBank
object to a method. The namespaces do not match.
After the constructor is called, both proxies reference the same TownBank object
in Microsoft Dynamics AX. If one proxy changes the state of the underlying
TownBank X++ object, the other proxy sees the changes.
2-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
// Constructor call.
ecoBank = new Economics.TownBank(finBank);
NOTE: This code sample is theoretical and will compile if pasted directly into a
C# Class Library. Additional code would be required for this example to work.
The first step is to create the class library in Visual Studio. After you have
created the class library project, you can then add a Microsoft Dynamics AX
table to the project. Then you can create class methods that access that table.
1. To create a new class library project, click File > New> Project.
2. Under the Installed Templates tree, click Visual C# > Windows,
select the Class Library project type and then click OK.
3. Save the new project.
4. Add the project to the AOT by clicking File > Add ClassLibrary1
to AOT. Notice that the project icon changes in Solution Explorer.
Alternatively, you can right-click the ClassLibrary1 project and
click Add ClassLibrary1 to AOT.
2-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
2. Click the CustTable table and drag it onto the project in Solution
Explorer. Alternatively, you can right-click the table and then click
Add to Project. In Solution Explorer, you can view the table and the
proxy to the CustTable table that is created internally by the system.
In the References node, you can view a reference to the assembly
Microsoft.Dynamics.Ax.ManagedInterop.
TIP: You can add a system table or system class to your Visual Studio project
even if the interface does not support the dragging of system objects. For
example, to add the FormRun system class, first add any application class, such
as the Bank class. Then rename the new proxy node from Class.Bank.axproxy to
Class.FormRun.axproxy.
Open the Class1.cs file and add the following code. This code contains two
methods that each take two parameters and return data for the specified customer.
///C# code:
using System;
namespace ClassLibrary1
{
public class Class1
{
public string GetCustomerPaymentMode(string
accountNum,
string dataAreaId)
{
string paymentMode = String.Empty;
CustTable custTable = new CustTable();
// Search for the customer.
custTable =
CustTable.findByCompany(dataAreaId, accountNum);
if (custTable.Found)
{
// Get the value for the
customer's payment mode.
paymentMode = custTable.PaymMode;
}
return paymentMode;
}
public bool GetCustomerCreditLimit(string
accountNum,
string dataAreaId)
{
bool hasCreditLimit = false;
CustTable custTable = new CustTable();
// Search for the customer.
custTable =
2-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
CustTable.findByCompany(dataAreaId, accountNum);
if (custTable.Found)
{
// Get the value for whether the
customer has a credit limit.
hasCreditLimit =
(custTable.MandatoryCreditLimit == NoYes.No ? false :
true);
}
return hasCreditLimit;
}
}
}
1. Open the Program.cs file and add the following code. This code calls
the GetCustomerPaymentMode and the GetCustomerCreditLimit
methods from the class that you created and displays the values in
the console window.
using System;
using ClassLibrary1;
using Microsoft.Dynamics.AX.ManagedInterop;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
2-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
// Create a session
using (Session session = new Session())
{
session.Logon(null, null, null,
null);
Run the application. If you have the sample data installed, the following output
will appear in the console window.
Customer 3003 in the CEU company has a payment mode of CHCK and does not
have a mandatory credit limit.
TIP: You might receive an error about the .NET target framework because both
projects target the .NET Framework 4 by default but the
Microsoft.Dynamics.AX.ManagedInterop assembly is a mixed-mode assembly
that targets the 2.0 runtime.
To resolve this error, you have two options— you can change the target
framework for both projects to .NET Framework 3.5 or you can add an attribute
2-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
to the app.config file of the console application project. To change the target
framework, right-click each project in Solution Explorer and then click
Properties. In the Target framework field, select .NET Framework 3.5.
If you want the console application project to target the .NET Framework 4, add
the useLegacyV2RuntimeActivationPolicy attribute to the startup element in the
app.config file and set it to true. For example, <startup
useLegacyV2RuntimeActivationPolicy="true">.
If you want the console application project to target the .NET Framework 4, add
the useLegacyV2RuntimeActivationPolicy attribute to the startup element in the
app.config file and set it to true. For example, <startup
useLegacyV2RuntimeActivationPolicy="true">.
Name Pattern
2-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The following indented list of .NET exception classes shows the inheritance
hierarchy of the ErrorException class. This is one of the exception classes that a
proxy object might encounter if the underlying X++ object has a problem. The
inheritance hierarchy is the same for the other exceptions such as
Microsoft.Dynamics.AX.ManagedInterop.WarningException.
A proxy object can encounter exceptions that are not related to the behavior of its
underlying X++ object. For example, if the AOS is stopped by the administrator,
the proxy can encounter a
Microsoft.Dynamics.AX.ManagedInterop.ServerUnavailableException. This
ServerUnavailableException class extends the
Microsoft.Dynamics.AX.ManagedInterop.ManagedInteropException class.
.NET interop from X++ is useful when you want your X++ code to access the
functionalities in a CLR managed assembly. This includes assemblies that are
installed with the .NET Framework. It also includes any assemblies that you
create with a language such as C# or Visual Basic.
2-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
In the following X++ code sample, the static and instance method calls are as
follows.
• Static: System.Convert::ToString
• Instance: netString.Substring
// static
netString = System.Convert::ToString(netInt);
// instance
netString = netString.Substring(3,2);
xppString = netString;
info(xppString);
2-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Implicit marshaling with the X++ assignment operator works in both directions,
either from X++ types to CLR types, or from CLR to X++.
However, if your next step is to pass that string into an X++ method that takes a
str, you must first marshal the System.String into a str.
Each row in the following table lists a pairing of types that are implicitly
marshaled by the X++ assignment operator.
NOTE: There is no implicit marshaling between the X++ utcdatetime and the
.NET Framework System.DateTime type. For more information about how to
convert between utcdatetime and System.DateTime, refer to the How to: Convert
Between utcdatetime and System.DateTime
(http://go.microsoft.com/fwlink/?LinkId=238170) page on MSDN.
2-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
The following code sample shows the marshaling between the .NET Framework
System.Boolean type and its X++ counterpart boolean.
xppBool = true;
xppBool = netBool;
if (false == xppBool)
{
info("B1. Good, X++ was marshaled to .NET.");
}
else
{
info("B2. Bad, X++ was not marshaled to .NET.");
}
}
*****/
TIP: For additional code samples for marshaling between the .NET Framework
types and the X++ counterparts, refer to the "How To: Marshal Between X++
and CLR Primitive Types (http://go.microsoft.com/fwlink/?LinkId=238171)"
page on MSDN.
2-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
IMPORTANT: Automatic marshaling works between the X++ int64 type and the
.NET Framework type System.Int64, just as marshaling works between the X++
int and the .NET System.Int32.
str 8 myStr ="123456789"; // The string is truncated, and the nine is removed.
The System.String type in the .NET Framework does not have a property that
corresponds to the maximum length of an X++ str, and string truncation does
not occur. This feature difference could lead to different behavior at run time in
the following cases:
When X++ is run as p-code rather than as CIL, instances of str truncation can
be logged by Microsoft Dynamics AX.
You cannot use a comparison operator with CLR primitive or value types
because they are represented as reference types or objects in the system. A
System.Int32 is an object that is converted to a value type temporarily during
assignment statements. A System.Int32 remains a reference type when it is used
with a comparison operator. Comparison operators such as >= are designed for
use between value types.
2-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
The following code sample shows that the X++ operator >= cannot be used
meaningfully between two System.Int32 variables. The sample also shows that
the .NET Framework has methods that provide the functionality of the
comparison operators. The method System.Int32.CompareTo is shown.
// System.Int32.CompareTo method.
xppCompare = netInt99.CompareTo(netInt8);
if (0 < xppCompare)
{
info(strfmt("xppCompare is %1, which means 99 >
8. Good.", xppCompare));
}
else if (0 == xppCompare)
{
info(strfmt("xppCompare is %1, which means 99 ==
8. Unexpected.", xppCompare));
}
else // (0 > xppCompare)
{
info(strfmt("xppCompare is %1, which means 99 <
8. Unexpected.", xppCompare));
}
/***** Output
Message (11:50:53 am)
This proves the X++ >= operator cannot be used
meaningfully between two .NET Int32 variables.
xppCompare is 1, which means 99 > 8. Good.
*****/
}
2-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
If your X++ code calls the .NET Framework class System.String, the X++
compiler finds the managed assembly because of two system configurations:
To run your X++ code on the AOS tier, you must copy your assembly to the
server\...\bin\ subdirectory on the AOS computer. This is located under the
Microsoft Dynamics AX installation directory.
It is not required to provide any reference to the assembly because the X++ code
is already compiled.
TIP: If you want to run CLR interop code on the server, you must assert
CLRInterop permissions.
2-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
A method can run on particular tier either by virtue of the client or server
modifier for static methods, or by virtue of the class being RunOn property being
either client or server for instance methods.
For example, your server method named SS cannot return a .NET Framework
object to another method named CC that calls SS from the client tier.
Example:
The following X++ code example has a server method that is called by a client
method. The server method returns a .NET Framework object of type
System.String. However, .NET Framework objects cannot be serialized and de-
serialized by Microsoft Dynamics AX. Therefore they cannot be returned to a
caller that is running on a different tier (in this case, the client tier).
This X++ code represents the client job that calls the
server method.
strXpp = sNet;
info(strXpp);
}
An attempt to run this code example causes an error because the CLRObject is
not initialized.
2-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The X++ code sample in this section calls methods that are in a .NET assembly.
As recommended, these calls are inside a try block.
The sample has a catch block for the X++ enum value Exception::CLRError. In
that catch block, the following steps are performed.
1. ClrInterop::getLastException is called.
2. ex.get_InnerException is called.
The following X++ code sample demonstrates how to handle exceptions that are
thrown from .NET methods.
// X++
static void JobCreateEventLog(Args _args)
{
#define.LogSource("Dynamics AX")
#define.LogName("Dynamics AX Log")
System.Exception ex;
System.Diagnostics.EventLog eventLog;
;
try
{
// Create the log if it does not already exist.
if
(!System.Diagnostics.EventLog::SourceExists(#LogSource))
{
System.Diagnostics.EventLog::CreateEventSource(#LogSource,
#LogName);
}
System.Diagnostics.EventLog::CreateEventSource(#LogSource,
#LogName);
2-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
eventLog.set_Source(#LogSource);
eventLog.WriteEntry("The exception should
prevent this line from appearing in the Windows event
viewer.", System.Diagnostics.EventLogEntryType::Warning);
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
// Clean up.
System.Diagnostics.EventLog::DeleteEventSource(#LogSource,
#LogName);
}
/*** Messages displayed in the Infolog:
System.ArgumentException: Source Dynamics AX already exists
on the local computer.
at
System.Diagnostics.EventLog.CreateEventSource(EventSourceCr
eationData sourceData)
at System.Diagnostics.EventLog.CreateEventSource(String
source, String logName)
***/
Additional Information
Use X++ Syntax for CLR Arrays
X++ has syntax that you can use to directly create and handle .NET Framework
arrays. The syntax is an alternative to constructing instances of System.Array
directly, and the underlying effect is the same. The syntax is easier to write than
the verbose alternative of using a variable declared as .NET Framework type
System.Array. For more information, refer to the How to: Use X++ Syntax for
CLR Arrays (http://go.microsoft.com/fwlink/?LinkId=238172) page on MSDN.
In Microsoft Dynamics AX, an X++ str type can be passed in a call to a .NET
Framework method or X++ method that requires a System.String parameter as its
input. However, substitutions in the other direction are not supported. An X++
method that requires an str parameter does not accept a System.String.
2-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The same rule applies to the other X++ primitive types and their .NET
Framework counterparts. Therefore an X++ int parameter can be passed to a
method that takes a System.Int32. However, a System.Int32 cannot be passed
into a method that takes an X++ int. For more information, refer to the How to:
Marshal Between X++ and CLR Primitive Types
(http://go.microsoft.com/fwlink/?LinkId=238171)page on MSDN.
It does not matter whether the method that takes the parameter is a .NET
Framework method or an X++ method.
In X++, you use the byref keyword when you call a .NET Framework method
that takes parameters by reference.
For more information about how the byref keyword works with value types and
reference types, refer to the "Understanding the X++ Keyword byref for CLR
Interop (http://go.microsoft.com/fwlink/?LinkId=238174)" page on MSDN.
In Microsoft Dynamics AX, the DictMethod system class has reflection methods
that can report on the .NET Framework types that an X++ method uses. The
.NET Framework types can be used for parameters, local variables, the return
type, and more. For more information about reflection, refer to the "Reflect on
.NET Elements of X++ Methods
(http://go.microsoft.com/fwlink/?LinkId=238175)" page on MSDN.
The AOS handles the items in these two AOT locations differently from one
another.
2-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
This scenario starts with an existing .NET Framework assembly .dll file. It is not
relevant how the .dll became available. The following list shows the sequence of
events in this scenario:
1. You manually copy the .dll file into your client\bin\ directory.
This step is unnecessary if the assembly is already in the GAC on
your local computer.
2. In the AOT, right-click the References node, and then click Add
reference. The Add reference form is displayed.
3. If the assembly is not in the list, click Browse to open the Select file
form.
4. Browse to the client\bin\ directory and select your .dll file. Then
click the Open button. The Select file form closes.
5. Back in the Add reference form, the .dll file that you selected is
listed in the bottom grid. Select your .dll file.
6. Click OK. The form closes.
You can view your new entry under AOT > References.
The following list shows the sequence of events when you use Visual Studio to
write code and compile a .dll assembly file.
Each successive compilation causes Visual Studio to again call the AOS to pass
the latest files to the AOS.
2-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Ongoing Deployments
In the AOT > Visual Studio Projects scenario, you do not have to manually copy
any assembly files to a location. The system handles all the file management. The
AOS contains your assembly in the database that the AOS manages for storing
metadata.
Later, when the .dll file is needed for a process that runs on the AOS, the AOS
copies the .dll file from the database and stores the .dll file under the
server\bin\VSAssemblies\ directory on its local hard disk drive. (The exact
directory path might vary slightly between installations.)
NOTE: In production environments, the AOS has the security authority to write
under its local server\bin\ directory, whereas clients on other computers typically
do not.
If a client needs the .dll file to compile or run X++ code that references classes in
the .dll file, the client calls the AOS for a copy of the .dll file.
NOTE: The hot-swap feature applies only to assemblies that are used by X++
code that runs on the AOS, not for assemblies that are used on the client only.
The following sections explain the importance of application domains in the hot-
swap feature. An application domain is an instance of the .NET Framework class
named System.AppDomain.
Scenario: Hot-Swapping
The primary use for the hot-swap feature is in the following standard
development cycle with Microsoft Visual Studio. This involves the AOT >
Visual Studio Projects area, which is comparable to the Visual Studio Projects
area of the Application Explorer window for Microsoft Dynamics AX in Visual
Studio. The scenario begins with the following steps.
1. In Visual Studio, write the C# code for an assembly .dll that you will
call from X++ code.
2. Compile the .dll. Add more code, and compile again.
2-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
A problem is encountered in the last step of the previous list. The AOS has
already loaded the earlier version of the assembly. You can start the hot-swap
feature to make the AOS load the updated version of the assembly for each new
connection.
The following sections describe the scenarios for the two possible states of the
hot- swap configuration option.
To test the updated assembly, you must restart the AOS. Then connect an
AX32.exe client to the AOS, and run the tests. Having to restart the AOS after
every compilation is inconvenient. The inconvenience is increased if other
developers are sharing the same AOS, because their connections are broken with
each restart. Their connections can be from an AX32.exe client, and from Visual
Studio.
You do not have to stop and restart the AOS when you want the AOS to load a
new assembly that it has not loaded before.
When the hot-swap configuration value is turned on, each new client connection
to the AOS is assigned to a new application domain that is dedicated to that
connection. Each connection has its own application domain. When you create
new application domains, they do not affect other connections.
2-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Each new application domain is populated with the versions of assembly .dlls
that are available to the AOS when the .dlls are loaded into the new domain. In
any given application domain, no updates can be made to any assembly .dll that
is already loaded into the domain.
In Visual Studio, after you modify your C# code and again compile the assembly
.dll, you have to start a new AX32.exe client to gain access to the updated
assembly for testing.
FIGURE 2.6 HOT-SWAPPING ON: EACH CLIENT HAS ITS OWN APPDOMAIN
IN THE AOS
You can turn on the hot swapping feature of the AOS by following these steps:
2-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
CAUTION: You should not use the hot-swap feature in your production
environment. The AOS might consume lots of memory caused by an accumulation
of application domains. Many assemblies would be loaded multiple times, which
would waste memory resources.
Summary
The Framework Features chapter introduced several different frameworks
available in Microsoft Dynamics AX.
Developers creating code that is customized by other users should create events
where customizations typically occur. Then, developers customizing the original
functionality in another layer can subscribe to an event. When the customized
functionality is tied to an event, the underlying application code can then be
rewritten and it will have little effect on the customization, if the same events are
raised in the same sequence from one version to the next.
There are many technologies that you can use to programmatically integrate
Microsoft Dynamics AX with other applications so that you can integrate
functionality or exchange data. These technologies include the following.
You can use a proxy class for classes, tables, and enums. A proxy class is a .NET
Framework class that provides access to one X++ item type of Microsoft
Dynamics AX.
Additionally, you can use the .NET interop from X++ to access classes in
assemblies that are managed by the CLR in X++ code, and you can use AOT >
References or AOT > Visual Studio Projects to deploy your .NET assemblies
for interop.
2-45
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
_____ 1. The logic that contains the code that causes a. Event
a change. b. Delegate
_____ 2. The definition of the information passed c. Event payload
from the producer to the consumer when an event
d. Producer
occurs
e. Consumer
_____ 3. The application code that represents an
interest in being notified when a specific event
occurs.
_____ 4. A representation of a change that happened
in the producer.
_____ 5. The information that the event carries with
it.
4. TRUE or FALSE? You should only use the hot-swap feature in your
production environment.
( ) TRUE
( ) FALSE
2-46
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
6. You can build proxies for which of the following X++ item types? (Select all
that apply)
( ) Base enumerations
( ) Extended data types
( ) Tables
( ) Classes
2-47
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
2-48
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 2: Framework Features
Solutions
Test Your Knowledge
1. What is the primary difference between using a reference versus a Visual
Studio project to deploy a .NET assembly for interop?
MODEL ANSWER:
AOT > References require ongoing deployments, whereas AOT > Visual
Studio Projects do not require you to redeploy the .dll files.
4. TRUE or FALSE? You should only use the hot-swap feature in your
production environment.
( ) TRUE
(•) FALSE
2-49
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
6. You can build proxies for which of the following X++ item types? (Select all
that apply)
(√) Base enumerations
( ) Extended data types
(√) Tables
(√) Classes
2-50
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Introduction
There are many application foundation features in Microsoft Dynamics AX 2012.
This chapter introduces several of these features.
3-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
This course highlights the patterns used to consume or update address book
controls. This includes party name/details and postal and electronic addresses.
In Microsoft Dynamics AX 2012, roles that are associated with party records are
referred to as party roles. Party roles include customer, vendor, prospect
(formerly known as business relations), contact, worker, applicant, competitor,
legal entities, operating units, teams, prospective vendors, and personal contacts.
A single party can be associated with one or more party roles in a Microsoft
Dynamics AX company. For example, the organization party of A. Datum
Corporation can be associated with a customer, prospect, and vendor in the
Microsoft Dynamics AX company CEE and can also be associated with a vendor
in the Microsoft Dynamics AX company CEU. Benefits of this shared data
include the following.
3-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Data Normalization
Most of the transactions and journals have address information for example: sales
orders have delivery addresses, and invoices have billing addresses. In earlier
versions of Microsoft Dynamics AX the address is stored on the header and each
line for each transaction. Additionally, the address is also stored with the journals
or packing slips that are generated from the transaction.
This pattern caused significant repetition of data. For example, entering a 10-line
quotation and moving it step-by-step to an invoice means the same address could
be stored 88 times. In Microsoft Dynamics AX 2012, address duplication is
reduced by storing the address one time and having each transaction or journal
table reference the address record.
Address Defaulting
An address defaulting methodology is implemented that lets users select which
address should be used as the default for a transaction. The customer, vendor,
legal entity, and prospect forms let the user specify a default address for a
specific purpose. Depending on the transaction, there are different defaulting
flows for addresses.
Terminology
The terms used with the GAB include the following.
3-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
In the earlier versions, the party tables, including DirPartyTable, are striped by
dataArea, and are shared across companies by virtual tables.
In Microsoft Dynamics AX 2012, names for organization and person are now
date-effective. Date-effective names are supported by the use of the
ValidTimeStateFieldType property of the table. The affected tables include
DirOrganizationName and DirPersonName.
3-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
In the earlier versions, primary address and contact information for party entities
is stored in the table for each entity (vendor, customer, worker, contact person,
prospect (business relation), applicant, competitor, and external and internal
organizations.
3-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
DirPartyLookup Class
Both the DirPartyRecId and DirPersonRecId extended data types automatically
inherit the lookup for party or person without any filter.
If you need the lookup to be filtered, you can use the DirUtility::nameLookup()
or DirUtility::personNameLookup() to do this. This uses the
DirPartyLookupEntitiesFilter class to filter by the party role. For more
information, refer to the following code sample taken from the
AuditPolicyAdditionalOption form.
dirPartyLookupEntitiesFilter::generateDirPartyLookupEntitie
sFilter(
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleView::All ? NoYes::Yes :
NoYes::No),
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleView::CustomersOnly ?
FilterStatus::Set
: FilterStatus::Undefined),
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleView::VendorsOnly ?
FilterStatus::Set
: FilterStatus::Undefined),
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleView::BusinessRelationsOnly ? FilterStatus::Set
: FilterStatus::Undefined),
3-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleView::CompetitorsOnly ?
FilterStatus::Set
: FilterStatus::Undefined),
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleView::ContactsOnly ?
FilterStatus::Set
: FilterStatus::Undefined),
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleView::EmployeesOnly ?
FilterStatus::Set
: FilterStatus::Undefined));
(auditPolicyListParty.AddressBookRole ==
DirPartyRoleViewApplicantsOnly ?
FilterStatus::Set
: FilterStatus::Undefined));
ret = DirUtility::namelookup(_formReferenceControl,
auditPolicyListParty,
DirPartyType::None,
element,
false,
dirPartyLookupEntitiesFilter);
return ret;
}
The following forms are examples that use single address logic.
• BankAccountTable
• BankGroup
• IntrastatParameters
• CustBankAccounts
• VendBankAccounts
• HcmWorkerBankAccounts
3-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The following forms are examples that use multiple address logic.
• CustTable
• tutorial_Form_GABPrimitive
• HcmApplicantBasket
• InventLocation
• VendTable
• HcmWorker
2. Create menu items for the New, Edit, Clear and Map buttons with the
following properties. When you are finished creating the menu items,
add them to the form in a button group.
3. On the form where the address part will be added do the following.
3-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
public LogisticsPostalAddressFormHandler
getAddressController()
{
return addressController;
}
addressController.callerUpdateButtons(newAddress,
editAddress, clearAddress, mapButton);
}
return ret;
}
TIP: We recommend that you use the right-click > Duplicate feature in the
Application Object Tree (AOT) and the drag-and-drop functionality. This also
works for methods.
2. Create menu items for the Add, Edit, Deactivate, Remove, Advanced
and Map buttons with the following properties.
3-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
b. ObjectType = Class
c. Object = LogisticsEntityPostalAddressFormHandler
d. EnumTypeParameter = LogisticsLocationAddressActionButtons
e. EnumParameter = 0 – New, 1 – Edit, 3 – Map, 4 – Delete, 5 –
Advanced, 6 – Deactivate
f. LinkedPermissionType = Form
g. LinkedPermissionObject = LogisticsPostalAddress
h. NormalImage = 11421 (Add), 10040 (Edit), 10106 (Advanced), 11438
(Delete), 10041 (Map), 10039 (Deactivate)
i. ImageLocation = EmbeddedResource
j. OpenMode = New, Edit, Auto (for Advanced, Map, Delete and
Deactivate)
public LogisticsLocationRecId
parmPostalAddressLocation(LogisticsLocationRecId
_postalAddressLocation =
dirPartyPostalAddressView.Location)
{
postalAddressLocation = _postalAddressLocation;
return postalAddressLocation;
}
LogisticsEntityPostalAddressView_ds.executeQuery();
}
return ret;
}
3-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
DirPartyPostalAddressView::updateQuery(this.query().d
ataSourceName(this.name()), custTable.Party);
super();
this.updateButtons();
if (postalAddressLocation != 0 &&
postalAddressLocation !=
dirPartyPostalAddressView.Location)
{
this.findValue(fieldnum(DirPartyPostalAddressView,Loc
ation),SysQuery::value(postalAddressLocation));
}
}
You can create address books at any time and if you select, you can set security
parameters for the address books at any time. Setting security for address books
is not required in Microsoft Dynamics AX. However, if you do not restrict access
by legal entity, or if security privileges are not set for an address book, all
workers in your organization can view all party records. You can use the
Security policy options link in the Global address book parameters form to
select whether the enforcement of security privileges for address books is based
on teams, legal entities, or both.
Each method for setting security privileges on the global address book uses an
extensible data security (XDS) policy in the AOT. When you add a new global
address entity, we recommend that you add your address entity tables as
constrained tables to the appropriate security policies in the AOT.
3-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Security policies are enforced in the Application Object Server (AOS). All access
mechanisms that route through the AOS are subject to policy enforcement. These
access mechanisms include forms, Enterprise Portal webpages, SSRS reports,
and calls from class methods.
Concept Review
The following list defines the concepts of the XDS model.
Primary table
You can use a primary table to help secure the content of the related constrained
table. For example, in a policy restricts access to all sales orders based on the
CustGroup foreign key value, the Customer table would be the primary table.
Policy query
You can define a policy query by specifying a value for the Query property in the
AOT at Security > Policies > YourPolicy. You can use a policy query to help
secure the constrained tables specified in a given security policy. The query
selects data from a primary table. The values in that data are then used to restrict
the data returned from the constrained table.
3-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Context
A policy context controls the circumstances under which a given policy applies.
The policy is not enforced unless the context is set. The types of policy contexts
are as follows.
• Role context: Can enable policies that are based on the roles to
which the user is assigned.
• Application context: Can enable policies that are based on
information which is set by the application.
Security Policies
A policy specifies the table row or record that can be accessed. This resembles
the WHERE clause in a SQL view or statement that specifies the table records to
be returned.
All security policies start with a query that is defined under AOT > Queries. The
VendProfileAccountPolicy query, shown in the following image, is the basis for
the policy that is described in this topic.
3-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The most important property of a policy is its Query property. The PrimaryTable
property is set to the first data source of the query.
3-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
• No: Means the policy does not restrict the data values in records that
are returned from the primary table.
• Yes: Means the policy does restrict the data values in records that are
returned from the primary table.
Trimming
The security configuration of each field is assessed for the current user. This
security behavior is called field trimming because the restricted fields are
trimmed out of the results before the results are sent from the AOS to the client.
The code sample scans all fields that are under AOT > Data Dictionary >
Tables, for a specified range of tables.
When a user runs a query, the system can refuse to send data from the AOS for
particular columns that the current user has no authorization to access. The
access is controlled by the AOSAuthorization property that is available on each
field during run time. This property value cannot be known at compile time. The
run time value of the AOSAuthorization property is controlled by the roles that
the user belongs to.
The following code sample scans the system tables to find fields that the current
user cannot access, on tables that he can otherwise access. The code prints
progress reports to the Print window while it runs. The final output of field
names appears in the Infolog window.
The macros near the top of the code sample are explained in a section that
follows the code sample.
TreeNode tnTable,
tnField;
str sTableAosAuth,
sFieldAosAuth;
int nCountOfTpfTablesFound = 0,
nCountOfAotTables = 0,
nCountOfTrimmedFields = 0;
3-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
tnTable = TreeNode::findNode
("\\Data
Dictionary\\Tables").AOTfirstChild();
}
else
{
tnTable = TreeNode::findNode
("\\Data (file://\\Data)
Dictionary\\Tables\\" + #SearchTableNameRangeStart);
}
while (true)
{
nCountOfAotTables++;
// Provide ongoing progress reports.
if ((nCountOfAotTables MOD 50) == 3)
{
print int2Str(nCountOfAotTables)
+ " tables examined to this point,
at " + tnTable.AOTname();
print int2Str(nCountOfTpfTablesFound) + "
TPF okay tables found to this point.";
print int2Str(nCountOfTrimmedFields) + "
trimmed fields found to this point.";
print "---------------- Wait...";
}
// Perhaps stop before the end of the AOT, for
convenience.
if (#SearchTableNameRangeStop < tnTable.AOTname()
&&
#SearchTableNameRangeStop !="")
{
break;
}
3-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
+
'\\Fields').AOTfirstChild();
tnField;
tnField =
tnField.AOTnextSibling()
)
{
sFieldAosAuth =
tnField.AOTgetProperty('AOSAuthorization');
// Test whether there is
authority to access the field.
if (sFieldAosAuth !=
'No')
{
nCountOfTrimmedFields++;
info(strFmt('%1 %2
is a trimmed field that you cannot access.',
tnTable.AOTname(),
tnField.AOTname()));
}
} // for each field in AOT
} // if table is guarded by the Table
Protection Framework (TPF).
} // name is Like
3-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Each security policy relies on a query. The ranges of the query are a primary
element of the security policy. You can create a new policy query by following
these steps:
1. Expand the Security node in the AOT window, and then right-click
the Policies node and select New Security Policy. Rename the new
security policy to MajorCustomersPolicy.
2. In the Properties window for MajorCustomersPolicy, set the
following properties:
o Name = MajorCustomersPolicy
o Label = Restrict data to major customers
o PrimaryTable = CustGroup
o Query = MajorCustomersPolicyQuery
3-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
The security policy is now ready for deployment and testing. Notice that the
ContextType property is currently set to the value ContextString, but the
ContextString property is empty. This combination implies that when it is
enabled, this security policy will always be applicable for all users.
As an application user, you can now verify that the security policy that you have
created is enforced by the system.
When you try to insert a record, the code output to the Infolog window is visible
, and you receive the following error message.
The security policy already exists for the CustGroup table. The pre-existing
security policy is named MajorCustomersPolicy. The PrimaryTable property of
the policy names the CustGroup table.
Foreign key relations are used by the policy to determine which data records the
users are authorized to access on the constrained tables. The CustGroup table is a
parent of the CustTable table, which has a foreign key field that references the
primary key of the CustGroup table. And the CustTable table is a parent of the
SalesTable table.
3-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You can add tables to the list under the Constrained Tables node of a security
policy. The policy denies access to some data records in the constrained tables.
The particular records that are denied are determined by the foreign key
relationships among the tables in the policy. A record on a constrained table can
be accessed only if the foreign key value in the record matches the primary key
value of a record that can be accessed in the primary table of the policy.
You can add the CustTable table as a constrained table by following these steps:
In this section, you constrain the SalesTable table. You constrain it by associating
it to the constrained CustTable table that you added in the previous section. The
SalesTable table is related to the CustGroup table indirectly through the
CustTable table.
There are no named relations between a view and a table, the way there are
between two tables where a formal foreign key is defined. However, in a security
policy under its Constrained Tables node, you can define a relation between a
view and one of the tables that the view references. You do this by setting the
Value property of the view to a value that has the following format:
(Table.FieldName=View.FieldName). You can also enter multiple field relations
in the following format: ((Table.Field1=View.Field1) &&
(Table.Field2=View.Field2)).
In the following steps, you improve the security policy to constrain access to data
from a view.
3-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
As an application user, you can now verify that the security policy that you have
created is enforced by the system.
As an application user, you can now verify that the new security policy is
enforced by the system.
NOTE: You can run another test as another user who is not assigned to the Sales
manager role, but does have access to customer groups to verify that all
customer groups are available when the Sales manager role is not assigned.
3-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Scenario
Claire, the HR Manager, should only be able to view vendors that are in the
employee vendor group. Employees are currently assigned to the "Other" vendor
group.
Simon, the Business Systems Developer, must create a new extensible data
security policy to restrict the HR Manager role to only view Other vendors.
Challenge Yourself!
Use the information that is provided to create a new extensible data security
policy for the HR Manager role that restricts access to view only vendors in the
Other group.
Step by Step
Inspect the Data You Want to Help Secure
3-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
1. Expand the Security node in the AOT window, and then right-click
the Policies node and select New Security Policy. Rename the new
security policy to OtherVendorsPolicyQuery.
2. Locate Data Sources under the SecurityPolicy >
OtherVendorsPolicyQuery node. Add a new data source.
3. In the Properties window for the new data source, set the Name
property to VendGroup_1, and the Table property to VendGroup.
4. Right-click the Ranges node and select New Range.
5. In the Properties window for the new range, set the Field property
to VendGroup, and the Value property to 80.
6. Locate Fields under the OtherVendorsPolicyQuery > Data
Sources > VendGroup_1 node.
7. In the Properties window for Fields, set the Dynamic property to
Yes. The Yes value indicates that all fields are queried.
Constrain Tables
You can add the VendTable table as a constrained table by following these steps:
3-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
3-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
3-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NOTE: For more information about the financial dimension framework and
examples of adding controls to forms and creating a new system-defined
dimension, refer to the “Use and Design of the Ledger Module” chapter in this
course.
Legal Entities
A legal entity is an organization with a registered or legislated legal structure that
is granted the authority to enter into legal contracts that is required to prepare
statements that report on its performance.
Operating Units
An operating unit is an organization that divides the control of economic
resources and operational processes among people who have a duty to maximize
the use of scarce resources, to improve processes, and to account for their
performance.
3-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
• A department is a type of operating unit that can have profit and loss
responsibility and could be a grouping of cost centers. Departments
are also frequently created based on functional responsibility or skill,
such as sales and marketing.
• A value stream is a type of operating unit typically used in lean
manufacturing. In lean manufacturing, a value stream owns one or
more production flows that describe the activities and flows needed
to supply a product, good, or service to the consumers of the product.
When legal entities and operating units are arranged into hierarchies and used for
reporting rollup, security access, and business policies, they help enable internal
control of your business.
Organization Hierarchies
You can set up organizational hierarchies to visually model your business from
different perspectives. For example, you can set up a hierarchy of legal entities
for tax, legal, or statutory reporting. Then you can set up another hierarchy that is
based on operating units that represents the way that you report financial
information that is not legally required. However, that is used for internal
reporting. For example, you can create a purchasing hierarchy to control
purchasing policies, rules, and business processes.
TIP: Microsoft Dynamics AX 2012 does not support the hierarchies in the
account structures. If you have at least two segments backed by an organization
unit in the hierarchy, you can select the hierarchy in the Configure account
structure form by clicking the Relationships button. When you do this, the system
will adhere to the hierarchy and not force users to also set up the constraints in
the account structure.
3-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NOTE: For more information about how to plan and implementing the
organization model, refer to the Organization Model chapter in the Installation
and Configuration course, or the "Implementing and Extending the Organization
Model" white paper.
Application Scenarios
The organization model is integrated with the application modules in Microsoft
Dynamics AX. There are two types of scenarios:
Address Book
Financial Dimensions
Legal entities and operating units can be used to define financial dimensions, and
those financial dimensions can be used in account structures.
Policy Framework
The policy framework provides support for override and default behavior for
organizations based on their hierarchies, and enables internal management
control of organizations to facilitate cost control, fraud detection, better operating
efficiency, and better performance generally.
Companies provided the data security boundary for most application data in
previous releases. The new extensible data security framework provides
capabilities to help secure data based on any condition.
3-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
A common scenario for data security is to filter master data or transaction data
based on a user’s association to internal organizations. The master data or
transaction data entity must have a foreign key relationship (field on the entity
table) with the organization to be able to set up a security policy.
Transaction Scenarios
There are several application areas that use the new organization model
framework. The primary effect is in the following modules. Here is a brief
description of the usage. For a complete description and steps for the scenarios in
these areas, refer to the Help documentation.
The lines of a purchase requisition are created for a buying legal entity, and they
are received in an operating unit such as a cost center or department. A purchase
requisition is created for a requester and is prepared by a preparer. Various
scenarios are enabled where you could view or create purchase requisitions for
all buying legal entities and receiving operating units in which you have access to
create requisitions.
Human resources
Expense reports and lines carry a legal entity to which the expense line item
should be charged from a statutory perspective, and they also carry an operating
unit for internal reporting.
Development
You can extend the organization model to support customization or special
configuration scenarios.
One of the core extensibility scenarios is extending the organization model for
specific industry vertical requirements such as retail, professional services, or
public sector. Branches, stores, schools, and school districts are basically
organization concepts. You can model them as new types of operating units. The
framework of the new organization model supports this extensibility by allowing
you to define a new type of custom operating unit.
3-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To define a query for the new type of operating unit, follow these steps.
3-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
To define a view based on the query that you defined, follow these steps.
1. In the AOT, right-click Data Dictionary > Views and then click
New View.
2. In Name, type OMStoreView.
3. In the Properties window, set the following values.
o Label = Store
o Query = OMStoreQuery
o TitleField1 = RecID
o TitleField2 = modifiedBy
4. Drag the following fields from the DataSource > Field nodes to the
OMStoreView > Fields node.
o OMOperatingUnitType
o LanguageId
o NameAlias
o Memo
o PartyNumber
o InstanceRelationType
o KnownAs
o Name
o OMOperatingUnitNumber
o OMOperatingUnitRecId
5. Drag the following fields into the Field Groups > AutoReport
node.
o RecId
o Name
3-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To define a new menu item to create new instances of this type of operating unit,
follow these steps. This menu item will open an operating unit form only for
creating operating units of the type Store. This step is optional.
1. In the AOT, right-click Menu Items > Display and then click New
Menu Item.
2. In Name, type OMStore.
3. In Label, type Store.
4. In Object, type OMOperatingUnit.
5. In EnumTypeParameter, type OMOperatingUnitType.
6. In EnumParameter, type Store.
class OMHierDesignExtClass
{
#ResAppl
#define.LegalEntityTopGradient("#FFA5CDFF")
#define.LegalEntityBottomGradient("#FF7EB8FF")
#define.LegalEntityBorderColor("#FF3F5C80")
#define.BusinessUnitTopGradient("#FF89C3E7")
#define.BusinessUnitBottomGradient("#FF4C9FD2")
#define.BusinessUnitBorderColor("#FF004b78")
#define.CostCenterTopGradient("#FFE2FFA6")
#define.CostCenterBottomGradient("#FFD6FF80")
#define.CostCenterBorderColor("#FF6B8040")
#define.DepartmentTopGradient("#FFA6ECFF")
#define.DepartmentBottomGradient("#FF80E3FF")
#define.DepartmentBorderColor("#FF407280")
#define.ValueStreamTopGradient("#FFFFCEA6")
#define.ValueStreamBottomGradient("#FFFFB980")
3-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
#define.ValueStreamBorderColor("#FF805D40")
#define.DefaultTopGradient("#FFDC143C")
#define.DefaultBottomGradient("#FFDC143C")
#define.DefaultBorderColor("#FF004b78")
FormRun m_HDForm;
OMOrganizationHierarchy m_omOH;
}
2. Build a new form (for example, a list page) for the transaction
scenarios, or change the existing user experience to view or maintain
transactions. The custom filters can help view or manage data across
organizations.
3. Apply default organizations on the transaction table in financial
dimensions by including them in account structures.
4. Create XDS policies for data security based on access to the
organizations of the user.
5. Use the policy framework to set up specific policies that are applied
while you are creating a new transaction in the application scenario.
3-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You must make special considerations if master data entities are referenced in the
application scenario because they have a relationship in the data model with the
transaction table.
While the goal is to resolve issues as swiftly as possible, not all issues and
questions can be resolved quickly and easily. They frequently require more than
one interaction in addition to collaboration and research before they can be
closed. Organizations need the ability to record and report on these issues.
3-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Case management provides the tools to handle issues more quickly and improve
customer, employee, and vendor relationships, and includes the following.
Case Process
Organizations need all cases to be handled consistently according to company
policies and procedures. To make sure that this occurs, case processes can be
defined to guide your workers through a simple checklist or a more elaborate
step-by-step set of stages and actions. This provides consistency in resolving
cases, and helps new case workers to become efficient and perform at a high
level in a short period of time. After a case process is defined, it can be
associated with a specific case category so that your case workers will know
what has to be completed for each situation.
Knowledge Articles
To resolve cases efficiently, case workers need easy access to processes and
procedures, answers to frequently asked questions, how-to documentation, and
other organizational knowledge collateral. The ability to create and store
knowledge articles provides case workers with the information that they must
have to resolve cases quickly. To help ensure even faster resolution, you can
associate specific knowledge articles with a case category, which will default the
knowledge articles to any case by using that category. This functionality reduces
the time that you have to have for a case worker to search for documentation.
3-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Scenario:
Vince, the Operations Manager, has noticed an increase in the number of calls
and the issues when vehicles are rented and returned. He wants a way to record
these issues when they are reported so that they can be followed up on. He has
decided to start by using case management to help with this process.
3-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
The CaseDetailsBase is the primary table for storing all cases regardless of where
the case is created from or which records the case is related to. Each case is
assigned a case category. Case categories are stored in the
CaseCategoryHierarchyDetail table. Each case can have logs or notes related to
the case. Each log entry related to a case is stored in the CaseLog table. When a
case is related to another case, this reference is stored in the CaseDependancy
table.
The CaseAssociation table is used to store a reference to each record that a case
is related to. The CaseAssociation table is then related to the primary table for
each type of association based on the CaseEntityType and RefRecId. For
example, when a case is related to a sales order, the CaseEntityType field would
store the enum value for the sales order table, and the RefRecId field would store
the RecID from the sales order that the case is related to.
3-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When a case is created from the Enterprise Portal the user details are stored in the
CaseWebDetails table.
Case Associations
Out of the box, cases can be related to the following data entities and tables.
Each case can have multiple associations and multiple associations of the same
type. For example, a case related to a specific customer, could also be related to
customer transactions.
3-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
1. Add a new element to the CaseEntityType base enum for the table
that you want to relate to. In this example, Vehicles for Fleet
management will be used.
2. Add a case statement to the smmAssociationLink.performLookup
method for the new entity. Use the following code sample to guide
you.
oSysTableLookup.addLookupfield(fieldnum(FMVehicle, VehicleID));
oSysTableLookup.addLookupfield(fieldnum(FMVehicle, VehicleModel));
oSysTableLookup.addLookupfield(fieldnum(FMVehicle, Description));
oSysTableLookup.parmQuery(oQuery);
oSysTableLookup.performFormLookup();
break;
case CaseEntityType::Vehicle:
menuItemName = menuitemdisplaystr(FMVehicle);
break;
case CaseEntityType::Vehicle:
tableId = tablenum(FMVehilce);
break;
case CaseEntityType::Vehicle:
fieldId = fieldnum(FMVehicle, VehicleId);
break;
3-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
3-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
boolean showMoreInformationGroup =
( showTrvExpTable || showTrvExpTrans ||
showsmmLeadTable || showsmmOpportunityTable ||
showInventTable || showServiceOrderTable ||
showHcmWorker || showPurchLine ||
showPurchTable || showSalesTable ||
showProjTable || showsmmBusRelTable ||
showVendTable || showCustTable ||
showCustTrans || showVendInvoiceJour ||
showVendInvoiceTrans || showFMVehicle);
if (caseMoreInformation_FMVehicles.visible() != showFMVehicle)
{
caseMoreInformation_FMVehicles.visible(showFMVehicle);
FMVehicle_DS.refresh();
}
1. Open Home > Area Page > Common > Cases > All cases.
2. Click Case in the New group of the Action Pane.
3. Select General > GEN1 in the Case category field.
4. Click Create.
5. Click No on the Create activity dialog box.
6. On the Associations FastTab of the Case form, click Add.
7. In the Entity type field, select Vehicle.
8. In the ID field, select a vehicle.
9. Save the record.
10. Click the Details button.
11. The Vehicles form should open to the vehicle you selected in step 7.
Close all the forms.
3-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: You can copy and paste the buttons from the SalesTable form onto the
FMVehicle form.
3-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Make sure that you specify an image resource, and set the data source property
on both menu items. The Vehicle form should resemble the following figure
when you are finished.
To test that the new buttons work correctly, follow these steps.
1. Open Fleet management > Common > Vehicles > All vehicles.
2. Select a vehicle.
3. Click the General tab on the Action Pane.
4. Click Create case.
5. Select a Case category.
6. Click Create.
7. Click No on the Create activity dialog box.
8. On the Associations FastTab, verify that an association is created for
the vehicle that you created the case for.
9. Close the forms.
3-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
This lab is designed for self-study. Completing this lab takes approximately 20
minutes.
Scenario
Vince, the Operations Manager, has noticed an increase in the number of calls
and the issues when vehicles are rented and returned. He wants a way to record
these issues when they are reported so that they can be followed up on. He has
decided to start by using case management to help with this process.
He wants to create cases for specific rentals to help control the return process for
vehicles. The inspectors will then record information that is collected during the
return such as the issues the customer had with the vehicle and the damage that is
found on the vehicle when it is returned.
So, Simon, the Business Systems Developer, must extend the case management
framework to allow cases to be associated to rentals.
Challenge Yourself!
Use the information that is provided to add rentals as a case association entity
type. Make sure that you add buttons on the Rental form to create the case and
automatically add an association.
3-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Step by Step
To create a new case association entity type, follow these steps.
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_03_02_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
oSysTableLookup.addLookupfield(fieldnum(FMRental, RentalID));
oSysTableLookup.addLookupfield(fieldnum(FMRental, Customer));
oSysTableLookup.addLookupfield(fieldnum(FMRental, Vehicle));
oSysTableLookup.parmQuery(oQuery);
oSysTableLookup.performFormLookup();
break;
case CaseEntityType::Rental:
menuItemName = menuitemdisplaystr(FMRental);
break;
case CaseEntityType::Rental:
tableId = tablenum(FMRental);
break;
3-45
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
case CaseEntityType::Rental:
fieldId = fieldnum(FMRental, RentalId);
break;
boolean showMoreInformationGroup =
( showTrvExpTable || showTrvExpTrans ||
showsmmLeadTable || showsmmOpportunityTable ||
showInventTable || showServiceOrderTable ||
showHcmWorker || showPurchLine ||
showPurchTable || showSalesTable ||
showProjTable || showsmmBusRelTable ||
showVendTable || showCustTable ||
3-46
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
showCustTrans || showVendInvoiceJour ||
showVendInvoiceTrans || showFMRental);
if (caseMoreInformation_FMRental.visible() != showFMRental)
{
caseMoreInformation_FMRental.visible(showFMRental);
FMRental_DS.refresh();
}
1. Open Home > Area Page > Common > Cases > All cases.
2. Click Case in the New group of the Action Pane.
3. Select General > GEN1 in the Case category field.
4. Click Create.
5. Click No on the Create activity dialog box.
6. On the Associations FastTab of the Case form, click Add.
7. In the Entity type field, select Rental.
8. In the ID field, select a rental. If there are no rentals, create one in
the Rentals form.
9. Save the record.
10. Click the Details button.
11. The Rental form should open to the rental you selected in step 7.
Close all the forms.
3-47
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: You can copy and paste the buttons from the SalesTable form onto the
FMVehicle form. Make sure that you specify an image resource, and set the data
source property on both menu items.
3-48
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Policy Framework
Microsoft Dynamics AX 2012 introduces a policy framework that can be used to
define policy rules in modules to help guide the flow of business. The framework
provides a common pattern and rich feature set that users can take advantage of
to enforce simple rules or to evaluate and act on several different rules in a
complex organizational hierarchy. The actual rules used by businesses, and the
actions that these rules allow, prevent, or alter are outside the scope of the
framework. However, this white paper does provide examples of the policy types
and rule types that that are included with Microsoft Dynamics AX 2012.
NOTE: The policy framework is only used for defining and enforcing business
rules. It is not related to the framework that creates extensible data security
policies also being introduced in Microsoft Dynamics AX 2012.
There are three perspectives from which the policy framework can be viewed and
used, depending on the role of the user.
NOTE: One person often performs the role of developer and software developer.
Developers and administrators can use the policy framework to improve their
business processes by enforcing rules for Microsoft Dynamics AX 2012 users.
Examples of rules include the following.
3-49
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
For each of these cases, a developer specifies the type of data that is stored in the
policy and how various forms and classes behave with that data. An
administrator then defines and manages who the policies will affect (and when)
and specifies the exact data values for each rule.
Framework Components
The policy framework consists of three main components that provide the
functionality that corresponds to the developer and administrator roles described
earlier.
These components provide the flexibility that developers and administrators must
have to achieve their objectives without problems. They also give the user the
same appearance and behavior as the rest of the policy user interface (UI) in
Microsoft Dynamics AX 2012.
Policy Types
A policy type is a collection of all the rule types that apply to a given module or
feature area.
Microsoft Dynamics AX 2012 includes six policy types. These types are
specified with the following SysPolicyTypeEnum enumeration values.
• ApprovalPolicy
• AuditPolicy
• PurchasingPolicy
• TrvExpensePolicy
• TrvRequisitionPolicy
• VendInvoicesPolicy
3-50
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Rule Types
Rules are at the core of any policy. The necessary data that defines how policies
will be enacted is located in rules. After a developer defines policy types and rule
types and he or she creates a policy, the policy administrator can add rules to that
policy. For example, suppose that an administrator adds a catalog rule to a
purchasing policy. The catalog rule is configured to specify the “Adventure
Catalog” for internal procurement. After the purchasing policy is associated with
a particular organization, all employees of that organization will see the
Adventure Catalog when they browse the internal procurement site.
Rules are date-effective, which gives you a set of powerful options for
manipulating policy events over time. You can define rules that take effect in the
present and expire sometime in the future, or that never expire. You can also set
up rules that will take effect at some specified point in the future. By defining
date-effective rules, you prevent multiple rules from being active at any given
time, when they might provide conflicting data.
After a rule has gone into effect, it can only expire or be discontinued. It can
never be removed from the policy. This constraint provides enhanced auditing
capability and historical policy retention. The policy framework can be queried
for the rules that were in effect at a specific time, if it is necessary.
Organization Assignment
Before a policy can affect anyone, it must be associated with an organization.
The administrator configures the association with the organization on the
SysPolicy form after a policy is created. In the business logic, the developer
queries the API for rules that are in effect for a specific organization.
All hierarchies with a specific hierarchy purpose can be sources from which to
select organizations. An additional source from which to select organizations is
the “flat list” of legal entities in the CompanyInfo table, which are designated in
the policy framework as “Companies.” (An example would be a legal entity with
a DataAreaId of “DAT.”) Although not a true hierarchy, this can be thought of as
a default hierarchy type that is always available.
3-51
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You can assign only organizations from a single hierarchy type to a given policy
(this is the typical scenario). If organizations from multiple hierarchy types
require the same policy, you must create multiple policies. For example, if you
have to create an AuditPolicy policy for employees of organizations in a
procurement hierarchy and for employees of companies in the “flat list” in
Microsoft Dynamics AX 2012, you will have to create a separate policy for each
group.
SysPolicyRule table
The SysPolicyRule table is the main table with which you will interact. To
demonstrate the design options that this table allows, you start with the output
and work backward. When you query the policy API (by using the
SysPolicies::getPolicyRuleIds method) for a list of rules for a given policy type,
rule type, and organization, the API returns an array of RecIds to the
SysPolicyRule table, which holds a list of specific rule instances. With this
strategy you can follow one of two general patterns shown for storing and
accessing your rule data. Select the pattern that best suits your requirements.
This is the more common pattern. There is just one set of data for each
rule, which is stored in one row in a table. To implement this pattern,
create a table that is a subtype of the SysPolicyRule table and add all the
fields required for your feature. A RecId that you receive from the policy
API will now directly correspond to a date-effective row in your table
(which is managed by the policy framework). You can directly query
your table without having to know that it extends the SysPolicyRule
table. You can view examples of this pattern in the
CatCatalogPolicyRule and TrvPolicyRule tables. For more information,
view the ER diagram.
3-52
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Use this pattern when you have to store several rows of information for
each rule (meaning, the rules are displayed as a grid on the rule form). In
this case, create a table with the fields that you must have that is not a
subtype of the SysPolicyRule table. Instead, add a foreign key to the
SysPolicyRule table to establish a many-to-one relationship. By doing
this, you can reference many rows of data in your table with one
SysPolicyRule RecId. You can view examples of this pattern in the
ProcCategoryPolicyParameter and ProcCategoryAccessPolicyParameter
tables.
3-53
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
3-54
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
NOTE: This figure shows the key relationships among all the tables in the data
model. None of the related tables will be directly queried. However, the diagram
provides a good basis for understanding the entity relations involved in the
policy framework.
SysPolicyType policyType =
SysPolicySetup::addPolicyType(SysPolicyTypeEnum::FleetMan
agementPolicy, HierarchyPurpose::PurchaseControl);
NOTE: This example uses the PurchaseControl hierarchy purpose. If you have
created a new hierarchy purpose, make sure that you select that purpose.
3-55
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
b. Later you will have to add a line of code for each rule type
related to the policy type. The format is as follows.
SysPolicySetup::addRuleType(policyType,
SysPolicyRuleTypeEnum::<PolicyRuleName>,
formstr(<PolicyRuleFormName>));
NOTE: This step cannot be completed until after you have created rule types and
forms for each rule type.
5. Modify the loadData method to call the method that you created in
step 4. Optionally you can add an IF statement to only call the
method if the configuration key is enabled.
The only two required fields in the SysPolicyType table are PolicyType and
HierarchyPurpose. The PolicyType field must match the value that you add to
the SysPolicyTypeEnum enumeration. The remaining fields are optional settings.
3-56
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Adding a new menu item also requires you to add the menu item to a menu and
to a privilege. Knowledge of how to do this is assumed and is not discussed in
this course.
In this example, it is assumed that your rule types are static and known at design
time. If your requirements require that the rule types must be dynamic (meaning
that is defined by the user) and added at run time, refer to the
SysPolicySourceDocumentRuleType form in the AOT for an example of this
pattern.
To add rule types to the SysPolicyRuleType table, edit the SysPolicySetup class
by completing step 4.b. in the “Create a Policy Type” procedure for each rule
type. There are several instances of this procedure in the class code that you can
follow as examples.
NOTE: This step cannot be completed until you have created a form for each
rule type.
3-57
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Several of these forms are included with Microsoft Dynamics AX 2012. Because
forms are feature-specific, more precise guidance cannot be provided about how
to design them. We recommend that you view the forms listed in the
RuleFormName column of the SysPolicyRuleType table for examples. The
following figure shows the CatCatalogPolicyRule form. It is the simplest
example because it contains just one piece of data for each rule.
3-58
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
After the developer has finished setting up the policies, a policy administrator
can configure policies as required by their business needs.
Summary
The Application Foundation Features chapter reviewed several features that are
used throughout the system.
The global address book is a central repository for addresses and contact
information. You can extend the global address book framework to create new
party types. You can also use the extensible data security policy framework with
the global address book framework to help secure address information across
legal entities, or teams, or both.
Developers and administrators can use security policies to block access to subsets
of data rows in tables. A policy resembles a where clause in an SQL select
statement. A security permission increases the access a user has to data, but a
security policy decreases access to data.
You can use financial dimensions to create "attributes" that you can use as
account segments for a shared chart of accounts. There are two basic types of
financial dimensions.
The organization model represents internal control, data security access, and
performance reporting structures designed to divide responsibility for human and
operations resources and work processes. The organization model in Microsoft
Dynamics AX 2012 introduces two new concepts—legal entity and operating
unit. You can extend the organization model framework to create new types of
operating units or new purposes for a hierarchy.
Case management provides the tools to handle issues more quickly and improve
customer, employee, and vendor relationships. You can extend the case
management framework to work with any data entity.
3-59
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
2. Which of the following are valid types of operating units that are available
out of the box? (Select all that apply)
( ) Department
( ) Cost Center
( ) Legal Entity
( ) Business Unit
3. Fill in the blanks with the name of the table that best describes the content of
the table to test your knowledge of this section.
Stores the parent child relationship between cases when a case is related to
another case. _____
Step:
3-60
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
5. Which of the following classes are used to add financial dimension controls
to a form? (Select all that apply)
( ) FinancialDimensionAccountController
( ) FinancialDimensionDefaultAccountController
( ) LedgerDimensionAccountController
( ) LedgerDimensionDefaultAccountController
7. List the four basic steps for creating a new operating unit type.
3-61
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
3-62
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 3: Application Foundation Features
Solutions
Test Your Knowledge
1. Which class is used to implement a single address on a form?
( ) DirUtiltity
( ) DirPartyLookup
(•) LogisticsEntityPostalAddressFormHandler
( ) LogisticsMultiEntityPostalAddressFormHandler
2. Which of the following are valid types of operating units that are available
out of the box? (Select all that apply)
(√) Department
(√) Cost Center
( ) Legal Entity
(√) Business Unit
3. Fill in the blanks with the name of the table that best describes the content of
the table to test your knowledge of this section.
Stores the parent child relationship between cases when a case is related to
another case. CaseDependancy
Step:
3-63
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
5. Which of the following classes are used to add financial dimension controls
to a form? (Select all that apply)
( ) FinancialDimensionAccountController
( ) FinancialDimensionDefaultAccountController
(√) LedgerDimensionAccountController
(√) LedgerDimensionDefaultAccountController
7. List the four basic steps for creating a new operating unit type.
MODEL ANSWER:
MODEL ANSWER:
The security configuration of each field is assessed for the current user. This
security behavior is called field trimming because the restricted fields are
trimmed out of the results before the results are sent from the AOS to the
client.
3-64
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Introduction
The following section describes a series of tasks that show the functionality used
in the General ledger, Budgeting, and Fixed assets modules. Participants will
be given the opportunity to understand the purpose of these modules from a
user’s viewpoint. Additionally, several of the key data and object models related
to these modules will be reviewed.
4-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You can use the consolidation functionality to combine the financial results for
several subsidiary legal entities into results for a single, consolidated
organization. The subsidiaries can be in the same Microsoft Dynamics® AX
database or in separate databases.
You can use the tools for forecasting cash flow and currency requirements to
estimate your legal entity’s future cash needs. You can then calculate, view, and
print forecasts of the cash flow. You can also calculate and display currency
requirements.
Fiscal calendars specify what time period financial data is posted, while currency
setup determines which currencies are available for business transactions.
4-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
To view currencies open General ledger > Setup > Currency > Currencies.
4-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Currency Calculation
Four pieces of information are necessary to perform a currency calculation in
Microsoft Dynamics AX 2012.
• From currency
• To currency
• Date
• Exchange rate type
CurrencyExchangeHelper Class
The CurrencyExchangeHelper class is introduced in Microsoft Dynamics AX
2012. It is the recommended Application Programming Interface (API) to
perform calculations between currencies. The following examples illustrate its
usage for the most common scenarios.
This example calculates the amount in the context of the current ledger. This is
indicated by passing Ledger::current() to the constructor method of the
CurrencyExchangeHelper class.
CurrencyExchangeHelper currencyExchangeHelper;
TransDate transactionDate;
CurrencyCode transactionCurrency = 'CAD';
AmountCur amountToConvert = 100.50;
boolean shouldRoundResult = true;
AmountMst result;
currencyExchangeHelper =
CurrencyExchangeHelper::newExchangeDate(
Ledger::current(),
transactionDate);
result =
currencyExchangeHelper.calculateTransactionToAccounting(
4-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
transactionCurrency,
amountToConvert,
shouldRoundResult);
info(strrfmt("%1",result));
NOTE: Additional code samples for calculating the transaction currency from
the accounting currency, and calculating the amounts by using an exchange rate
that is entered are available in the Shared Currencies and Exchange Rates
(http://go.microsoft.com/fwlink/?LinkId=238176)white paper.
ExchangeRateHelper Class
The same information used to perform currency calculations is used to work with
exchange rates.
• From currency
• To currency
• Date
• Exchange rate type
4-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
There are nine possible triangulation scenarios, three of which require two
exchange rates. As a result, all code must assume that two exchange rates are
possible and must always take this into account when storing them or passing
them to the calculation engine.
If a subsystem uses one exchange rate, most likely it is incorrect unless that rate
is a true cross rate that factors in both exchange rates. (Note that the
getCrossRate and getCrossRateReciprocal methods on the
ExchangeRateHelper class do factor in triangulation.)
Another important concept to understand is that the rates are always stored in
terms of the transaction (or reporting) currency to the accounting currency.
Therefore, when calling the exchange rate engine, make sure to set the “from”
and “to” currency accordingly. This is illustrated in the following example.
ExchangeRateHelper exchangeRateHelper;
TransDate transactionDate;
CurrencyCode transactionCurrency = 'CAD';
CurrencyExchangeRate exchangeRate1;
CurrencyExchangeRate exchangeRate2;
exchangeRateHelper = ExchangeRateHelper::newExchangeDate(
Ledger::current(),
transactionCurrency,
transactionDate);
exchangeRate1 = exchangeRateHelper.getExchangeRate1();
exchangeRate2 = exchangeRateHelper.getExchangeRate2();
4-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Both fiscal year and periods can be set up by the following measurements of
time—years, months and/or days.
Each period (at the ledger level) can be closed completely or put on hold to block
transaction postings, or set to enable selected users to continue an update of one
or more modules. To do this, open General ledger > Setup > Ledger, and then
click the Ledger calendar button.
The periods and fiscal year feature is useful for the preparation and reconciliation
of periodic and yearly accounts.
4-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Fiscal calendars are shared across multiple legal entities. The benefits of sharing
fiscal calendars include the following.
• Will support multiple fiscal calendars for each legal entity. For
example, fixed assets could require two calendars—one for auditing
purposes and one for tax purposes. If you have multiple calendars
you can run parallel depreciations.
• Reduces the amount of setup required for each legal entity because it
is possible to use the same fiscal calendar for multiple legal entities.
Before posting transactions, a new fiscal year must be divided into
periods since transactions cannot post unless a period is created for
the posting date.
Chart of Accounts
A chart of accounts is a set of main accounts tracked by Microsoft Dynamics
AX. It captures financial information that is used to make sound financial
decisions. Each account is assigned an account number as a unique identifier.
Each chart of accounts contains the account structures used by the chart of
accounts to define the segments and the valid combinations of main accounts and
financial dimension values. The chart of accounts is shared and it is also a list of
main accounts and structures, used to define a chart of accounts in use by one or
more ledgers.
• Main account
• Dimension values
• Chart of accounts
• Main accounts
• Account structures
• Advanced rules
• Financial dimensions
• Financial dimension values
4-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Financial Dimensions
Characteristics of financial dimensions include the following.
You can use the Financial dimensions form to create financial dimensions that
you can use as account segments for shared charts of accounts. Open General
ledger > Setup > Financial dimensions > Financial dimensions. There are two
basic types of financial dimensions.
After you have created the financial dimensions, use the Financial dimension
values form to assign additional properties to each financial dimension. When
you define a dimension that is based on a system-defined entity, you cannot add
values in the Financial dimension values form. However, you can view the
values. To add new values, you must access the main form for system entity. For
example, for the Customer entity you must add a customer in the Customer
form.
4-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Financial dimension sets have several purposes. Financial dimension sets are
used to determine how reports and inquiries related to the general ledger are
rendered. They are also used to calculate balances during the posting process.
Balances can also be scheduled for calculation or manually updated.
Balances are stored based on the financial dimension set and are calculated based
on the option to calculate with posting or batch schedule. Financial dimension
sets also drive the data displayed in the Trial balance list page.
The order in which financial dimension sets are considered in reporting effect
how transactions are sorted and fields are presented. For example, the set
Department and Cost center indicates that the Department dimension type is
first and Cost center second. Therefore, the considered financial set is the
composite of Department and Cost center. Department amounts are presented
first and Cost center amounts are presented second.
The defined financial dimension set can be used alone or in pairs when inquiring
or reporting on financial transactions. The selection of a primary and secondary
financial dimension set is considered when presenting the results. The secondary
financial dimension set details the figures of the primary dimension set. The
selection of a secondary financial dimension set is limited to dimension types that
do not share a dimension type with a primary dimension set. Therefore, if the
primary dimension set is the composite of Main account and Department, these
cannot be selected in the secondary financial dimension set.
Account Structures
You can use the Configure account structures form to create one or more
account structures. Open General ledger > Setup > Chart of accounts >
Configure account structures.
Accounts structures provide the segments and order of entry for the account
number. Main account is a required segment for an account structure, but it does
not have to be the first segment. The account structures are used to define the
valid combinations which, together with the main accounts, form a chart of
accounts. Multiple account structures allow a legal entity to track information for
specific accounts without affecting information in other accounts.
4-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Data Patterns
Default Account
The default account pattern consists of a single segment, main account. The
default account is a separate pattern from the main account because of the
additional business logic built into its underlying control. This business logic
handles data restrictions in lookups and other critical functionality that would
have to be developed separately in each uptake scenario without the control. A
foreign key representing a default account is a 64-bit integer field that contains
the data from the corresponding RecId field in the
DimensionAttributeValueCombination (or LedgerDimension) table.
Foreign key fields for default accounts are named LedgerDimension because that
is the alias used for the DimensionAttributeValueCombination table.
Main Account
The main account pattern represents just one of the possible segments in a ledger
account. A main account is required in a ledger account, but it does not have to
be the first segment. When referencing a main account as a foreign key, the
developer should set up a reference to the RecId field in the MainAccount table.
Ledger Account
A ledger account contains the main account, account structure, and the financial
dimension values that are needed to populate the related account structure and
account rule structures. A foreign key representing a ledger account is a 64-bit
integer field that contains the data from the corresponding RecId field in the
DimensionAttributeValueCombination (or LedgerDimension) table. Foreign key
fields for ledger accounts are named LedgerDimension because that is the alias
used for the DimensionAttributeValueCombination table.
Multi-type Account
The multi-type account pattern consists of an account type field and its related
ledger account or default account. In this pattern, a ledger account or default
account can store accounts other than ledger accounts. When the account type
field for the related account is set to “ledger,” this pattern becomes the default
account or ledger account pattern (depending on the extended data type used for
the field). If the account type field is not set to “ledger,” the pattern stores a
system-generated account structure (used to specify which account number
should be stored in the field) and an account number for the related account type.
For example, if the account type field is set to “customer,” the related account
number field will contain a customer number with a related account structure that
indicates that the account number field should contain a single customer value.
4-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
This pattern is primarily used for the setup and entry of financial journals. In this
case, a multi-type account will store one of six types of accounts, based on the
related account type field (asset, bank, customer, vendor, project, or ledger). A
foreign key representing a multi-type account is a 64-bit integer field that
contains the data from the corresponding RecId field of the
DimensionAttributeValueCombination (LedgerDimension) table. Foreign key
fields for multi-type accounts are named LedgerDimension because that is the
alias used for the DimensionAttributeValueCombination table.
4-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
The following figure shows the data model for the chart of accounts.
Default Dimensions
The default dimension pattern represents a set of financial dimensions and their
related values. A customer will set the values for given financial dimensions on
master data records for defaulting purposes or directly on some transactions. In
Microsoft Dynamics AX 2012, this pattern is represented by a single field. The
single field is a foreign key reference to the RecId field in the
DimensionAttributeValueSet table. This value references the correct record in the
4-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Dimension Set
The dimension attribute set pattern represents a set of financial dimensions and
their related enumeration values. This pattern is used in advanced general ledger
processing where different financial dimensions can be handled differently, based
on these stored enumeration values.
The dimension attribute set pattern is used to store a set of financial dimensions
and related data, such as enumeration values. This pattern is used in places where
it is necessary to store additional information about dimensions, such as whether
they are optional or required. For an example of this implementation, refer to the
VendPaymMode form under Forms in the Application Object Tree (AOT). A
foreign key representing a dimension attribute set is a 64-bit integer field that
contains the data from the corresponding RecId field of the
DimensionAttributeSet table. The new model allows you to store an unlimited
number of financial dimensions.
4-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
The following figure shows the data model for the financial dimensions.
4-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: You can create a new form, or you can use the VendPaymMode form in the
Hyper-V training environment to implement these changes.
1. Verify that the table that will hold the foreign key to the
DimensionAttributeValueCombination table as a data source on the form.
2. Drag the LedgerDimension field from the data source to the desired location
on the form design. This should add a Segmented Entry control at this location
on the form with appropriate DataSource and ReferenceField property values.
Alternatively, you can complete this step by adding a Segmented Entry control to
the design and manually setting the DataSource and ReferenceField properties.
public void
loadAutoCompleteData(LoadAutoCompleteDataEventArgs _e)
{
ledgerDimensionDefaultAccountController.loadAutoCompleteDat
a(_e);
super(_e);
}
4-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
public void
segmentValueChanged(SegmentValueChangedEventArgs _e)
{
ledgerDimensionDefaultAccountController.segmentValueChanged
(_e);
super(_e);
}
ledgerDimensionDefaultAccountController.parmControl(this);
ledgerDimensionDefaultAccountController.loadSegments();
}
5. Overload the following methods on the data source field that backs the
Segmented Entry control.
Control Options
There are four parameter methods available for specifying items that the control
can link to and validate. These parameter methods should be called in the
loadSegments method. These methods are called every time that the control
receives focus. Always declaring the parameters in one method ensures that
developers can easily verify whether all parameters have been correctly set.
4-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NOTE: The parameter name (LedgerPostingType) differs from the one for the
Ledger Account control because, in this case, it only restricts what is shown in
the lookup when the filter is selected. For account entry, it prevents entry of
values entirely.
NOTE: There is no special control for the main account pattern. This pattern
uses a foreign key that has a standard pattern in Microsoft Dynamics AX 2012.
Control Options
4-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
System-Defined Dimensions
With system-defined dimensions, it is not necessary to maintain two separate lists
of values for an entity you want to track details for in the general ledger. When
you set up a system-defined dimension, the values for the entity are automatically
copied from the entity table into the dimension values. Any time the data is
modified or a new record is inserted into the backing entity table, the information
is automatically updated in the dimension values.
Scenario
Ken, the Controller, wants to track the vehicle details in the general ledger.
Simon, the Business System Developer, needs to create a new system-defined
dimension for vehicles so that Ken will not need to maintain a custom list of the
vehicles in the Financial dimensions form.
After the new system-defined dimension is created, Ken must set up the new
financial dimension to be linked to the vehicles backing entity. Then, he must
add the new financial dimension to the account structure or advanced rules for
the chart of accounts. Simon also needs to add defaulting logic to the Vehicles
form so that when a new vehicle is created, the financial dimension for vehicles
will default to the current vehicle ID and cannot be changed. Then he must add
logic to the Rentals form to copy the financial dimensions from the vehicle to the
rental record.
4-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
b. Label = Vehicles
NOTE: This is the description that will appear in the Use values from drop-
down list on the Financial dimensions form.
c. FormRef = FMVehicle
d. SingularLabel = Vehicle
CRITICAL: The three fields must be named Key, Value, and Name for the
dimension to function correctly.
4-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
NOTE: At this point, you have created a system-defined dimension and set it up
as financial dimensions. Additional steps would be required to add the dimension
to an account structure or advanced rule. Additional coding would also be
required to default the dimension value on the vehicle and to copy the value from
vehicles to rentals.
4-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
This lab is designed for self-study. Completing this lab takes approximately 20
minutes.
Scenario
Ken, the Controller, wants to track the rental details in the general ledger. Simon,
the Business System Developer, needs to create a new system-defined dimension
for rentals so that Ken will not need to maintain a custom list of the rentals in the
Financial dimensions form.
After the new system-defined dimension is created, Ken must set up the new
financial dimension to be linked to the vehicles backing entity.
Challenge Yourself!
Use the information provided to create a new system-defined dimension for
rentals. The table that stores rentals is called FMRentals.
Step by Step
To add a new system-defined dimension, follow these steps.
4-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
6. Open a new AOT window, and then locate the FMRental table and
drag it to the Data Sources node of the DimAttributeFMRental view.
7. In the Properties window for the new data source, enter
BackingEntity in the Name property, and then save the view.
8. Expand the Fields node of the DimAttributeFMRental view and the
Fields node of the BackingEntity data source.
9. Drag the RecID field from the BackingEntity > Fields into the Fields
node for the view.
10. In the Properties window for the RecID field, enter Key for the
name.
11. Drag the RentalId field from the BackingEntity > Fields into the
Fields node for the view.
12. In the Properties window for the RentalId field, enter Value for the
name.
13. Drag the Comments field from the BackingEntity > Fields into the
Fields node for the view.
14. In the Properties window for the Comments field, enter Name for
the name.
15. Save the view.
16. Close Microsoft Dynamics AX.
17. Open Start > Administrative Tools > Services. Locate the
Microsoft Dynamics AX service and then click Restart service.
4-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Journals Overview
A journal is a worksheet you can use before you manually enter postings into the
system. Before you use financials in Microsoft Dynamics AX, you must
complete the setup procedures for journals. The procedures include the basic
setup of journals such as journal names, controls, and texts. You can use journals
quickly and efficiently when you set them up correctly.
Both manual and system generated journals exist in Microsoft Dynamics AX.
Examples of system generated journals are allocation journals and elimination
journals. These journals are created automatically and are never created
manually. Manual journal entries are generated by postings entered into the
system such as a general journal entry. When you use a manual journal entry the
transactions are not posted immediately. Before you post a manual entry, the
journal can be changed, reviewed, approved, or deleted.
Users can post transactions to the following accounts by using a general journal.
• General ledger
• Bank
• Customer
• Vendor
• Projects
• Fixed assets
4-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
In a general journal, users enter the following information for the transaction.
• Posting date
• Amount
• Accounts to post to
The information users enter in a general journal is temporary and can be changed
if it remains unposted within the journal.
4-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
4-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
The LedgerJournalTable table contains one record for each journal. A journal is a
set of journal transactions with a given status—either created or posted. Each
journal is related to a journal name and has a journal number. When a journal is
created, many of its parameters are copied from the corresponding record in
LedgerJournalName and can be set up individually for each journal. Records in
LedgerJournalTable are also used to block the journal while it is being posted.
The LedgerJournalParmPost table contains parameters that are used when you
post multiple journals by the batch. This is a periodic function, and it is an
alternative to activating posting directly from the current journal.
The LedgerJournalTxt table can be used to store typically used transaction texts.
Each text is associated with an alias that can be used when you enter information
in the journal line’s Description field. This table is not related to other tables that
are used by the ledger journal.
The postJournal() method selects the lines of the journal. For each journal line
postTrans() is called.
The class can be activated directly from X++ by using the following lines:
ledgerJournalCheckPost =
LedgerJournalCheckPost::newLedgerJournalTable(
ledgerJournalTable,
NoYes::Yes);
ledgerJournalCheckPost.run();
4-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The second parameter specifies whether the journal should be posted (true) or
validated (false).
The update of the individual journal line is handled by the class hierarchy
LedgerJournalTransUpdate.
The check() method is used when validating the journal. The checkWhenPost()
method is used when validating the journal during posting and the updateNow()
method handles the update of the posting.
Transactions Overview
The General ledger module records the value of all company assets. This
includes cash, accounts receivable, bank accounts, stocks, bonds, inventory,
buildings, and machinery. Any event that changes the value of these assets
should be reflected in ledger transactions.
4-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
The following figure shows General ledger module interfaces with other
Microsoft Dynamics AX modules:
The sales and purchase orders facilitate trade with vendors and customers.
Related stock changes are handled by the Inventory and warehouse
management module. Invoice payments occur through the Accounts payable
and Accounts receivable modules by using invoice journals and payment
journals. Every sales order generates revenue and a corresponding cost of goods
sold. Both are reflected in the General ledger module.
The Cash and bank management module keeps track of company bank
accounts, whose balance values are also reflected in the General ledger module.
When payments are posted to customer or vendor accounts using the payment
journals the customer and vendor balances are updated at the same time.
The Project management and accounting module keeps track of projects. This
includes registration of hours and customer invoicing. Revenues and related costs
are posted in the General ledger module. The periodic revenue assessment on
fixed price projects is also reflected in related transactions in the General ledger
module.
4-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The Fixed assets module keeps track of material assets used for operations such
as buildings and machinery and are not intended for sale like inventory products.
These asset values are recorded in the General ledger module, just as asset
revaluation and depreciation are also reflected there.
The Budgeting module keeps track of plans or budget amounts for the chart of
accounts. These estimated or budgeted amounts can then be compared to actual
amounts in the general ledger. The budget amounts are often times generated
based on the actual amounts from the general ledger.
Multiple factory methods exist to support different input scenarios. After using
one of these methods to create a class instance, a developer can customize the
instance by using the parm methods.
4-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
• GeneralJournalAccountEntry
• LedgerEntry
• GeneralJournalEntry
• LedgerEntryJournal
LedgerVoucher Class
The task of the LedgerVoucher class is to control ledger transaction postings.
You can use this class when you post ledger journals and other updates that
contribute to ledger transactions. It verifies the posting is correct and that the
voucher balances. The LedgerVoucher class holds all the vouchers in temporary
storage (a list array) until the End method is called. The End method creates
ledger transaction records from the temporary postings.
Posting (LedgerVoucher)
• Voucher (LedgerVoucherObject)
o Trans (LedgerVoucherTransObject)
o Trans
• Voucher
o Trans
o Trans
If new fields are added to the ledger transactions, this object can also hold the
new information. The remaining task is to initialize the new fields which
involves the following two steps.
4-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
ttsbegin;
ledgerVoucher = LedgerVoucher::newLedgerPost(….)
ledgerVoucher.addVoucher(LedgerVoucherObject::newVoucher(…)
);
ledgerVoucher.addTrans( LedgerVoucherTransObject::new…(…));
ledgerVoucher.addTrans( LedgerVoucherTransObject::new…(…));
ledgerVoucher.addTrans( LedgerVoucherTransObject::new…(…));
ledgerVoucher.addVoucher(LedgerVoucherObject::newVoucher(…)
);
ledgerVoucher.addTrans( LedgerVoucherTransObject::new…(…));
ledgerVoucher.addTrans( LedgerVoucherTransObject::new…(…));
ledgerVoucher.end();
ttscommit;
AXLedgerJournalTrans Class
The Ax-classes provided with Microsoft Dynamics AX are an encapsulation of
records and are typically used when importing data to Microsoft Dynamics AX.
4-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Scenario
Actively participating during this workshop will help you with the following.
• Understand the concept of how to import data into a journal and let
the standard application generate the transaction.
• Become familiar with the use of Ax-classes to import data to
Microsoft Dynamics AX tables.
• Extend the generic framework for importing data to be implemented
for a specific task with minimal effort.
Requirement
Create a solution that contains a function to import ledger transactions into the
general journal.
• Ledger account
• Transaction date
• Voucher number
• Transaction text
• Currency code
• Amount in currency
"606200","2006/09/10","ext00005","Insurance third
quarter","EUR",100.00
"606300","2006/09/10","ext00005","Pencils","EUR",200.00
"110180","2006/09/10","ext00005","Misc. cash
expenses","EUR",-300.00
"606300","2006/09/11","ext00006","Copy paper","USD",70.00
"110180","2006/09/11","ext00006","Copy paper","USD",-70.00
4-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Technical Issues
Base Import
A generic import class is included in your Hyper-V training image that can be
extended to the specific import tasks.
To create a class which can import from a file, you extend this class and override
these three methods.
Vouchers
When transactions are manually entered in the ledger journal, the vouchers are
typically allocated automatically by using a number sequence. To assign the
voucher during the import, the journal used should be set up with a manual
number sequence for vouchers.
4-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Step by Step
To import ledger transactions into general journal, follow these steps.
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_04_02_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
4-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
axLedgerJournalTable = AxLedgerJournalTable::construct();
axLedgerJournalTable.parmJournalName(journalName);
axLedgerJournalTable.save();
}
AxLedgerJournalTrans axLedgerJournalTrans;
AmountCur amountCur;
;
axLedgerJournalTrans =
AxLedgerJournalTrans_CustPaymJour::newLedgerJournalTable(axLedgerJourn
alTable.ledgerJournalTable());
axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Ledger);
axLedgerJournalTrans.parmLedgerDimension(
conpeek(_c,#PosLedgerAccount));
axLedgerJournalTrans.parmTransDate( conpeek(_c,#PosTransactionDate));
axLedgerJournalTrans.parmVoucher( conpeek(_c,#PosVoucherNumber));
axLedgerJournalTrans.parmTxt( conpeek(_c,#PosTransactionText));
axLedgerJournalTrans.parmCurrencyCode(
conpeek(_c,#PosCurrencyCode));
amountCur = conpeek(_c,#PosAmountCurrency);
if (amountCur > 0)
{
axLedgerJournalTrans.parmAmountCurDebit(amountCur);
}
else
{
axLedgerJournalTrans.parmAmountCurCredit(abs(amountCur));
}
4-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
axLedgerJournalTrans.save();
}
super();
}
NOTE: The sample mentioned in the requirement section is available in the file
that is named AX2012_ENUS_DEVIV_04_02_SAMPLEFILE.txt.
Test
As described earlier, you need a journal related to a manual number sequence to
assign voucher numbers read from the file. This includes the following steps:
4-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
After a successful import, you will find the journal created by using the path
General ledger > Journals > General journal.
You can repeat the test if you change the data file to use different voucher
numbers. Every time that the function is activated, a new journal is created.
NOTE: The Ledger dimension values provided in the sample file are record IDs.
In a more realistic import, additional code would be required to lookup the recID
for the dimension value combination that is entered by the user in the file.
4-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Budgeting Overview
You can use the Budgeting module to set up, create, and view budgets.
Budgeting can include budget control, used to monitor the budget funds that are
available for planned and actual purchases and expenditures. You can create
budget register entries for the original budget, budget transfers, and budget
revisions. You can also create budget register entries to manually reserve budget
funds for purchases and planned expenditures by using the encumbrance or pre-
encumbrance budget types. Budget register entries can be created automatically
when budgets are transferred to the general ledger from other modules such as
Project management and accounting or Fixed assets.
You can determine which financial dimensions from the chart of accounts will be
available for basic budgeting and budget control. When you configure budget
control, you define budget intervals, budget cycle time spans, budget thresholds,
budget managers, budget groups, and the calculation that is used to check for
available budget funds. The available budget funds can be verified when source
documents and accounting journals are entered. You can view the status and
history of budget register entries, budget control statistics, actual versus budget
amounts, budget details, and budget funds available.
One of most important management tools a company can use to make plans is to
compare planned performance to actual performance. Planning for the general
ledger is performed by creating budgets in the Budgeting module. A budget is a
set of expected ledger transactions. Although a budget can be as finely detailed as
actual transactions, budgets are more typically prepared at an aggregate level.
4-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Budgets are also used in balance sheet reports, where planned figures are
compared with actual values.
Before you use basic budgeting, complete the steps that are described in the
following topics. If you use budget control, you must set up basic budgeting
before you configure budget control.
You can set up basic budgeting and budget control based on the ledger for a legal
entity. The ledger provides the chart of accounts, accounting and reporting
currencies, and fiscal calendar. You can determine which financial dimensions
from the chart of accounts will be available for budgeting and budget control.
Additionally, you can define the following.
• Budget intervals
• Budget cycle time spans
• Budget thresholds, budget managers
• Budget groups
• Calculation used to check for available budget funds
4-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
The available budget funds can be verified when source documents and
accounting journals are entered. The following figure shows the data model for
the budget control configuration.
• General journals
• Allocation journals
• Project expense journals
• Fixed asset journals
• Accounts payable invoice journals
• Accounts payable invoice approval journals
• Accounts payable invoice registers
• Vendor invoices
• Purchase orders
4-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• Purchase requisitions
• Travel requisitions
• Expense reports
NOTE: The Project management and accounting module also uses its own
budget control. It is only integrated with the Budgeting modules budget control
through the Project expense journal. For more information about Project
management and accounting budgeting functionality, refer to the Advanced
Projects in Microsoft Dynamics AX 2012 course.
Budget Amounts
After you have set up and configured basic budgeting you can begin to enter
budget amounts. If you plan to use budgeting workflows, create the workflows,
and then assign them to budget codes before you begin to make budget register
entries. Also, if you plan to use budget control, configure budget control before
you enter budget amounts.
The budget data is entered through the Budget register entry form that consists
of a header and lines. The header information is applied to the whole budget
register entry and the lines (account entries) are where budget amounts for
specific dimension combinations are entered.
4-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
The following figure shows the data model for budget register entries.
When you have completed entering the budget register entries, you must update
the budget balances. This step is similar to posting a general journal and updates
the budget amounts based on the budget account entries.
4-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The BudgetCalculateBalance class queries for budget and posted ledger amounts
by fiscal period and uses the information to create records in the
BudgetTmpBalance temporary table. This class supports the Actuals vs. Budget
inquiry & report and role center chart.
Budget Checking
When budget control is enabled for a specific source document, budget checks
are completed automatically when the record is saved. The check is based on
options specified in the budget control configuration except for the budget
register which always perform a check on line save.
You can also manually perform a budget check on a transaction. Budget checks
are processed by using the BudgetControlProcessor class. There are core
integrations to the Budget control framework through the following classes as
well:
• BudgetControlSourceDocumentProcessor
• BudgetControlBudgetTransactionProcessor
• BudgetControlAccountingJournalProcessor
These classes handle common patterns for formulating the budget control check
request for the BudgetControlProcessor based on the type of integrator.
NOTE: A portion of the budget control checking logic occurs through stored
procedures on the SQL Server. The code for the SQL logic is contained in the
BudgetControlSQLObjects class and the T-SQL code is deployed to the SQL
Server at activation of the budget control configuration or first budget check.
When a budget check is completed and returns an error or warning, you can use
the Budget check errors or warnings form to view the details.
4-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
When you use the Fixed assets module, you can view the current value of all
fixed assets. The way in which fixed assets are handled must correspond to both
international accounting standards and the accounting legislation in each
country/region. Requirements might include rules for recording acquisition and
disposal transactions, depreciation, lifetimes, and write-ups and write-downs of
fixed assets. The fixed assets functionality incorporates many of these standards
and rules.
You must enter transactions to track the acquisition, depreciation, and disposal of
fixed assets. Sometimes you must change the value of an asset. For example, the
value of land that your organization owns might increase, or you might have to
reflect the fair market price of a specific asset.
4-45
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
It is important to define the differences between fixed and current assets before
discussing how to account for each. The classification of assets is not based on
the physical nature of the asset, but instead on the purpose of the ownership of
the asset.
Current assets are those that a company depletes in the typical course of business
over the next year or business cycle, whichever is shorter. Examples of current
assets include cash, accounts receivable, prepaid expenses, or inventory.
Fixed assets are assets that a company owns and uses in the day-to-day
operations of the company and are not intended for resale to customers. The
useful lives of these assets spans multiple years. Examples of fixed assets include
automobiles, computers, machinery, buildings, copyrights or trademarks (a
special class of assets frequently called intangible assets).
Based on these definitions, the same asset can be classified as a fixed asset in one
company and as a current asset or inventory item in another. An example of a
company where the same asset can be classified as both fixed and current is an
automobile dealership. The vehicles held for sale are inventory items in addition
to current assets, whereas the manager's company car is a fixed asset.
Because most fixed assets represent a significant investment for companies, the
ability to track and keep sound financial records on fixed assets is important.
4-46
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
This integration to the general ledger represents the minimum functionality that
the Fixed assets module must provide. Microsoft Dynamics AX 2012 provides
many additional features including the following.
Most of the basic setup steps are accessed by opening Fixed assets, and then
clicking Setup. The standard steps are as follows.
• Depreciation profiles
• Depreciation books
• Value models
• Fixed asset groups
• Posting profiles
• Parameters
4-47
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The AssetTable is the primary table for storing fixed assets. Each asset has one
record in this table. Each fixed asset is assigned to a fixed asset group. The fixed
asset groups are used to help simplify the setup of assets, for reporting and
inquiries, and to serve as a template with default information for setting up an
asset. The fixed asset groups and default data are stored in the AssetGroup table.
Each asset can have several value models that are stored in the AssetBook. The
default information for value models is stored in the AssetBookTable.
Additionally, each asset can have several depreciation books. Each depreciation
book for an asset is stored in the AssetDepBook table. The default information
for a depreciation book is stored in the AssetDepBookTable. Depreciation books
do not post to the general ledger like value models, so there is no accounting
related to them. The depreciation books are used to calculate various values of
the assets based on the depreciation profile selected for reporting purposes.
4-48
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Fixed assets transactions are posted by using a journal. This process is similar to
the general journal. The data model and classes used for posting fixed assets are
similar.
Summary
This chapter introduced currencies and exchange rates. Microsoft Dynamics AX
2012 supports multiple currencies and making conversions between currencies.
The CurrencyExchangeHelper and ExchangeRateHelper classes can be used to
make currency conversions.
Additionally, the chapter introduced the chart of accounts. The chart of accounts
consists of main accounts and financial dimensions. The main accounts and
dimensions are then constrained by the account structures and advanced rules in
use by the chart of accounts. You can define two types of financial dimensions—
system-defined and custom lists. Financial dimensions and main accounts can
also be combined to create dimension sets that are used to group and report on
specific combinations of dimensions.
Journals and transactions comprise the details of the general ledger. Journals are
used to make manual adjustments and are posted by using the journal framework
and the LedgerJournalCheckPost class. Other transactions such as sales order
invoices or expense reports are posted by using automatic journals with the
LedgerVoucher class hierarchy.
You can use the Budgeting module to create budget amounts for a specified
combination of the main account and financial dimensions. However, the main
account is not required for budgeting. You can use budget control checking to
enable a budget check on certain source documents. With this check you can
warn a user or prevent a user from posting a transaction that exceeds specified
budget thresholds.
The Fixed asset module is also used to create and track information related to
your companies fixed assets. You can keep multiple sets of books for each asset,
and use the fixed asset journal to acquire, depreciate, or adjust assets.
4-49
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. Which of the following tables are used for a new budget register entry?
(Select all that apply)
( ) BudgetTransactionHeader
( ) BudgetTransactionLine
( ) LedgerBudgetHeader
( ) LedgerBudgetLine
2. Which class holds a list of transactions that are going to be posted for a
particular voucher?
( ) LedgerVoucher
( ) LedgerVoucherObject
( ) LedgerVoucherObjectTrans
( ) LedgerVoucherTransObject
5. Which table is the primary table used for storing fixed asset information?
( ) AssetBook
( ) AssetTable
( ) AssetTrans
( ) AssetGroup
4-50
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
6. Which of the following tables are part of the ledger journal data model?
(Select all that apply)
( ) LedgerJournalName
( ) LedgerJournalTable
( ) LedgerJournalLines
( ) LedgerJournalTrans
7. Which of the following are valid field names to be used in a view for a new
system-defined dimension? (Select all that apply)
( ) Key
( ) Group
( ) Value
( ) Name
4-51
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
4-52
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 4: Use and Design of the Ledger Module
Solutions
Test Your Knowledge
1. Which of the following tables are used for a new budget register entry?
(Select all that apply)
(√) BudgetTransactionHeader
(√) BudgetTransactionLine
( ) LedgerBudgetHeader
( ) LedgerBudgetLine
2. Which class holds a list of transactions that are going to be posted for a
particular voucher?
( ) LedgerVoucher
(•) LedgerVoucherObject
( ) LedgerVoucherObjectTrans
( ) LedgerVoucherTransObject
MODEL ANSWER:
5. Which table is the primary table used for storing fixed asset information?
( ) AssetBook
(•) AssetTable
( ) AssetTrans
( ) AssetGroup
4-53
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
6. Which of the following tables are part of the ledger journal data model?
(Select all that apply)
(√) LedgerJournalName
(√) LedgerJournalTable
( ) LedgerJournalLines
(√) LedgerJournalTrans
7. Which of the following are valid field names to be used in a view for a new
system-defined dimension? (Select all that apply)
(√) Key
( ) Group
(√) Value
(√) Name
4-54
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
Introduction
A product is an item, service, or right that results from an economic activity. In
Microsoft Dynamics® AX 2012, all product data is shared across all companies,
and the virtual table collection concept is no longer available for product data .
The item representation (InventTable) used in earlier versions still exists, and this
table can still be included in a table collection. However, it now has a foreign key
to the shared product instance (EcoResProduct hierarchy), and it represents the
released product concept or a given enterprise product that is now authorized for
use inside a legal entity.
This chapter highlights the new patterns used to represent item-product master
data. This document does not describe all new functionality within the item-
product data management feature. Instead, this document focuses on the
development patterns and how they are implemented. A complete list of new
tables and their replacements can be found in the Implementing the Item-Product
Data Management Framework for Microsoft Dynamics AX 2012 white paper at
https://go.microsoft.com/fwlink/?LinkId=246121.
5-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Products
Product information management in Microsoft Dynamics AX 2012 targets the
creation and maintenance of an Enterprise Products Repository. It supports larger
organizations in a centralized structured approach in creating and maintaining
core master data such as product definitions. Smaller organizations that require a
more decentralized approach can, with some restrictions, create and maintain
their products while they are automatically added to the shared products
repository.
Product Maintenance
Product definitions are created independently of a legal entity, and core values
such as product number, type, and name are shared values.
Some core values can be overridden by a legal entity, an example is the search
name. Other values are kept as key definition attributes and they cannot be
changed other than on the actual product definition.
From a decentralized process, you can create and maintain products directly from
the Released products list page in the Product information management
module. A product definition is created by the system when a product is created
directly from the Released products list page.
• Products
o These are clearly identifiable products that do not have
variations associated with them. You can think of them as
standard or base products.
o Use the Products list page in the Product information
management module to view and manage products.
• Product masters
o These serve as templates or models for variants. The variants of
a product master can be predefined or created in sales scenarios
by using a product configurator. A product master is associated
with one or more product dimensions or for some configurations
or product attributes.
o Use the Product masters list page in the Product Information
Management module to view and manage product masters.
5-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
To view all products and product masters use the All products and product
masters list page by using the following path:
Product information management > Common > Products > All products and
product masters
5-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When you create a new product definition the type and subtype are the key
attributes to enter—they determine the additional functions and required setup.
5-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
Product Patterns
This pattern applies to the following tables.
• EcoResProduct
• EcoResProductMaster
• EcoResDistinctProductVariant
• EcoResDistinctProduct
All products are stored as system master data, and are used by organizations to
create and maintain shared product definition data.
The "product master" concept includes the product definition, and can have
variants in product dimensions (color, size, and configuration).
The "product variant" concept includes a product that has several of the
associated product dimension values (color, size, and configuration). It replaces
the previous "item combination" concept. Be aware that a product variant has all
the attributes and functionality of any other type of product.
The "distinct product" concept includes a product that does not vary in product
dimensions and therefore cannot have a product dimension group associated to it.
The products in a system can be released to a legal entity to become available for
various processes (sales, purchase, and production). The same shared product
variants can be available for production in one company, but not available for the
production in another legal entity.
5-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Product dimension values such as colors, sizes, and configuration are stored in
the system tables (EcoResColor, EcoResConfiguration, and EcoResSize) and are
immutable. The InventDim product dimensions values point to the
EcoResColor.Name, EcoResConfiguration.Name, and EcoResSize.Name
fields.
Releasing Products
The product release process is designed to enable users in an enterprise to move
or copy product definitions to various organizational units. By releasing a
product or a product master you associate it with a legal entity and authorize the
product definition for use in the legal entity.
5-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
Before you can use a product master on a transaction, such as a sales order or
purchase order, both the product master and one or more of its variants must be
released to each legal entity, if the configuration technology is set to be
predefined variants. When products are released, many combinations of products,
product masters, product variants, and legal entities can be released such as the
following:
5-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You must finalize a product in each legal entity where you have released it. In
Microsoft Dynamics AX there are four fields that must be set up on the Released
product form (open Product information management > Common >
Released products) before you can use the product on a transaction. You can
manually enter, or use a template to enter the following fields.
To make sure these four mentioned fields are set up, you can run a validation
check on the product in the respective legal entity. When you click Validate in
the Maintain group of the Action Pane, the system will check for the attributes
and produce a warning if no value exists.
5-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
• Product images: Each item can have multiple images linked to it.
The images are stored in the document handling system by using the
DocuRef table.
• Barcodes: You can define barcodes for each item. The
InventItemBarcode table contains information about the bar codes
that are used for items.
• GTIN: You can define Global Trade Item Numbers (GTIN) for each
item. GTIN is a 14-digit data structure used to uniquely identify
trade products. The InventItemGTIN table contains information
about items and their related GTINs.
Additional Functionality
The following sections describe additional functionality that is available to help
further classify and define the product information.
You can use category hierarchies to classify products for reporting and analysis
purposes. Each category hierarchy consists of a structure of subcategories. An
organization can create more than one category hierarchy. For example, your
organization might create one category hierarchy for classifying purchased
products and another hierarchy for classifying vendors.
5-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Product Attributes
You can use product attributes to identify the details that you want to maintain
for your products such as, Stock Keeping Unit (SKU) number, product version,
and so on. Product attributes also provide additional details that your
organization might want to record for a particular product or category. You can
associate product attributes together with a product through the category that the
product belongs to. When you add a category and its associated products to your
procurement catalog, the attributes assigned to the procurement category are
imported into the catalog and can display on the procurement site.
When you define product attributes, you must first define the attribute type and
then assign the attribute type to the attribute. The attribute type identifies the type
of data that can be entered for a specific attribute and a list or range of valid
values that can be used for the attribute. The attribute is the value that is
displayed with the product to provide the requester additional details about the
product.
Product Translation
When you use the Text translation form, you can create product translations by
entering descriptions and product names for multiple languages. However, the
product name and description are optional, only the product number is required.
The product translations are mainly used for output on external documents, and
the data values will always be shown in the system language, for example, when
you open and view the product related list pages and forms.
To open the Text translation form click the Translations button in the Action
Pane of All products and product masters forms or list pages.
5-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
The pattern that is applied to model product localization is consistent across the
application to model localization support for shared entities. The general system
translation forms are used to manage product translation. This enables a
consistent user experience in the way that the user interacts with the various
entities in the system for multilanguage translation (product, attributes, catalog
descriptions, and so on).
• ProductNumber
• ItemId
• EcoResProductIdentification
• EcoResProduct.DisplayProductName
• InventTable.ItemId
5-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Internally, all products have their own system-unique surrogate key that should
always be used to model the relationship to the product.
5-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
The InventTable still has an ItemId value that by default will be equal to the
corresponding product shared number value. However, in certain cases, you can
have an itemId value that differs from its product number value. With this option
you can have different identification strategies for the same product instance in
different legal entities.
Inventory Dimensions
There is a clear difference between product attributes and product dimensions.
You can use product dimensions to track their values in all major processes such
as for cost, inventory, and analysis purposes.
Product attributes are only associated with products and product masters, and
product dimensions can only be used together with product masters (except for
masters that are configured by using the option constraint-based configuration).
This is because they consist of the uniqueness of a product master’s variations.
5-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You can determine which product dimensions are mandatory for a given product
master by selecting the appropriate product dimension group when you create the
product master.
Microsoft Dynamics AX 2012 offers three product dimensions that include size,
color, and configuration.
The product dimension group can be assigned only when the product is being
created. The storage and tracking dimensions groups can be assigned to the
product on two levels—system level, where they are used in all legal entities
where the product is released, and the legal-entity level, where they are used only
for the product that is in that specific legal entity.
5-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
To determine if a dimension for a specific field is active you can use the
following code sample.
InventTable inventTable;
InventDimGroupSetup inventDimGroupSetup;
InventDimGroupFieldSetup inventDimGroupFieldSetup;
inventDimGroupSetup =
InventDimGroupSetup::newInventTable(inventTable);
inventDimGroupFieldSetup =
inventDimGroupSetup.getFieldSetup(fieldNum(InventDim,WMSPal
letId));
if (inventDimGroupFieldSetup.isActive())
{
info(strFmt("The palletId dimension is active for
dimension group
%1",inventDimGroupSetup.getStorageDimensionGroup()));
}
5-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Configuration Technologies
You can use the product setup to model configurable products. When you work
with product masters it is important to define how the variations of a master are
created. Frequently, many mandatory attributes must be specified to create a new
variation.
Configuration Definition
technology
Predefined variant With this type the product can be modeled based
on the product dimensions, color, configuration,
and size. This is the only option that can be set up
directly with product variants. Any combination
of the product dimensions is allowed.
Dimension-based A configuration technology that is used to create
configuration product variants by selecting values for product
dimensions. Any combination of the product
dimensions is permitted. The advantage of the
dimension configuration is that only one product
is required for a bill of material.
Constraint-based With this type the product can be used in the
configuration Product Configurator. To select this type, the
product dimension group must have a
configuration selected, and no other product
dimensions can be enabled. The constrain-based
configuration used the attributes described earlier.
NOTE: Rule-based configuration is used for items that implement the Product
builder functionality. This option is only available for customers who are
upgrading from an earlier version. This option will be removed in future
releases. Therefore it is recommended that you move to the Constraint-based
configuration option.
5-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
• EcoResProductMasterDimValue and
EcoResProductVariantDimValue hierarchies
• InventDim
The product master holds relations to all possible product dimensions values
within one product attribute. The product variant holds one—and only one—
relation to the product dimensions value within one product attribute. The
InventDim structure holds the relationships to the shared product dimension
values.
5-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• InventTable
• InventDimCombination
Products and product variants must be released to a specific legal entity before
they can be used with that legal entity. The InventTable and its associated tables
use the concept of the released product and can also be treated as the instance of
the particular product in the current company. The mandatory product foreign
key is added to the InventTable. The InventTable represents the instance of either
a product master or a distinct product.
5-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
The InventDimCombination table and its associated tables use the concept of the
released product variant and can also be treated as the instance of a product
variant in the current company. The mandatory DistinctProductVariant foreign
key is added to the InventDimCombination table. The InventDimCombination
always represents the instance of a product variant.
Item model groups determine the following stock and inventory policy:
5-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
An item model group setup is important when you determine how the item will
integrate with other areas of the Microsoft Dynamics AX 2012 system. You can
view the item model groups by opening Inventory and warehouse
management > Setup > Inventory > Item model groups.
If an item model group is set up for a not stocked product, many of the
parameters are irrelevant. The following table displays the parameters that are
relevant to a product that are maintained in stock versus products that are not
maintained in stock.
5-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
When a product is defined as not stocked, there are several differences in how
transactions are handled, and certain types of transactions are restricted. For
example, when a not stocked product is added to a purchase order, the system
will not track the on hand quantity or create an inventory transaction
(inventTrans table record). You can process this purchase order in the same
manner as the purchase order with stocked product.
The following figure shows the data model for item groups and item model
groups.
FIGURE 5.10 ITEM GROUP AND ITEM MODEL GROUP DATA MODEL
5-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Scenario
Challenge Yourself!
By using the provided information, add a new field to the product that is copied
to the released product. Make sure that the field can be edited and that it is
required by adding logic into the Validate button on the Released products
form.
5-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
Follow these steps to add the MSRP field to the EcoResProduct table and the
EcoResProductDetails form.
1. Under the Data Dictionary node in the AOT window, expand tables
and locate the EcoResProduct table.
2. Drag the table into the project that you created in step 3.
3. Expand the EcoResProduct table.
4. Select the MSRP extended data type and drag it to the Fields node of
the EcoResProduct table.
5. Save the table.
6. Right-click the Field groups node and then click New Group.
7. Set the following values in the Properties window.
a. Name = MSRP
b. Label = MSRP
8. Select the MSRP field from the Fields node on the EcoResProduct
table, and then drag it into the MSRP Field group.
5-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
18. Close the Product details form, and go back to the Development
workspace.
Follow these steps to add the MSRP field to the InventTable and the
EcoResProductDetailsExtended form.
1. In the AOT, locate the InventTable under the Tables node of the
Data Dictionary.
2. Drag the InventTable into the project that you created earlier.
5-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
8. Select the MSRP field from the Fields node of the InventTable and
then drag it into the MSRP Field Group node.
9. In the AOT window, expand Forms and then locate the
EcoResProductDetailsExtended form.
10. Drag the EcoResProductDetailsExtended form into the project that
you created earlier.
11. Save the project.
12. Right-click the EcoResProductDetailsExtended form and then
click Restore.
13. In the Data Sources node of the form browse to InventTable >
Fields and then select the MSRP field group (folder) from the list.
14. Drag the MSRP field group into the bottom of the TabPageSales
tabpage under the Design node of the form. (To locate the
TabPageSales tabpage, browse to Designs >Design > Tab:Tab >
TabPage:Details > Tab:TabHeader > TabPage:TabPageSales in
the EcoResProductDetailsExtended form.)
5-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
17. Close the Released product details form and go back to the
Development workspace.
5-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
if (!MSRPSet)
5-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
fieldList.addEnd("MSRP");
5-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
Summary
The Product information management module provides functionality to set up
and maintain the details of products across legal entities and to set up legal entity
specific data for released products.
The module also includes functionality that will categorize products, create and
store custom product attribute details for each product, and support the entry of
translations for many fields on the product details.
NOTE: More information about the item-product data model, upgrade for
earlier releases, and coding patterns can be found in the Implementing Item-
Product Data Management Framework for Microsoft Dynamics AX 2012 white
paper at https://go.microsoft.com/fwlink/?LinkId=246121.
5-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. TRUE or FALSE? All products are stored as system master data, which
allows organizations to create and maintain shared product definition data.
( ) True
( ) False
5-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 5: Use and Design of the Product Information Management
Module
1.
2.
3.
5-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Solutions
Test Your Knowledge
1. TRUE or FALSE? All products are stored as system master data, which
allows organizations to create and maintain shared product definition data.
(•) True
( ) False
5-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
Introduction
The following sections explain the functionality offered by the Inventory and
warehouse management module by describing a series of tasks that are
performed by using the module.
The following main tasks are supported by the Inventory and warehouse
management module.
6-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When an item is delivered to a customer, the cost value of the item is used to
calculate the sale’s contribution margin. You can allocate a single sale of an item
against a specific stock lot to make sure that this calculation is completed
correctly. This concept is known as marking. Marking is used on items where the
average cost could be misleading because of large fluctuations in the costs of
individual stock lots.
Reservations Overview
There are two basic types of reservations in Microsoft Dynamics AX 2012—
reserved physical and reserve ordered. A physical reservation is a hard allocation
or reservation. When a transaction is physically reserved, the item is available in
the warehouse and it is specifically set aside for the transaction(s) that it is
reserved against.
The reserve ordered type reservation is a soft allocation. This means the items are
currently on order and those specific ordered items are reserved for a specific
transaction. When the items are available in inventory, the reservation is changed
from reserve ordered to reserved physical. For example, you have created a sales
order for 100 widgets. The widgets are not available in inventory. However there
are several open purchase orders for the item so that you can make an ordered
reservation for the widgets against the sales order. After the widgets are received,
the reservation can be updated to a physical reservation.
6-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
The InventSum table is used to make sure that the reserved quantities are
available. This requires that negative physical inventory is not allowed and it is
controlled by the item model group that is specified on each released product.
The control of the availability only considers the dimensions that are marked as
part of the physical inventory.
NOTE: For more information about the inventory transaction data model, refer
to the "Inquiries and Transactions" topic in this course.
On hand
The quantity on hand (available quantity) is a key figure when you make
decisions related to a specific item. This information can be supplemented by
expected stock movements because of future purchases, production, or sales. One
of the main purposes of the Inventory and warehouse management module is
to supply this important information; many of the other functions described are
intended to maintain this information.
Transactions
6-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Inventory Transactions
Many different actions in the system can trigger how you can create inventory
transactions. The four primary transactions include the following.
Refactoring helps reduce the amount of data that is stored (disk space) and help
parts of the table to avoid redundant data and the inherent risk of inconsistent
data.
6-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
The following figure shows the data model for inventory transactions.
InventTrans Relationships
The split of the InventTrans table affects code that uses the relationships between
the inventory transaction originating tables and the inventory transaction table.
The InventTransId field is removed from the InventTrans table and is replaced
by the InventTransOrigin field to reference the InventTransOrigin table. Some
inventory transaction originating tables keep the InventTransId field; however,
the field cannot be used to reference the InventTrans table. All inventory
transaction originating records must first be referenced by a record in the
InventTransOrigin table that references the InventTrans table. The following
code example shows how to do this.
6-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
This change also affects other objects that used the InventTransId field to find,
collect, or summarize data from the InventTrans table.
InventMovement Class
The InventMovement class is used to wrap a record that is responsible for
generating inventory transactions. Sales line, production table, and inventory
journal line are examples of tables that hold this type of records. The concept is
to make a common presentation of the data attributes and ignore the source.
6-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
InventUpdate Class
You can use the InventUpdate class to make a specific change to the state of the
data. Reservation, Pick, and Delivery are examples of state changes covered by
this class.
InventUpdate is extended to cover each update. The following figure shows the
class hierarchy for the InventUpdate class.
Each InventUpd_ class has a series of static methods with a prefix new. They are
used to initialize the object that has a specific set of parameters.
The following pattern is typically used when you work with InventUpdate.
inventUpd_Reservation =
InventUpd_Reservation::newMovement(movement, reservation,
mayBeReduced);
inventUpd_Reservation.updateNow();
6-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Inventory Statuses
The inventSum table contains the sum of all inventTrans for each combination of
ItemId and InventDimId. InventTrans has two fields that specify the status of the
transaction—StatusReceipt and StatusIssue. InventSum has several fields that
specify the quantity of items of a different status.
Designs that use InventSum are preferred for performance reasons, because it
prevents the summing of transactions during both the calculation of available
quantities and the control of negative inventory.
6-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
InventOnHand Class
The InventSum table contains consolidated figures for each item and dimension
combination. The content of this table is redundant to the data in InventTrans.
The reason for this design is to increase performance when calculating quantity
on hand.
InventOnHand class is used to wrap the InventSum table and should be used to
retrieve the information.
The class has several different static methods that are used to initialize the object.
You can use the static method InventOnHand::newItemDim to retrieve the
consolidated quantities for the specified dimension values. The following code
sample shows how to call this method.
ItemId itemId;
InventBatchId inventBatchId;
InventDim inventDimCriteria;
InventDimParm inventDimParm;
InventOnHand inventOnHand;
inventDimCriteria.clear();
inventDimCriteria.inventBatchId = inventBatchId;
inventDimParm.clear();
inventDimParm.InventBatchIdFlag = NoYes::Yes;
InventOnHand = InventOnHand::newItemDim(itemId,
inventDimCriteria,
inventDimParm);
InventDimOnHand Class
You can use the InventOnHand class to calculate consolidated figures for one
specification of an item ID and a dimension combination.
You can use the InventDimOnHand class to have individual figures for a more
detailed specification, than the one being used to limit the query.
The following sample shows how to obtain the physical quantity available for
each item included on a specific inventLocationId and wmsLocationId.
6-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
InventDimOnHand inventDimOnHand;
InventDimOnHandIterator inventDimOnHandIterator;
InventDimOnHandMember inventDimOnHandMember;
InventDim inventDimCriteria;
InventDimParm inventDimParmCriteria;
InventDimParm inventDimParmOnHand;
inventDimCriteria.clear();
inventDimCriteria.InventLocationId = inventLocationId;
inventDimCriteria.wmsLocationId = wmsLocationId;
inventDimParmCriteria.initFromInventDim(inventDimCriteria);
inventDimParmOnHand.clear();
inventDimParmOnHand.ItemIdFlag = NoYes::Yes;
inventDimOnHand = InventDimOnHand::newAvailPhysical(
'',
inventDimCriteria,
inventDimParmCriteria,
InventDimOnHandLevel::SpecPositive,
inventDimParmOnHand);
inventDimOnHandIterator = inventDimOnHand.onHandIterator();
while (inventDimOnHandIterator.more())
{
inventDimOnHandMember = inventDimOnHandIterator.value();
itemId = inventDimOnHandMember.parmItemId();
qty = inventDimOnHandMember.parmInventQty();
...
...
inventDimOnHandIterator.next();
}
6-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
The costing method is determined by settings on the item model group for each
product. Any number of costing methods can be used in a single installation.
When a method other than standard costing is used, the system records
transactions at the weighted average in real time. Then, a process that is known
as Inventory close must be run periodically to make adjustments from the
weighted average to the actual costing method. Additionally, the process makes
settlements between the receipts and invoices. After this process is complete the
inventory is stopped up to the date that inventory is closed for. This means that
no additional transactions can be posted with a date earlier than the specified
date.
When the inventory close process is run, the system updates the transactions
(inventTrans table records) with a new status in the ValueOpen field, records the
closed date, and records any adjustments for each inventory transaction.
InventSettlement
When a withdrawal from inventory is updated financially, it will be assigned a
cost value that is based on the current status of the inventory. Later, financial
receipt updates could affect the originally calculated cost value. There is no
automatic recalculation of the cost of goods sold for the update of the receipt.
6-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
However, a periodic run of the inventory close process will reevaluate the
assigned cost value. The original cost value is specified in the
InventTrans.CostAmountPosted field. The adjustment will not change this
original value. However, the change will be specified in the
InventTrans.CostAmountAdjustment field. If the transaction is affected by
more than one adjustment, this field will contain the consolidated adjustment.
Each adjustment is logged in the InventSettlement table. The following figure
shows the relationship between inventory transactions and settlements.
The InventTrans.costValue() method returns the current cost value that is the sum
of the CostAmountPosted and CostAmountAdjustment fields.
6-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
Items are bought through the Procurement and sourcing module or produced in
the Production control module. Items are consumed by sales orders, projects or
production orders. The Ledger module keeps track of inventory value and
consumption costing.
Inventory Journals
The primary way that inventory is updated in Microsoft Dynamics AX is through
sales orders, purchase orders, and production orders. Inventory journals are an
alternative that you can use to make manual updates to the inventory. Several
types of journals can be used to make updates.
Each inventory journal consists of a header and lines. The header defines the
journal information that is configured on the journal name. These inventory
journal names resemble the journal names and types that are defined in the
General ledger module.
The journal lines are used to define the items, dimensions, and quantities. Each
type of journal has small differences. However, the main principle is that the
journal has inventory transactions in the inventTrans table that are used to add or
remove inventory.
6-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Journal Types
The four primary journal types are described in the following sections.
Movement
Inventory Adjustment
Counting
Transfer
A transfer is used when a lot is moved from one warehouse to another. The same
function is also used to change other inventory dimensions, such as batch ID,
serial ID, pallet, or warehouse location.
Additional journal types are available for item arrivals, production input, and tag
counting. For more information about other journal types, refer to the Help.
6-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
6-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
InventJournalCheckPost Class
The InventJournalCheckPost class prepares for the validation and posting of an
inventory journal. It uses the baseEnum InventJournalType to construct an
instance of the correct type. The JournalCheckPost class actually does the
validation and posting.
The class can be activated directly from X++ by using the following lines of
code.
JournalCheckPost =
InventJournalCheckPost::newPostJournal(inventJournalTable);
JournalCheckPost.run();
6-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
Scenario
Simon, the Business System Developer, must upload the beginning inventory on
hand balances for the products that Contoso sells. The information is currently in
a spreadsheet and must be imported. Simon must create a new class that includes
a dialog box that has a field that allows the user to browse to the desired file, and
a drop-down box to select the journal name to be used for the import.
The import tool should be fixed to only allow the import of movement journals.
The journal should not be posted automatically to allow the user to review the
journal before he or she manually posts the journal.
Challenge Yourself!
Use the provided information to create a new class that has a dialog box that has
two parameters for selecting a file and a journal name. Add logic to the OK
button in the dialog box to open the selected file and create a new movement
journal header by using the journal name that is specified in the dialog box. Each
line of the spreadsheet must be imported into the journal lines. When the file is
finished processing, the users should receive an Infolog informing them of the
journal number.
1. Create a new project to store the objects that you create or modify as
a part of this workshop.
2. Create a new class.
3. Add methods to the class for a dialog box. For an example of how to
create a dialog box in a class, refer to the Tutorial_RunBaseBatch
class.
4. Add a progress indicator to the class. For an example of how to
implement a progress indicator, refer to the Tutorial_Progress class.
5. Add validation to the class to verify that the two fields in the dialog
box are populated with a value.
6. Add methods to the class to open an excel file and read in the
contents of the file. Use the SysExcelApplications and
SysExcelWorkbooks classes to open and process the file.
7. Add a method to correctly close the Excel file when you are finished.
6-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
8. Add methods to the class to create a new journal header and journal
lines. For a sample of code that creates movement journals, refer to
the TutorialJournalCreateExample.
9. Create a menu item to open the new dialog box, and put the menu
item in the Periodic folder of the Inventory and warehouse
management module.
10. Create a new journal name to be used for the import in the
tutorial_JournalName form.
11. Test the import by importing the
AX2012_ENUS_DEVIV_06_01_LAB_SAMPLEFILE.xls file from
the Hyper-V training image.
Step by Step
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_06_01_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
To create a new class that is copied from the Run Base Batch Tutorial, follow
these steps.
6-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
To update the code in the class for the dialog to importing beginning balances,
follow these steps.
// Excel objects
SysExcelApplication oSysExcelApplication;
SysExcelWorkbooks oSysExcelWorkbooks;
SysExcelWorksheets oSysExcelWorksheets;
SysExcelWorksheet oSysExcelWorksheet;
SysExcelCells oSysExcelCells;
// Dialog fields
DialogField dlgFileNameOpen;
DialogField dlgInventJournalNameId;
#define.CurrentVersion(1)
#define.Version1(1)
#localmacro.CurrentList
fileNameOpen,
inventJournalNameId
#endmacro
}
4. Update the description of the class. Use the following code sample to
guide you.
6-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
if (ImportBeginningBalances.prompt())
ImportBeginningBalances.run();
}
return dialog;
}
6-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
return super();
}
To add validation, a progress indicator, and logic to import the file, follow these
steps.
1. To add validation to the class, modify the validate method. Use the
following code sample to guide you.
2. Add the following code that is used to initialize the objects for
importing a spreadsheet in the init method.
6-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
catch
{
throw error(strfmt("@SYS76826", fileNameOpen));
}
oSysExcelWorksheets = oSysExcelApplication.worksheets();
return true;
}
void startProgress()
{
#avifiles
SysOperationProgress oProgress;
oProgress = new SysOperationProgress();
oProgress.setAnimation(#aviupdate);
oProgress.setCaption(ImportBeginningBalances::description());
oProgress.update(true);
}
4. Create a new method called readAll that opens the file and reads the
records. Use the following code sample to guide you.
InventDim tInventDim;
TutorialJournalTable journalTable;
TutorialJournalTrans journalTrans;
TutorialJournalTableData journalTableData =
JournalTableData::newTable(journalTable);
TutorialJournalTransData journalTransData =
6-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
journalTableData.journalStatic().newJournalTransData(journalTrans,journalTa
bleData);
// Init journalTable
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;
journalTable.JournalNameId = inventJournalNameId;
journalTableData.initFromJournalName(journalTableData.journalStatic().findJ
ournalName(journalTable.JournalNameId));
oSysExcelCells = oSysExcelWorksheet.cells();
while (startRow <= #SP_END_ROW)
{
journalTrans.clear();
journalTransData.initFromJournalTable();
journalTrans.TransDate = oSysExcelCells.item(StartRow,
#SP_READ_TRANSDATE_COLUMN).value().date();
journalTrans.ExItemId = this.cell2String(StartRow,
#SP_READ_ITEMID_COLUMN);
journalTrans.ExCostAmount = oSysExcelCells.item(StartRow,
#SP_READ_COST_COLUMN).value().double();
journalTransData.create();
StartRow ++;
}
journalTable.insert();
}
catch
{
throw error("Reading values from Excel file failed.");
}
}
6-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
if (! oSysExcelCells)
{
ret = '';
}
else
{
switch (oSysExcelCells.item(_row, _column).value().variantType())
{
case COMVariantType::VT_BSTR:
// String type
ret = strltrim(strrtrim(oSysExcelCells.item(_row,
_column).value().bstr()));
break;
case COMVariantType::VT_R8:
// Real type
ret = strltrim(strrtrim(num2str(oSysExcelCells.item(_row,
_column).value().double(),0,0,0,0)));
break;
default :
ret = '';
break;
}
}
return ret;
}
6-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
7. Modify the run method to execute the logic you created in the
startProgress, init, readAll, and exitExcel methods. Use the following
code sample to guide you.
/// <summary>
/// Contains the code that does the actual job of the class.
/// </summary>
public void run()
{
#OCCRetryCount
if (! this.validate())
throw error("");
try
{
ttsbegin;
this.startProgress();
this.init();
this.readAll();
this.exitExcel();
ttscommit;
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
this.exitExcel();
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
this.exitExcel();
throw Exception::UpdateConflict;
}
}
catch (Exception::Error)
{
6-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
error("Import failed!");
this.exitExcel();
}
8. Save and compile the class, and then close the Code Editor window.
Test
To create a new menu item and put it on the main menu in the Inventory and
warehouse management module under the Periodic folder, follow these steps.
To create a new journal name to be used for the import, follow these steps.
6-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
To test the new menu item and import process, follow these steps.
6-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
4. Notice the journal header that is imported, and then click Lines.
5. Notice the journal lines that are imported. Your data should look
similar to the following figure.
TIP: You can repeat the test as many times as you would like. The journal
number and voucher numbers will automatically increment during each import.
NOTE: This lab uses the Microsoft Dynamics AX 2012 Tutorial tables, classes,
and forms. In a more realistic implementation, you should create your own
tables, forms, and classes.
6-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
Quarantine Orders
The quarantine function is used to block a specific lot. When the quarantine is
started, the quantity is removed from available inventory. Later, when the
quarantine is ended, the quantity is returned to available inventory. One use of
this function is to block a received lot until it has passed quality assurance.
Quality Orders
You can use quality orders to identify the tests and to record test results and test
quantity for a specific item.
The tests are copied from the test group that is assigned to the quality order. Tests
can be added, deleted, or changed. A quality order can be manually created or
automatically generated based on rules that are defined in the Quality
associations form found in Inventory and warehouse management > Setup >
Quality control. A quality order is associated with an item in a sales order, a
purchase order, a quarantine order, a production order, a production order routing
operation, or an on-hand inventory balance. Items that are specified for
inspection in a quality order are automatically blocked from issue or
consumption.
Each quality order is stored in the InventQualityOrder table. The lines of the
quality order represent each test to be performed and stored in the
InventQualityOrderLine table. Each test or quality order line can have test results
recorded for it that are stored in the InventQualityOrdersLineResults table. The
InventQualityManagementCreate class provides the facilities for quality
management order generation.
Inventory Blocking
Inventory blocking is part of the quality inspection process. During the quality
inspection, items are automatically blocked from consumption or issue. Also, you
can manually block items that you want to prevent from being issued or
consumed.
6-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
For manually blocked quantities, you must consider if expected receipts should
be included in planning activities as an expected on-hand quantity. Expected
receipts are blocked items that are expected to be available as on-hand inventory
after inspection. By default, the Expected receipts check box is selected for
items that are blocked through a quality order.
Items can be specified for inspection by creating a quality order in the Quality
orders form found in Inventory and warehouse management > Periodic >
Quality management. When you create a quality order, the quantity of an item
that you specify is blocked.
NOTE: The sampling plan (created in Inventory and warehouse management >
Setup > Quality control > Item sampling) that is associated with a quality order
controls the quantity of an item that should be inspected. The quantity of blocked
items, on the other hand, is not controlled by the sampling plan. Regardless of
the quantity that is sent for inspection, as specified by the sampling plan, the
quantity of the item that is entered on the quality order is the quantity that is
blocked.
NOTE: If the Full blocking check box in the Item sampling form is selected, the
full quantity of, for example, a purchase order line is blocked during inspection
regardless of the item sampling quantity.
6-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
Other Functionality
The Inventory and warehouse management module has many additional
features. The following topics review the forecasting and transfer order
functionality.
Forecasts
Forecasts are used to enter sales and purchases expected in the future. By
forecasting you can plan for the future beyond the period covered by received
sales orders and created purchase orders. For example, forecasts are necessary
when a manufacturing company’s production lead time is longer than the order-
to-delivery time that it offers customers.
You can define a forecast model in two levels. A forecast model can include one
or more submodels. This allows you to aggregate the individual forecasts. When
you run forecast scheduling for a top-level forecast model, the program calculates
gross requirements for all models that are designated as submodels.
• All forecast models must be defined before you can designate one or
more models as submodels of a forecast model.
• A forecast model that is used as a submodel cannot contain other
submodels.
• A forecast submodel uses its own parameters, not those of the top-
level forecast model.
Transfer Orders
A transfer between two warehouses can be updated by using a transfer journal as
mentioned earlier. However, when a journal is updated, the issue and receipt are
updated at the same time. If there is a time lag between the issue and the receipt
because of transport time, this can be reflected by creating a transfer order.
Transfer orders differ from transfer journals because shipping and receiving
actions must be completed. They also allow for multiple shipments and receipts
against the same order.
6-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
6-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
Scenario
Contoso has to keep a history of all inventory blocking records for auditing. In
Microsoft Dynamics AX 2012, an inventory blocking record must be deleted to
clear or release the hold on the inventory.
Simon, the Business Systems Developer, must add new fields to track the date,
time, and the user who clears the inventory blocking. Additionally, the Delete
button on the Inventory blocking form must be modified to copy the data into a
new Inventory blocking history table.
He must then create a new form and menu item to access the inventory blocking
history. The new Inventory blocking history form will be located in Inventory
and warehouse management > Inquiries > Quality management.
Challenge Yourself!
Use the provided information to create a new table to track the history of cleared
inventory blocking records. Add new fields to this table to store the user ID and
the cleared date and time. Modify the functionality of the Delete button on the
Inventory blocking form to copy the blocking record to the new inventory
blocking history table.
1. Create a new table for inventory blocking history. Make sure that
you include new fields with extended data types for the user ID,
cleared flag, and the cleared date and time.
2. Create a new form for the inventory blocking history.
3. Create a new menu item for the new inventory blocking history, and
add the menu item to the main menu under Inventory and
warehouse management > Inquiries > Quality management.
4. Create a new method in the InventBlockingTableType class to copy
the inventory blocking record to the inventory blocking history table.
5. Modify the delete method in the InventBlockingTableType class to
call the new method that you created in step 4.
6. Test the new functionality to verify that the records are copied to the
new inventory blocking history table.
6-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To create new extended data types for the new inventory blocking history table,
follow these steps.
4. Save the extended data type, and then drag it into the project that you
created earlier.
5. Right-click Extended Data Types, and then click New >
UtcDateTime.
6. In the Properties window for the new extended data type, set the
following values.
a. Name = ClearedDateTime
b. Label = Cleared date time
c. HelpText = Date and time the inventory blocking was cleared.
7. Save the extended data type, and then drag it into the project that you
created earlier.
8. Save the project.
6-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
4. Save the table, and then drag it into the project that you created
earlier.
5. Save the project.
6. Expand the Fields node of the InventBlockingHistory table.
7. Drag the InventBlockingClearedFlag and ClearedDateTime extended
data types into the Fields node.
8. Set the AllowEdit property on each of the fields to No.
9. Right-click the Fields node and then click New > String.
10. In the Properties window, set the following values.
a. Name = ClearedBy
b. Label = Cleared by
c. HelpText = User that cleared the inventory blocking.
d. AllowEdit = No
e. ExtendedDataType = UserId
11. Right-click the Fields node and then click New > String.
12. In the Properties window, set the following values.
a. Name = origCreatedBy
b. Label = Created by
c. HelpText = User that created the inventory blocking.
d. AllowEdit = No
e. ExtendedDataType = UserId
13. Right-click the Fields node and then click New > UtcDateTime.
14. In the Properties window, set the following values.
a. Name = origCreatedDateTime
b. AllowEdit = No
c. ExtendedDataType = CreatedDateTime
15. Right-click the Field Groups node and then click New Group.
6-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
8. Modify the init method of the form to only call the super and
initialize the vertical splitter. Use the following code sample to guide
you.
6-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
13. Select the Design node of the form and set the Caption property to
Invent blocking history.
14. In the form, browse to Designs > Design > ActionPane:ActionPane
> ActionPaneTab:ActionPaneTab, and then remove the
ButtonGroup:RecordBasics.
15. In the form, browse to Designs > Design > Group:Body >
Group:DetailsContainer > Tab:DetailsTab > TabPage:General,
and then set the Columns property to 3.
16. Right-click the top node of the InventBlockingHistory form and
select Restore.
17. Drag the InventBlockingClear field group from the Fields node of
the InventBlocking data source on the form into the
TabPage:General section and put it below the Group:History
group.
18. Save the form.
19. In the Project window, select the InventBlockingHistory table, and
set the FormRef property to InventBlockingHistory.
To create a new menu item and to add the menu item to the menu, follow these
steps.
6-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_06_02_LAB _CODE.txt file. You can copy and paste
these code samples into the correct methods.
1. Delete all of the methods from the Methods node of the table. (These
methods were copied from the InventBlocking table, and are not needed on the
new InventBlockingHistory table.)
/// <summary>
/// Initializes the current <c>InventBlockingHistory</c> record from an
InventBlocking record.
/// </summary>
public void initFromInventBlocking(InventBlocking _InventBlocking)
{
this.ItemId = _InventBlocking.ItemId;
this.Qty = _InventBlocking.Qty;
this.InventTransIdIssue = _InventBlocking.InventTransIdIssue;
this.InventTransIdReceipt = _InventBlocking.InventTransIdReceipt;
this.InventDimId = _InventBlocking.InventDimId;
this.ExpectedReceiptDate = _InventBlocking.ExpectedReceiptDate;
this.ExpectReceipt = _InventBlocking.ExpectReceipt;
this.Description = _InventBlocking.Description;
this.BlockingType = _InventBlocking.BlockingType;
this.origCreatedBy = _InventBlocking.createdBy;
this.origCreatedDateTime = _InventBlocking.createdDateTime;
}
6-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
3. Create a new find method on the table that is used to find inventory blocking
history table records. Use the following code sample to guide you.
/// <summary>
/// Finds the specified record in the <c>InventBlockingHistory</c> table.
/// </summary>
/// <param name="_inventBlockingHistory">
/// The ID of the record to find.
/// </param>
/// <param name="_forUpdate">
/// A Boolean value that indicates whether to read the record for update;
optional.
/// </param>
/// <returns>
/// A record in the <c>InventBlocking</c> table if it exists; otherwise, an empty
record.
/// </returns>
public static InventBlockingHistory find(
RecId _inventBlockingHistory,
boolean _forUpdate = false)
{
InventBlockingHistory inventBlockingHistory;
inventBlockingHistory.selectForUpdate(_forUpdate);
return inventBlockingHistory;
}
4. Create a new method on the table that overrides the initValue method. This
method should set the values for the new fields that were added to the table. Use
the following code sample to guide you.
/// <summary>
/// Initializes default inventory blocking history values.
/// </summary>
public void initValue()
{
this.InventBlockingClearedFlag = NoYes::Yes;
this.ClearedBy = curUserId();
this.ClearedDateTime = DateTimeUtil::utcNow();
}
6. Drag the class into the project that you created earlier.
6-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
/// <summary>
/// Lab 6.2 Write History Table
/// </summary>
private void writeInventBlockingHistory()
{
inventBlockingHistory inventBlockingHistory;
inventBlockingHistory.initFromInventBlocking(inventBlocking);
inventBlockingHistory.initValue();
inventBlockingHistory.insert();
}
/// <summary>
/// Deletes the inventory blocking record and corresponding inventory
transactions.
/// </summary>
public void delete()
{
// Delete issue transaction
this.deleteBlockingTransaction();
inventBlocking.doDelete();
}
6-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
TIP: You can repeat the test as many times as you would like by using different
item numbers and dimensions. The only requirement is that the item and
dimension combination that you select must be on hand.
6-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Summary
The Inventory and warehouse management module in Microsoft Dynamics
AX 2012 integrates with many other modules and is the central module for
processing inventory transactions.
The module includes functionality for recording and updating the inventory
transactions and keeping track of the on hand quantities for every item and item-
dimension combination.
Finally, quarantine and quality management features can be used to record test
results and prevent items from being processed because of quality issues.
6-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
1. Describe the difference between the inventTrans table and the inventSum
table.
2. Match the inventory statuses with the correct inventory status field.
1. Status Issue
2. Status Receipt
6-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
4. Which of the following stores the original cost value for an inventory
transaction in the InventTrans table?
( ) InventTrans.CostValue() method
( ) InventTrans.CostAmountAdjusted field
( ) InventTrans.CostAmountPhysical field
( ) InventTrans.CostAmountFinancial field
6-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
1.
2.
3.
6-45
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Solutions
Test Your Knowledge
1. Describe the difference between the inventTrans table and the inventSum
table.
MODEL ANSWER:
The inventTrans table stores the details of every inventory issue and receipt,
whereas the inventSum table stores the summation of all inventTrans records
grouped by the inventory dimension combinations which are identified by
the inventDimID.
2. Match the inventory statuses with the correct inventory status field.
1. Status Issue
2. Status Receipt
2 Item 1: Ordered
1 Item 2: OnOrder
1 Item 3: ReservOrdered
2 Item 4: Received
2 Item 5: Purchased
1 Item 6: Deducted
1 Item 7: Picked
1 Item 8: Sold
4. Which of the following stores the original cost value for an inventory
transaction in the InventTrans table?
( ) InventTrans.CostValue() method
( ) InventTrans.CostAmountAdjusted field
( ) InventTrans.CostAmountPhysical field
(•) InventTrans.CostAmountFinancial field
6-46
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 6: Use and Design of the Inventory and Warehouse Management
Module
6-47
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
6-48
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Introduction
The Accounts receivable and Accounts payable modules offer similar
functionality for customers and vendors. The modules are used to maintain the
customer and vendor information and the transactions that occur for each. This
chapter reviews the functionality that is available for customers and vendors and
the primary transactions that occur for each module.
7-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Customers
Accounts receivable is used to track customer invoices and incoming payments.
You can create customer invoices for a sale that is based on sales orders or
packing slips. You can also enter free text invoices that are not related to sales
orders. Additionally you can generate customer invoices from a project. You can
receive payments by using several different payment types. These include bills of
exchange, cash, checks, credit cards, and electronic payments. If your
organization includes multiple legal entities, you can use centralized payments to
record payments in a single legal entity on behalf of the other legal entities.
You can use the Settle open transactions form to settle invoices with payments
or credit notes. You can also enter payments and settle them in the Enter
customer payments form. To view customer information, use the All customers
list page and related forms. You can manage overdue balances, calculate interest,
and generate collection letters by using the Collections list page and related
forms.
• Maintain customers
• Free text invoice
• Request payment
• Register payment
• Bill of exchange
• Account statement
• Collection letter
• Interest calculation
• Exchange adjustment
• Reconciliation
7-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Maintain Customers
Creating new customers and maintaining existing customer information is an
ongoing task. Make sure that customer setup is correct to guarantee smooth
communication and to avoid calculation errors.
Some customers are transferred from the Prospects form in the Sales and
marketing module. However, other customers must be created manually in the
Accounts receivable module. The customer forms and list pages are available
from the Accounts receivable and the Sales and marketing modules.
Customer sales prices and discounts for items sold should be maintained. Prices
can be set up specifically for individual items and customers, for a group of
customers or for all customers as one group. The price structure also includes
line, multiline, and total discounts.
The actual value of invoices due in a foreign currency can change over time as
the result of exchange rate fluctuations. Because an invoice’s value is calculated
in the accounting currency when the transaction is posted, you could have to
make periodic exchange rate adjustments to revalue foreign currency receivables.
7-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
7-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Trade agreements (terms and conditions) made with the customer are registered
and maintained in cooperation with the Inventory and warehouse management
module. The customer’s expected sales can be forecast and used in master
planning.
The General ledger module keeps track of all company financial transactions.
All customer financial movements are replicated in the General ledger module.
Payment transactions are recorded in the Cash and bank management module
that controls the company’s bank accounts.
7-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Both open and settled parts of a customer transaction can have related cash
discount information. This information is stored in a separate table,
CustTransCashDisc, because each transaction part can have multiple cash
discount specifications.
Vendors
Accounts payable is used to track vendor invoices and outgoing expenditures.
You can enter vendor invoices manually or receive them electronically through a
service, or your vendor can enter the invoices by using a vendor portal. After the
invoices are entered or received, you can review and approve the invoices by
using an invoice approval journal or the Vendor invoice form. You can use
invoice matching, vendor invoice policies, and workflow to automate the review
process so that invoices that meet certain criteria are automatically approved, and
the remaining invoices are flagged for review by an authorized user.
After vendor invoices are approved, you can pay vendors. If your organization
includes multiple legal entities, you can use centralized payments to pay all
invoices from a single legal entity. Multiple payment formats are supported.
These include checks, promissory notes, and Single Euro Payments Area (SEPA)
electronic payments. You can settle invoices with payments or credit notes by
using the Settle open transactions form. To view vendor information, use the
All vendors list page and related forms.
• Maintain vendors
• Register invoice
• Invoice approval
• Payment proposal
• Register payment
• Promissory notes
7-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
• Exchange adjustment
• Reconciliation
Maintain Vendors
Creating new vendors and maintaining existing vendor information is an ongoing
task. Make sure that vendor setup is correct to guarantee smooth communication
and to avoid calculation errors.
Purchase prices and discounts for items purchased should be maintained. Prices
can be set up specifically for individual items and vendors, for a group of
vendors, or for all vendors as one group. The price structure also includes line,
multiline, and total discounts.
7-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Trade agreements (terms and conditions) made with vendors are registered and
maintained with the Inventory and warehouse management module. Expected
purchases can be forecast and used in master planning.
The General ledger module keeps track of all company financial transactions.
All vendor financial movements are replicated in the General ledger module.
Payment transactions are recorded in the Cash and bank management module
that controls the company’s bank accounts.
The data model for vendors and vendor transactions resembles the customer data
model. Therefore, the data model for vendors is not reviewed. The primary
difference between the data models is that the vendor data model tables begin
with Vend... and the customer data model tables begin with Cust.
7-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
This lack of integration makes the use of free text invoices simpler and creates
fewer database records. Therefore, free text invoices are a good option when
integration to other functions is required.
Implementing free text invoices as the primary invoice engine will typically
require some additional programming, because the standard application only
handles basic scenarios.
7-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Printing setup and copies can be specified individually for each customer. This
setup can be overridden in a specific Free Text Invoice. The setup is included in
the tables PrintMgmtDocInstance, PrintMgmtSettings and
PrintMgmtIdentificationText.
7-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Each free text invoice template record is stored in the CustInvoiceTemplate table.
The lines of the templates are stored in the CustInvoiceLineTemplate table. Each
free text invoice template must be linked to one or more customers. The
CustRecurrenceInvoice table contains the information about the templates that
are assigned to a customer. One template can be assigned to multiple customers,
and each customer can have multiple templates assigned.
Periodically, you must run the Generate recurring invoices job to create the
recurring free text invoices for each customer. When the job runs the
CustInvoiceTemplate table records are copied into the CustInvoiceTable as a
standard free text invoice. The lines are copied from the
CustInvoiceLineTemplate table to the CustInvoiceLine table.
Every time that the Generate recurring invoices job is run, a new record is
inserted into the RecurrenceInvoice table. This record serves as a batch or
"journal" header type record for the free text invoices that are created. The
CustRecurrenceInvoiceGroup table contains information about each of the free
text invoices that are created from the batch.
When the recurring free text invoices are posted, the transactions are copied to
the CustInvoiceJour and CustInvoiceTrans tables in the same manner that a
regular free text invoice is processed.
7-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
CustPostInvoice Classes
CustPostInvoice
The CustPostInvoice class handles the posting of a single free text invoice
specified by one record in the CustInvoiceTable and one or more records in the
CustInvoiceLine.
CustPostInvoiceJob
Vendor Invoices
Invoices can originate from purchase orders. However, if an invoice is created in
another system, or for products and services that are not recorded in a purchase
order, then it can be recorded manually in Microsoft Dynamics AX, by using the
General journal or an Invoice journal in the Accounts payable module. When
you manually enter a vendor transaction and specify a vendor account and an
invoice number, the transaction will be recorded as an invoice.
The company receives invoices from its vendors. To make sure that received
invoices are correct and valid, incoming invoices are typically sent through an
approval workflow.
Invoicing Methods
Purchase Order Invoicing
7-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Invoice Journal
• Registered
• Approved
• Paid
• Invoice Register
• Invoice Approval Journal
• Invoice Pool excluding Posting
• Invoice Journal
The purpose of the invoice register journal is to pre-register invoices when they
arrive at the company and transfer them to an invoice pool for approval. In the
invoice register journal, an employee registers the following information.
• Vendor account
• Invoice number
• Amount
• Person who approves the invoice
The same employee validates and posts the journal to the accounts specified in
the posting profile. Usually the accounts are pending accounts where the amounts
require the manual approval and reclassification by the person specified in the
journal line.
7-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
After you post the lines of the invoice register, the postings display in the invoice
pool. To view the postings in the invoice pool click Accounts Payable, click
Inquiries, and then click Invoice pool.
• The invoice pool displays the relevant information about the invoices
awaiting approval.
• The invoice pool holds invoices originating from a purchase order
that originate from an invoice register. Click the Purchase order
button to select and approve the purchase orders.
Invoice Journal
A third option for processing incoming invoices is to enter them directly into the
invoice journal.
• By default, the user who is logged on and enters the journal lines
approves the invoices.
• The invoice journal is designed for users to enter the invoices they
receive from vendors without entering them into the approval
journal. As soon as the user enters the incoming invoices, the user
can post.
7-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Payments
The collection of customer payments and generation of vendor payments is one
of the most important tasks in the finance process. They control the flow of cash
into and out of your business.
If you do not receive payments from your customers, you might not have cash to
make payments to vendors and keep your business running. Similarly, if you do
not make payments to your vendors for the items that you purchase, your vendors
could stop sending you items that keep your business running.
Before any payments can be made or received, several system setups must be
completed. Most of the payment setup is shared between the Accounts
receivable and Accounts payable modules, and there are many similarities in
the processing of payments for each module.
Payment Set Up
Microsoft Dynamics AX offers extensive functionality for setting up different
vendor payment options. These global payment options are used in the Accounts
payable and Accounts receivable modules, and include the following.
• Payment days: Use payment days to define the payment day used
for calculating the due date. The due date always is rounded up to the
nearest specified date. Payment days can be specified for one of the
following.
o Day in the week
o Day in the month
7-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
7-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
VendPaymFormat contains payment formats that are selected by using the Setup
button on the File formats tab page (in the form used for setting up payment
methods).
7-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Similar tables that begin or end with Cust are used for customer payment set up.
The following tables are shared between Accounts receivable and Accounts
payable.
Customer Payments
Request Payments
Payment Journals
Payment registration is one of the Customer module’s main tasks. The payment
journal, a variant of the general journal used in the General ledger module, is
used to register customer payments. You can do this manually by entering
information into the payment journal.
7-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Key tasks related to payment registration are to match invoices with their specific
payment, and to recognize outstanding invoices to be able to calculate interest
charges and submit collection letters. By doing this, the electronic payments
received from the bank, should settle and pay the appropriate invoices. Some
payments have related fees that customers should pay to the bank. Registration of
these fees is an integrated part of payment registration.
Vendor Payments
Payment Proposal
Open vendor invoices are reviewed periodically to select specific invoices to pay.
You do this by entering the payments in a journal with the specifications for
those invoices that will be settled. The Accounts payable module includes a
function for automatic proposals of those invoices that have to be paid.
When the payment proposal is reviewed and approved, payments are then
typically generated. The payment generation process is different, depending on
the method of payment. For check payments, a physical check must be printed
and mailed, whereas other types of payments require the generation of a file that
is transferred electronically to a bank.
Payment Journals
7-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
LedgerJournalName contains different journal names, based on how they are set
up in the General Ledger module. Each journal name is related to one specific
type of journal. One of the journal types is customer payments.
The fees are stored in the CustVendPaymJournalFee table. Each payment fee can
generate a new record in LedgerJournalTrans that will contain the fee. To post
payment fees, this design uses the usual ledger journal posting. Fee transactions
cannot be viewed or edited in LedgerJournalTrans, because this is replicated
from the information in CustVendPaymJournalFee.
7-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
When a payment is entered in the journal, the desired transaction settlement can
be specified when it is posted. The settlement is stored in the SpecTrans table,
and will be reflected in the CustSettlement table when the journal is posted. Each
record in SpecTrans defines a settlement between a line in the payment journal
and an open transaction part in CustTransOpen. SpecTrans can contain
information other than settlements from the customer payment journal. The same
table is used for other settlement specifications in the Customer and Vendor
modules.
CustInPaym Class
The CustInPaym class forms a framework for the import of payments from
customers. The file is typically received from the company bank. The function
involves reading the file and creating a new journal that contains the payments.
The information in the received file will usually contain a reference to the
invoice covered by the payment, and the import should make a settlement against
the open invoices while generating the payment journal.
When a payment method is set up, it can be related to an import file format. This
function will display all classes extending from CustInPaym.
The files generated can contain different types of records to handle several ways
of processing the payment. The individual types of records in the file are
implemented by creating a class extending from
CustOutPaymRecord/VendOutPaymRecord. If multiple record types will be
implemented, they should be implemented as extensions from one root class
extending from CustOutPaymRecord/VendOutPaymRecord.
7-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• VendOutPaym_Format1
• VendOutPaymRecordFormat1
• VendOutPaymRecordFormat1Spec1
• VendOutPaymRecordFormat1Spec2
You can make a duplication of these classes, when you implement a new specific
format.
The details of a payment can be retrieved from many tables in the Vendor
module. The VendPaym class contains a payment’s consolidated information. All
information is available by calling corresponding methods. The methods can be
grouped into three categories.
CustVendCreatePaymJournal Class
The CustVendCreatePaymJournal class is used to generate journals with
payments or journals handling bills of exchange and promissory notes.
The class searches for open invoices that will be paid by using a cash discount
and due date criteria. The data fetched is controlled by a query on the
CustTransOpen/VendTransOpen table and the payments generated are saved in a
ledger journal (LedgerJournalTrans).
CustVendSettle Class
The CustVendSettle class handles the update of a settlement between an invoice
and a payment. The processing is complex because the settlement can include
some of the following tasks.
7-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
If the journal transaction is created by X++ the open transaction editing can be
controlled by creating records in SpecTrans as illustrated earlier. Suppose that the
amount in the journal transaction must be settled against a specified tableId
(Cust-/VendTransOpen) and recId. The following method will create the
information in SpecTrans.
SpecTransManager specTransManager;
;
specTransManager =
SpecTransManager::construct(ledgerJournalTrans);
specTransManager.insert(_ledgerJournalTrans.DataAreaId,
_tableId,
_recId,
_ledgerJournalTrans.amount(),
_ledgerJournalTrans.CurrencyCode);
SpecTransManager specTransManager
CustTable custTable;
CustTransOpen custTransOpen;
specTransManager = SpecTransManager::construct(custTable);
specTransManager.deleteAll();
custTransOpen = …;
specTransManager.insert(custTransOpen.DataAreaId,
custTransOpen.tableId,
7-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
custTransOpen.recId,
custTransOpen.AmountCUR,
custTransOpen.custTrans().currencyCode);
custTransOpen = …;
specTransManager.insert(custTransOpen.DataAreaId,
custTransOpen.tableId,
custTransOpen.recId,
custTransOpen.AmountCUR,
custTransOpen.custTrans().currencyCode);
CustTrans::settleTransact(custTable);
This resembles the manual transaction editing that can be controlled by the end-
user.
7-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
This lab is designed for self-study. Completing this lab takes approximately 45
minutes.
Scenario
The solution should contain a function for exporting payments to a file. The file
should contain one record for each payment, and the records should have a fixed
length.
The file can consist of two kinds of records. One record is used for bank transfers
and another record layout is used for checks.
The length of each record is 198 bytes. Each record is separated by Carriage
Return Line Feed (CR LF). The total size of the file is 200 bytes for each
transaction.
7-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Technical Issues
VendOutPaym
All classes extending from VendOutPaym will be available when you set up
export formats related to payment methods.
• interfaceName
• open
• close
• custVendOutPaymRecordRootClassId
• dialog
• pack
• unpack
• validate
• ::description (Scope resolution operator determines the method is
static)
7-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
The open method should initialize data member files that are defined in the super
class. Use the following code sample to guide you.
Codepage
The close method is called when all payments are exported to the file. If the last
record should be followed by a record delimiter, then an additional empty call to
file.write() can be included in this method. The method can also send information
to the created file’s infolog.
classId custVendOutPaymRecordRootClassId()
{
return classNum(VendOutPaymRecord_AXA);
}
7-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The dialog method is overridden to specify those fields to include in the dialog
box. If the only field is the name of the file, then the method should be such as
this.
this.dialogAddFileName(dialog);
this.dialogAddPrintDocument(PaymDocumentType::ControlReport
,
dialog,
true);
return dialog;
}
Notice that the method also adds functionality to print a control report.
The pack and unpack methods should be implemented by using the usual
contents. The CurrentVersion and CurrentList macros are defined in the super
class.
The method, ::description is a static method that returns the same information as
the object method interfaceName. The following is a sample of this method.
VendOutPaymRecord
You can use “abstract” classes in the hierarchy with the purpose of sharing code
between some record formats. The rule is that you should only implement the
interfaceName method on classes that implement an actual record type.
7-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
• interfaceName
• checkValues
• output
The output method writes the record type to the file. You can do this by calling
file.write() or file.writeExp().
Both methods checkValues and output methods are called automatically for each
record to export. All information about the payment will be available through the
data member custVendPaym, based on the VendPaym class described in the
following text.
Implementation
Perform the following steps to export the vendor payments to a file of a fixed
length as it is specified in the “Scenario” section of this lab.
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_07_01_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
7-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
g. pack
h. unpack
i. validate
j. description
Test
To test the implementation, complete the following steps.
2. Click the Setup button on the File formats FastTab. Locate the new
AXA export format in the list of available formats and move it to the
left (Selected). Close the form. Select the file format in the Export
format field on the File formats tab page and save the record.
3. Click the Payment specification button and create two records
related to the two record formats (Bank transfer and Check)
implemented. Remember to specify the Export format for each
record type. Close the forms.
7-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
4. Create a new payment journal by using the path Accounts payable >
Journals > Payments > Payment journal. Open the journal lines
by clicking Lines.
5. Create a payment for vendor, “8500” with a debit amount of 766.50
using the United States dollar (USD). Specify the payment method
and record format in the Method of payments and Payment
specification fields.
6. Manually create another payment for vendor “8500” with a debit
amount of 474.86 USD. Specify the payment method and record the
format in the Method of payments and Payment specification
fields. Select the other record format compared to the line earlier.
7. Click the Functions > Generate payment button and select the
implemented Export format in the dialog box. Click the Dialog
button and specify the name of the file to be generated. Specify the
bank account “USA OPER”.
NOTE: You will receive an error about credit amounts when you generate the
file. This error is expected, because you added validation to check for credit
amounts. To correct the error you can change the credit amount in the journal
line to a debit amount and then generate payments again.
TIP: If you want to repeat the test, set the status of the lines back to None by
selecting Payment status and clicking the None button.
If account statements are to specify those invoices that are outstanding, then
transaction open-editing must be up to date. Account statement printouts are
followed by a reconciliation to make sure that they are correct.
7-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The CustInterest table defines the different interest codes that have the related
specification of the interest calculation that includes the percentages and accounts
that are used for posting.
The interest code used for each customer is determined by the posting profile that
can be accessed by the path Accounts receivable > Setup > Posting profiles >
Setup.
The CustInterestFee table is used to specify a fee that will be included in the
interest calculation. The reason for this separate table is the need to specify a
specific fee for each currency. The table is also used to specify a minimum
interest that should be calculated. The CustInterestRange table contains
information about the interest that is applicable by the ranges of an overdue
balance or the time on the customer transactions and is specific to a customer
currency.
Each calculated interest note has a header in the CustInterestJour table. The
calculation is specified in CustInterestTrans that contains a record for each
original transaction that has contributed to the interest calculation.
7-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
The printing and posting of the interest note updates information in the
CustInterestJour. When the interest is posted one or more new interest
transactions are created in the CustTrans table.
• checkOpenTrans
• checkSettlement
The CustInterestPost class handles the posting of an interest note. This includes
the creation of ledger and customer transactions.
Bills of Exchange
A bill of exchange, also known as a draft, is an instrument used to administer
agreements to make payments. The document is created by the selling company.
However, it resembles a check written from the buyer to the seller.
• Draw
• Protest
• Redraw
• Remittance
• Settlement
Separate journals for each step handle registration. These different kinds of
journals are collected in the submenu Journals > Bills of exchange.
7-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Draw
This step creates the document. Invoice transactions are selected when you enter
information into the journal.
When the journal is posted, the customer transaction that originated the invoice,
is settled and replaced by a new, open transaction represented by the bill of
exchange.
Protest
A bill of exchange is created by the selling company. A buyer can protest the bill
of exchange if he or she does not accept it.
For a protest, the transaction representing the drawn bill of exchange is selected
when you enter the information into the journal. When the journal is posted, the
bill of exchange’s status is changed from Drawn to Protested.
The customer transaction that originated the drawn bill of exchange is settled and
replaced by a new, open transaction represented by the protested bill of
exchange.
Redraw
The customer transaction that originated the protested bill of exchange is settled
and replaced by a new, open transaction representing the redrawn bill of
exchange.
Remittance
One of the purposes of bills of exchange is for sellers to use them to obtain bank
credit.
The customer transaction that originated the drawn or redrawn bill of exchange is
settled and replaced by a new, open transaction representing the remitted bill of
exchange.
7-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Settlement
Final settlement of a bill of exchange ends the payment workflow. This step
represents the customer’s final payment of the invoice that is the basis for the bill
of exchange.
The transaction representing the remitted bill of exchange is selected when you
enter the information into the journal. When the journal is posted, the status of
the bill of exchange is changed from Remitted to Honored.
The customer transaction that originated the remitted bill of exchange is settled
and replaced by a new, open transaction representing the honored bill of
exchange.
Promissory Notes
A promissory note is an instrument used to administer agreements to make
payments. The document is created by the buying company and states that the
buyer has agreed to make a payment in the future.
1. Draw
2. Redraw
3. Remittance
4. Settlement
Each of the steps are handled and registered by using a journal dedicated to each
step. The different kinds of journals are collected in the submenu Journals >
Promissory notes.
Draw
This step creates the document. Invoice transactions are selected when you enter
information into the journal.
When the journal is posted, the customer transaction that originated the invoice is
settled and replaced by a new, open transaction represented by the promissory
note.
Redraw
The transaction representing the honored promissory note is selected when you
enter the information into the journal. When the journal is posted, the promissory
note status is changed from Honored to Redrawn.
7-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The vendor transaction that originated the honored promissory note is settled and
replaced by a new, open transaction representing the redrawn promissory note.
Remittance
The vendor transaction that originated the drawn or redrawn promissory note is
settled and replaced by a new, open transaction representing the remitted
promissory note.
Settlement
Final settlement of the promissory note ends the payment workflow. This step
represents the vendor’s final payment of the invoice that is the basis for the
promissory note.
The transaction representing the remitted promissory note is selected when you
enter the information into the journal. When the journal is posted, the promissory
note status is changed from Remitted to Honored.
The vendor transaction that originated the remitted promissory note is settled and
replaced by a new, open transaction representing the honored promissory note.
7-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Scenario
The business relations, used as vendors, and the customers, are recorded in the
accounts payable table. If the company is buying from and selling to the same
business relation, this will be created in both tables.
An invoice is usually settled by a payment, but when buying from and selling to
the same business relation, the invoices from the purchase and sales order could
be set off one another.
A new function should find customers and vendors related to one another (the
same business relation). If both the customer and vendor have open invoices,
they should be set off one another. Only invoices in the same currency can be
settled against one another.
Implementation
To find and settle customer and vendor open invoices of the same currency,
follow these steps.
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_07_02_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
7-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Test
To test the implementation, follow these steps.
NOTE: You may receive warnings that the number sequence you created does
not allow reservations. This message can be ignored.
TIP: If you want to repeat the test, you should delete the journal generated.
7-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Summary
The Accounts receivable module is used to track customer invoices and
incoming payments. The Accounts payable module is used to track vendor
invoices and outgoing expenditures.
The Accounts receivable module has functionality for free text invoices. Free
text invoices are useful because they are not related to inventory items and
provide a simple invoice mechanism.
The Accounts payable module uses invoice journals to process invoices that are
not related to inventory. The following types of invoice journals are available.
• Invoice Register
• Invoice Approval Journal
• Invoice Pool excluding Posting
• Invoice Journal
7-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
2. What is the primary difference between free text invoices and sales order
invoices?
7-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
5. Which of the following frameworks and classes are used by the free text
invoice generation process? (Select all that apply)
( ) CustVoucher
( ) LedgerVoucher
( ) CustInvoiceCalcTax
( ) FormLetter framework
7-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
7-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 7: Use and Design of the Accounts Receivable and Accounts
Payable Modules
Solutions
Test Your Knowledge
1. Categorize the following items.
2. What is the primary difference between free text invoices and sales order
invoices?
MODEL ANSWER:
Free text invoices cannot be related to inventory items, and sales order
invoices can be related to inventory items.
5. Which of the following frameworks and classes are used by the free text
invoice generation process? (Select all that apply)
(√) CustVoucher
(√) LedgerVoucher
(√) CustInvoiceCalcTax
(√) FormLetter framework
7-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
7-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
• Review the general features that are supported with sales and
purchase orders.
• Describe how sales and purchase orders integrate with other
modules,
• Discuss the primary tables used in the purchase order flow.
• Describe how the PurchType, PurchLineType, and PurchTotals
classes work.
• Describe how trade agreements are used and set up.
• Review the data model for trade agreements.
• Discuss how the trade agreement classes are used and can be
extended.
• Describe how sales and purchase agreements are used and set up.
• Review the data model for sales and purchase agreements.
• Discuss how the sales and purchase agreement classes are used and
can be extended.
• Describe how pricing policies are used.
• Describe how charges are used and set up.
• Review the data model for charges.
• Describe how the FormLetter framework is used.
• List the various documents that are processed through the
FormLetter framework.
• Describe the data model for updating documents.
• Describe how the FormLetter classes relate to each other and
generally work.
• Describe how to make modifications to the FormLetter framework.
• Describe the differences between the sales order and the sales
quotation features, data model, and classes.
• Describe the differences between the purchase order and the request
for quotation features, data model, and classes.
• Describe the differences between the purchase order and the
purchase requisitions features, data model, and classes.
• Explain how to use and set up categories and category hierarchies.
• Review the data model for categories and category hierarchies.
8-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Introduction
The sales and purchasing processes are important components of every business.
Microsoft Dynamics® AX 2012 provides functionality businesses can use to
manage purchase and sales information with the integration to inventory and the
general ledger.
The order to cash process is also referred to as the sales process, and involves
many steps. These steps include gathering leads and opportunities that drive the
creation of prospective customers, followed by the quotation process, and after
the quotation is accepted, generating confirmed sales orders. Next is the picking
and shipping of the products and then invoicing or billing the customer. After the
customer receives the goods payment must be collected.
Because every business has different processes the source to sell process steps
can be conducted differently, Microsoft Dynamics AX 2012 helps businesses
manage these processes that are usually controlled by the type of customer that
includes, business-to-business (B2B), business-to-customer (B2C) or by specific
business requirements.
The procure to pay process is also referred to as the purchase process, and it also
includes many steps, and is similar to the source to sell process. These steps
include requesting and qualifying a new vendor, submitting purchase requisitions
by employees requiring various products, followed by the request for quotation
process with the vendor. When the purchase requisitions and, or the request for
quotations are approved, purchase orders are generated and then confirmed with
the vendor. After the products are delivered, a product receipt is generated and
the invoice is recorded for the purchase order, and then payments must be
generated to the vendor.
This course introduces the features in Microsoft Dynamics AX 2012 that support
the sales and purchase processes, and it also reviews the data models and coding
patterns for many of the features. Since the customer and vendor data models and
coding patterns are similar, the details of both will not be discussed.
8-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The primary components of a sales order consist of a header and one or more
lines. Each sales order header is linked to one specific customer account. Each
line of a sales order is linked to one specific item number or one specific sales
category. When a sales order line is linked to an item number, the category field
is defaulted based on the category assigned to the item. You can leave the item
number field blank, and select only a category.
Several types of sales orders exist and each has different functionality.
After a sales order is created and the customer, item or category, quantity, and
pricing information are entered, the order must be processed. The four steps to
process a sales order include the following.
8-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
As a sales order is processed, the status of the order is updated and the related
inventory transactions are simultaneously updated. Sales orders also support
other features such as the following.
8-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The primary components of a purchase order consist of a header and one or more
lines. Each purchase order header is linked to one specific vendor account. Each
line of a purchase order is linked to one specific item number or one specific
procurement category. When a purchase order line is linked to an item number,
the category field is defaulted based on the category assigned to the item. You
can leave the item number field blank, and select only a category.
Unlike sales orders, a purchase order only has three order types
available―Journal, Purchase order, and Returned order. Additionally, when a
purchase order is processed, the steps include a confirmation that is similar to the
sales order confirmation, a receipts list, a product receipt, and an invoice.
A receipts list is a record of received items. The task is performed for physical
accepting of the goods. Products updated on a receipts list are still not physically
available.
8-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
8-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The PurchTable table holds a record for each purchase order, whereas the related
lines are stored in the PurchLine table. A purchase order is always related to a
vendor to whom the goods in the purchase order will be received from. A
different vendor account might be specified to receive the invoice.
8-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When there is a delivery schedule on a purchase order line, the PurchLine table
stores one record for each delivery date, and there is "master" record for the
original purchase order line. The LineDeliveryType field is used to determine
whether the line has a single delivery or multiple deliveries. When the value is
OrderLine there is only one delivery. When the value is
OrderLineWithMultipleDeliveries, the line is original order line that has a
delivery schedule attached. When the value is DeliveryLine, the line is one of the
scheduled deliveries.
Inventory dimensions for the purchase order lines, such as size, color, and
configuration, are saved in a separate table, labeled InventDim. The
InventDimId field creates the relationship between a purchLine and the record
holding dimension values. This design is used because it reduces the number of
indexes in tables holding inventory dimensions. The InventDim table has many
indexes related to individual inventory dimensions. All indexes in the InventDim
table can be used with the PurchLine table through a join between the two tables.
This join only requires one index (InventDimIdx) on the PurchLine. The
purchase order lines are always related to a record in the InventDim table, even if
all inventory dimensions have blank values.
Inventory transactions are used to store the status and history of the inventory
receipts and issues. Each purchase order line has one related record in the
InventTransOrigin table. Each InventTransOrigin record is related to one or more
InventTrans table records. By default the relationship between the
InventTransOrigin and the InventTrans is a one-to-one relationship. However,
when a delivery schedule exists on a purchase order line, multiple InventTrans
records are created. There are other scenarios, such as partial receipts and
invoices that can cause multiple inventory transaction records to be created.
Additionally, there are scenarios where inventory transactions do not exist, such
as purchase orders with the type of journal or purchase lines with products that
are not stocked, or purchase order lines that are category based.
8-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
8-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To create a new order type, start by adding a new element to the purchase order
type base enumeration, and then create a new class that extends the
PurchTableType and PurchLineType classes. Add methods to the new class that
override the base methods in the PurchTableType and PurchTableLine classes.
Then you must modify the construct() method on the classes to call the
appropriate "type" class for each purchase order header and line.
The totals of a purchase order are calculated by using the PurchTotals class. This
class extends TradeTotals which Extends TradeTotalsBased which are also used
for calculating sales totals.
The totals are calculated in relation to the inquiry from the purchase order, check
of the credit limit, update to an invoice, and so on. The scope of the calculation
can range from one single purchase order line to a summary of multiple purchase
orders.
The classes have many object methods returning several amounts such as order
balance, volume, weight, taxes, charges, and so on.
8-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Agreements
The Agreement framework offers users of Microsoft Dynamics AX a broad set of
tools for applying and following up on commercial agreements between the
company and its customers and vendors regarding of buying/selling a certain
quantity or/and volume of an particular item as well as a range of items within a
certain category with a special policies applied to achieve an agreed price for
trading goods and/or services.
The prices and discounts of the sales or purchase agreement overrule any prices
and discounts stated in any trade agreements that could exist.
You can specify the agreement commitment type on the purchase and sales
agreements. This controls what information is required on the agreements. The
commitment type also determines how the agreement is being managed to
determine when the commitment is fulfilled.
Trade Agreements
Prices of sold and purchase items should be maintained. Prices can be set up
specifically for individual items, customers, and vendors, or prices can be set up
for a group of customers or vendors, or for all customers as one group.
The price structure also includes line, multiline, and final discounts.
Administration of sales prices and purchase prices that includes publishing to the
organization and customers, is an ongoing task.
8-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• Price
• PriceUnit
• Markup
8-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The following figure shows the design of the purchase price and discount data
model.
When more complex pricing is required, you can use Trade agreements to define
detailed pricing information for specific vendors, currencies, quantities, or date
ranges. Trade agreements allow you to set up purchase prices, line discounts,
multiline discounts, and total discounts. This is controlled by the Relation field
on the PriceDiscTable. Each specification in the price agreement table contains
item and vendor dimensions.
This creates up to nine different levels of specification. The search for a price or
discount must use a priority between the several combinations.
Price groups are used to create the groups of customer, vendors, or items that you
want to handle in the same way for prices. A separate price group can be created
for each type of pricing (prices, line discounts, multiline discounts, and total
discounts) and for each group of transactions (customers, vendors, and items).
Many different relations exist between the PriceGroup table and the
PriceDiscTable.
8-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You cannot change the information in PriceDiscTable directly. Instead, you must
create a price and discount journal and make the modifications in the journal.
When the journal is posted, the records are updated or created in PricDiscTable.
The following figure shows the design for the price and discount journal
function:
The PriceDiscAdmName table contains the journal names that are defined in the
setup. PriceDiscAdmTable contains the header for each journal, whereas
PriceDiscAdmTrans contains the individual price agreements. If the journal line
is loaded from the existing agreements, then it will be related to the existing
record in PriceDiscTable (RecId).
8-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The prices and discounts of the sales or purchase agreement overrule any prices
and discounts stated in any trade agreements that might exist.
You can specify the agreement commitment type on the purchase and sales
agreements. This controls what information is required on the agreements. The
commitment type also determines how the agreement is being managed to
determine when the commitment is fulfilled.
8-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The agreement framework physical data model design uses the table inheritance
feature and implement all data sub-types needed by the framework and their
behavior deviations as a table inheritance ladder, encapsulating both data- and
functional- specializations within a single type of objects – AX Data Tables.
With that done the need for supporting class hierarchy behind the used data
tables was completely eliminated.
The following figure show the data model for purchase agreements.
8-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Agreement Classifications
Agreement classifications are a required field on agreements. Classifications help
group agreements into different types. Functionality does not change with
different types. These values can be used for reporting and analysis.
The following figure shows the data model for agreement classifications.
8-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Agreement History
The agreement framework in Microsoft Dynamics AX2012 enables users to
create a snapshot of the current agreement state at any given time. These
snapshots called “Agreement History” are stored by the system as separate
records in a database so persisted state for particular agreement can be
reconstructed by the system and accessed by user for later analysis.
To enable this functionality the agreement framework defines a number of
history entities shown in the following figure.
Explicit relations between history- and base- entities are established for only a
few entities (exactly only for AgreementHeader and AgreementHeaderHistory as
well as for AgreementLine and AgreementLineHistory). Besides them, all other
similar relations would be redundant for the data model and therefore were not
implemented.
8-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Also it is important to note that History entities for agreement headers and lines
do not directly implement “Header-Lines” pattern. You can see in the previous
figure that there is no relation between AgreementHeaderHistory and
AgreementLineHistory entities.
You can use additional functionality that is created automatically during certain
types of updates based on parameter settings to link between purchase orders and
purchase agreements. For example, you can select an option for the system to
search for purchase agreements when you create a purchase order from a sales
order, or when you create purchase orders through Master planning.
Charges
A charge is an additional fee or cost that can be added to a purchase or sale order.
Charges can be linked to the header or the lines of the orders. They can be added
manually to an order, or a rule can be configured to have charges automatically
added to an order.
8-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The following figure shows the data model for the relation of charges with a sales
order.
Each charge that is added to an order is defined by the charge code. The charge
code defines how the charge will be assessed. For example, a sales charge can be
assessed as a fee that will post to the customer's account this type of charge
increases the invoice amount of the order. Another option on the set up of the
charge code is used for the charge to be assessed to the item. This type is most
often used as a landed cost that increases the inventory cost but does not increase
the invoice amount to be paid by the customer. Similar options exist for purchase
orders.
Additionally, options exist on the charge code set up to determine which main
account the cost or fees should post to when invoice updating the order. For
purchase orders there are additional options to select a method for allocating a
charge that is applied to the header to the lines of that order.
8-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The following figure shows charges and their relation to Purchase order
invoicing.
8-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The AccountCode and ItemCode fields are enumerations with the following
entries.
When an order or order line is created, the application will search for related
information in the MarkupAutoTable. If the search finds some information, then
the related information in the MarkupAutoLine table is copied to the
MarkupTrans table.
8-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
FormLetter Framework
The FormLetter framework in Microsoft Dynamics AX is used when posting
documents for sales or purchase orders. This framework is refactored in
Microsoft Dynamics AX 2012 to provide better support for customizations,
extensibility, and performance. This lesson describes the Microsoft Dynamics
AX 2012 version of the framework.
8-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The following figure shows how the various base classes are used when posting a
document for an order.
8-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The following figure shows the various class hierarchies used when posting a
sales order packing slip document.
8-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The module specific classes, such as SalesFormLetter, are updated so that they
extend the FormLetterServiceController class. All functionality that does not
relate to the interaction with the Posting form is moved to other class hierarchies.
The class variables that are assigned a value to use during the posting process in
earlier releases are moved to the data contract classes.
The pattern used to assign values to the data contract classes are the parm
methods from Microsoft Dynamics AX 2009 that changed and use the data
contract class instead of a global class variable. The following code sample is an
example of a parm method.
8-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Parm methods are used to set and get the data from a contract class. The
following code sample is an example of a parm method:
[DataMemberAttribute]
public NoYes parmDirectDeliveryUpdate(NoYes
_directDeliveryUpdate = directDeliveryUpdate)
{
directDeliveryUpdate = _directDeliveryUpdate;
return directDeliveryUpdate;
}
8-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The run method initializes the objects required for posting, creates the journal,
posts the documents, and then calls the logic to print the document if required.
The class also has a service operation method for each of the document types that
can be posted by this service, such as PostSalesPackingSlip.
[SysEntryPointAttribute]
FormLetterOutputContract
postSalesOrderPackingSlip(SalesFormLetterPackingSlipContrac
t _contract)
{
formletterContract = _contract;
this.run();
return outputContract;
}
8-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
The SalesTable and SalesLine tables contain information manually entered in the
sales table form.
The update is activated by using a button in the Action Pane of the Sales order
form. This creates an update specification in the SalesParm-tables.
Lines from different sales orders can be collected in one invoice. The
SalesParmSubTable holds one record for each sales order that contributes to such
invoices. Information in SalesParmLine refers to the sales order that contains the
invoice with the SalesId field, whereas the OrigSalesId field contains the ID of
the sales order that relates to the line(s) in question. SalesParmSubLine contains
sales order line update relations.
8-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The base class uses a template pattern that defines a template for how to create
records in the parm tables. There are module specific classes such as
SalesFormLetterParmData, and one class for each document type supported, such
as SalesFormLetterParmDataPackingslip.
8-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
8-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
There are also document specific classes for each of the documents created by
the framework, such as SalesPackingSlipJournalCreate. These classes hold the
logic specific for a document. Those document classes that support having
multiple versions of the same document extend the
FormLetterVersionableJournalCreate class.
The FormLetterService class instantiates this class hierarchy for each of the
journals it needs to create and calls run.
8-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
There is also a document specific class for each of the documents posted by the
framework, for example SalesPackingSlipJournalPost. These classes hold the
logic specific for a document. This class hierarchy requires that a journal is
created and passed in.
The FormletterService class instantiates this class for each of the journals it needs
to post and calls run.
8-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When a document is posted, the data from the parm tables is copied to another set
of tables that are used for balancing the ledger to the sub-ledger. For example, the
sales order invoice creates transactions into the customer invoice tables. The
following figure shows the data model for a sales order invoice document.
If multiple sales orders contribute sales lines to one invoice, then only one of the
sales IDs will be stored in CustInvoiceJour. CustInvoiceSalesLink is used to
show all invoices related to a sales table, regardless of which sales order owns
the invoice.
8-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
TIP: A periodic job can be used to clean up and delete records from the parm
tables.
The previous pattern is repeated many times, one for each type of update in the
sales and purchase areas.
The FormLetterService class instantiates this class either for each of the journals
being posted, or once with a list of all posted journals.
8-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
8-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Scenario
The solution should contain a new field in the customer table. This field should
contain instructions for the payment of invoices sent to the customer. The field
should be implemented as a multiline field, with a limit of 100 characters.
When a new sales order is created, this field should be copied to the sales order.
You should be able to change the value for specific sales orders.
When you post an invoice, you should be able to change the field without
overwriting the original value in the sales table. The value specified while
ordering the update should be printed on the invoice.
Technical Issues
This section outlines additional information that is required to implement the new
field.
InitFrom
Transfer of information from one table to another is frequently used when you
create records and save transactions from updates. This task is typically
implemented by creating an object method in the destination table named
initFrom<sourcetable>. Creating a record in a sales table in this manner involves
the activation of the following logic
salesTable.initFromCustTable();
8-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The SaleFormLetter class hierarchy is used for this posting. Depending on the
menu item that is selected, the appropriate subclass of SalesFormLetter is
instantiated. The dialog method of the SalesFormLetter object opens the
SalesEditLines form.
In the init method of the SalesEditLines form an object of one of the classes in
the SalesEditLinesForm hierarchy is instantiated. Methods of this class hierarchy
are called from the form to control the layout of the form.
The pattern used can be explained by viewing how the display of the Bill of
lading tab page is controlled in SalesEditLines. The Bill of lading tab page is
only visible if you are posting to an invoice.
tabPageBillOfLading.visible(salesEditLinesForm.billOfLading
());
Implementation
Extend CustTable, SalesTable, SalesParmTable and CustInvoiceJour tables with
the new field that contains the instructions for the payment of invoices sent to the
customer.
1. Create a new project to store all of the objects that you modify or
create as a part of this lab.
2. Make an extended data type defining properties of the payment
instruction.
3. Create a new field in the tables that is required to implement the
requested possibilities to change and store the information.
4. Add fields to the relevant forms to view the current value and
possibly edit this value.
5. Add a field to the SalesInvoiceTmp table for the payment
instructions and modify the SalesInvoiceDP class to populate the
field. Then include the field in the header of the SalesInvoice report.
8-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
To add the payment instruction extended data type, follow these steps.
1. Under the Data Dictionary node in the AOT window, expand tables
and locate the CustTable.
2. Drag the table into the project that you created earlier.
3. Expand the CustTable table.
4. Select the PaymentInstruction extended data type and drag it to the
Fields node of the CustTable table.
5. Save the table.
6. Right-click the Field groups node and then click New Group.
8-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
8. Select the Payment instruction field from the Fields node on the
CustTable table, and then drag it into the PaymentInstruction Field
group.
9. Save the table. If the Synchronize table window opens, click
Continue.
10. Repeat steps 1-9 for the SalesTable, SalesParmTable, and
CustInvoiceJour tables.
1. In the AOT window, expand Forms and then locate the CustTable
form.
2. Drag the CustTable form into the project that you created earlier.
3. Save the project.
4. Right-click the CustTable form and then click Restore.
5. In the Data Sources node of the form browse to CustTable > Fields
and then select the Payment Instruction field group (folder) from the
list.
6. Drag the Payment Instruction field group into the bottom of the Sales
order defaults FastTab (TabPageSales) under the Design node of
the form. (To locate the TabPageSales tabpage, browse to Designs >
Design > Tab:Tab > TabPage:TabPageDetails > Tab:TabHeader
> TabPage:TabPageSales in the CustTable form.)
7. Right-click on the CustTable form and then click Open.
8. Verify that the new Payment instruction field is available.
9. Repeat steps 1-8 for the SalesTable form. Place the field group on
the Setup (TabHeaderSetup) FastTab of the Header view on the
form. (To locate the TabHeaderSetup, browse to Designs > Design >
Tab:MainTab > TabPage:TabPageDetails > Tab:DetailsTab >
TabPage:HeaderView > Tab:HeaderDetailsTab >
TabPage:TabHeaderSetup in the SalesTable form.)
10. Repeat steps 1-8 for the SalesEditLines form (the field group is in
the SalesParmTable data source). Place the field group on the Setup
(TabSetup) tab on the form. (To locate the TabSetup, browse to
Designs > Design > Tab:TabSalesParmTable >
TabPage:TabSetup in the SalesEditLines form.)
NOTE: You cannot open this form directly, you must open it from the Sales
order form by selecting a delivered sales order, and then click the Invoice tab in
the Action Pane, and then click Invoice in the Generate group.
8-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_08_01_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
this.setPaymentInstruction();
return custInvoiceJour.PaymentInstruction;
}
8-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NOTE: The code will vary slightly for each method. Make sure to use the correct
table and field for each class.
#define.PaymentInstruction('PaymentInstruction')
return this.get_Attribute(#PaymentInstruction);
}
NOTE: The code will vary slightly for each method. Make sure to use the correct
table and field for each class.
8-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
1. Under the Data Dictionary node in the AOT window, expand tables
and locate the SalesInvoiceTmp.
2. Drag the table into the project that you created earlier.
3. Expand the SalesInvoiceTmp table.
4. Select the PaymentInstruction extended data type and drag it to the
Fields node of the SalesInvoiceTmp table.
5. Save the table.
1. Locate the SalesInvoiceDP class and drag it into the project that you
created earlier.
2. Locate the insertIntoSalesInvoiceTmp method and then right-click
and select View Code.
3. Add a line of code to the bottom of the //Invoice section after line 79
to set the temporary tables payment instruction field equal to the
custInvoiceJour payment instruction field. Use the following code
sample to guide you.
salesInvoiceTmp.PaymentInstruction = custInvoiceJour.PaymentInstruction;
8-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Test
Use the following steps to create a new sales order, and to post and print the
invoice.
1. Open the Customers form by using the path Accounts receivable >
Common > Customers > All customers and specify a value in the
new field that has the payment instruction.
2. Create a new sales order by using the path Accounts receivable >
Common > Sales order and select the customer modified in step 1.
Make a modification to the payment instruction inherited from the
customer.
3. Add a line to the sales order for item number 10007.
4. Post the invoice by clicking the Invoice tab of the Action Pane and
then click Invoice in the Generate group. Change the payment
instruction inherited from the sales order. Select to print the invoice
and specify the screen as the destination of the report by clicking the
Printer Setup->Invoice button and change the print destination to
screen on the Print destination settings form.
5. You can repeat the test by creating a new sales order.
8-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Other Features
There are many additional features in the Sales and Purchase Order modules.
The following lesson introduces sales quotations, request for quotations,
purchase requisitions, and categories.
The two main functional benefits of applying the versioning pattern are:
Purchase order
The purchase order is the most complex use of the versioning pattern in
Microsoft Dynamics AX 2012. Besides the traceability and change management
with workflow integration it also enabled other procurement functionality
extensions like encumbrance accounting for confirmed purchase orders.
8-45
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Product receipts and packing slips use of the pattern is limited to versioning and
no workflow integration is enabled.
The following purchase order logical data model shows how the versioning
pattern is applied to the purchase order document. White entities were present in
earlier AX versions: PurchaseOrder (PurchTable),
PurchaseOrderLine(PurchLine) and the *MiscCharge* entities (MarkupTrans).
They define the basic PO tree structure with the PurchaseOrder being the root
node, PurchaseOrderLine its child node type and MiscCharge nodes that could be
children of both PurchaseOrder and PurchaseOrderLine. The highlighted entities
were added to support versioning.
8-46
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Physical table names of the history tables are based on the physical table names
of the corresponding node tables, for example, the physical table name for the
purchase order line history entity is PurchLineHistory. The physical model
adjustments include the use of the IsModified flag and duplication of most of the
immutable attributes to the history tables (for example, PurchLineHistory.ItemId)
to help simplify queries against the archived versions (in other words, there is no
need to join PurchTable, PurchLine and MarkupTrans in such queries).
8-47
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Sales Quotations
A quotation is a proposal to a customer to make an order. The quotation can be
sent to prospects that are not existing customers or existing customers, and
typically the company issuing the quotes does not expect to receive orders from
all the recipients of the quotation. If a quotation is accepted, it will be
transformed into a sales order.
The SalesQuotationTable table stores one record for each quotation. The details
of the quotation are stored in SalesQuotationLine. When the quote is confirmed
the data is transferred to the sales order that is described in the following section.
The PurchRFQCaseTable stores one record for each case, and the
PurchRFQTable stores one record for each vendor on a specific case. The details
of the quote are stored in PurchRFQCaseLine. When the quote is accepted the
data is transferred to the purchase order that is described in the following section.
8-48
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Purchase Requisitions
You can use a purchase requisition to submit a request for items or services that
you must have to perform your job function. By using purchase requisitions, you
can do the following.
The PurchReqTable table contains one record for each purchase requisition. The
details of each product or category on the purchase requisition are stored in the
PurchReqLine table.
Each purchase requisition and line on a purchase requisition can contain a reason
or business justification for the request. The system can be configured to require
business justifications. The business justifications for each purchase requisition
and line are stored in PurchReqBusJustification.
The PurchReqExternalSource table contains the identifier that is used for the
purchase requisitions in an external source system when the requisition originates
from such a system.
8-49
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Summary
Sales orders and purchase orders are two of the main transactions in Microsoft
Dynamics AX. The functionality and data structures that are used with each are
very similar.
Sales orders and purchase order have many integrations with other areas and
modules of the system. Several different frameworks are provided with Microsoft
Dynamics AX to help you manage basic order information, pricing, charges and
document history.
Both areas integrate with the agreements feature which allows you to define basic
contracts for sales or purchases. The FormLetter framework allows you to
manage the data for posting documents such as confirmations, packing slips, and
invoices.
8-50
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
8-51
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
8-52
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 8: Use and Design of the Sales and Purchase Modules
Solutions
Test Your Knowledge
1. Which class is used to control functionality about each type of order?
( ) PurchOrderType
(•) PurchTableType
( ) InventOrderType
( ) InventTableType
MODEL ANSWER:
8-53
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
8-54
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
• Describe how projects are created, and the various types of projects
that are available.
• Review the data model for projects.
• Discuss the significant classes that are used with projects.
• Describe how the work breakdown structure is used with projects
and how the data model relates to the project data model.
• Discuss the transaction types that are used for journals in the Project
management and accounting module and how categories, pricing,
and line properties control the posting of these transactions.
• Review the data model and the ProjTrans class hierarchy that is used
for posting transactions against a project.
• Describe how budgeting and forecasting works with projects.
• Review the data model for budgets and forecasts.
• Describe how project contracts are used.
• Review the data model for project contracts.
• Describe how project invoice proposals and invoices are generated in
Microsoft Dynamics® AX.
• Review the data model and classes used for generating invoice
proposals and invoices.
• Review how estimate projects and cost templates are used in the
system.
• Describe the Project Management and Accounting Add-In.
Introduction
This chapter introduces you to the Project management and accounting
module of Microsoft Dynamics AX. The design and data models for several key
areas are reviewed.
Use the project management and accounting module to plan, create, manage,
control, and complete projects for your organization. Customer-focused projects
can be set up on a time and materials or fixed-price basis. You can also use the
module to manage costs for internal and investment projects.
9-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
For external projects, you can create project quotations that can be converted to
projects. You create project contracts with one or more funding sources that will
be invoiced for project costs and fees.
Each project that you create can have one or more subprojects and activities that
are made up of the project work structure. You can create financial forecasts and
budgets for cost control and to measure project performance.
You can assign attributes for project skills and experience to workers to enable
you to search for and assign workers to a project that is based on skills and
availability. For additional project planning flexibility, you can integrate the
projects with Microsoft® Project Server.
During project execution, employees and contractors can enter project timesheets
and expense reports. Required items and services can be procured and charged
back to the customer.
Project managers have many different reports and analytical tools to examine
project performance from different perspectives. The following figure provides
an overview of the Project management and accounting module.
9-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Projects
The project list contains the list of all projects in the current company and will be
used frequently by project managers. Open Project management and
accounting > Common > Projects > All projects.
Subprojects
Some projects can easily be processed as one large project for planning and
accounting if the subprojects and complexity are low. Other projects gain more
overview when distinct phases of the project's activities are split into separate
subprojects. For example, if a large project has several phases such as a design
phase and an implementation phase a separate subproject can be created for each
phase.
9-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You can use subprojects to achieve a project structure that reflects the different
project initiatives, and to process special accounting situations.
All project types can be combined in a project hierarchy, and more subprojects
can be added as a project progresses. Project hierarchy properties appear in the
Project hierarchy tab on the Project details form. Each subproject must have a
project ID that follows the format <Parent Project ID><Delimiter><Subproject
ID>.
Project Types
The Project management and accounting module, supports the following six
project types.
• Time and material: Time and material projects are invoiced as work
progresses based on the consumption of hours, expenses, items, or
fees on the project. This project type is mainly applied to projects
where costs can be matched with the revenue on each transaction and
the project is invoiced as work progresses.
• Fixed-price: Fixed-price projects are for projects that are invoiced
according to a billing schedule based on the project contract.
Revenue for a fixed-price project can be posted according to the
completed contract method or according to the completed percentage
method.
• Internal: Internal projects are financed by your company. There are
no customers for this project and it cannot be invoiced. Costs can be
posted to profit and loss accounts or balance sheet accounts.
9-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
• Cost: Cost projects are internal projects that register hours, expenses,
and item transactions. Transactions on cost projects are posted to
profit and loss accounts and cannot be capitalized to balance
accounts.
• Time: Time projects are internal projects that only register hour
transactions. Time projects are applied to the total number of hours
consumed on a task or a project. Unlike the transactions on an
internal project type, transactions on a time project are never posted
to ledger accounts. Examples of time projects include the registration
of illness or holidays.
• Investment: Investment projects are internal projects without
immediate earnings. Only costs of items, hours, and expenses can be
registered on an investment project, and the estimate feature is
applied to track and control costs. Costs registered to an investment
project are entered on profit and loss accounts and transferred to
work in progress (WIP) accounts when estimates are posted. After
the project is completed and the project is eliminated, the WIP value
is transferred to a fixed asset, a ledger account, or a new project.
Project Groups
Project groups define how the system processes the ledger postings of the project
types. Each project belongs to a single project group.
Project groups control the posting profiles to the general ledger and the project
WIP.
Rules for posting transactions are set up according to project or category type,
and the costs are posted into profit and loss or balance accounts. Because the
project group is mandatory when you create a new project, a minimum of one
project management and accounting group must be set up.
When you create a project group, you must immediately determine the project
type tied to this group. Then you will assign the specific conditions connected to
that specific type, such as invoice posting, journalizing, cost price, and sales
price.
When you create new projects, you can only select groups that are defined for
that specific project type.
9-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Open Project management and accounting > Setup > Posting > Project
groups.
9-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
The ProjTable is the primary table for projects; each project has one record in the
ProjTable. For external (billable) projects, each project contract
(ProjInvoiceTable) is attached to one or more customers for invoicing and
payment. Each project is also attached to a project group (ProjGroup). The
project group defines how the system processes the ledger postings of the various
project types.
9-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
ProjTableType Class
Microsoft Dynamics AX 2012 supports several different types of projects such as
internal, cost, and time. Each type supports different tasks and functionality.
Instead of creating many if-statements to separate the functionality about the
project type, the properties and methods are isolated on the class hierarchy
ProjTableType. The following figure shows the ProjTableType class hierarchy.
To create a new project type, start by adding a new element to the project type
base enumeration, and then create a new class that extends the ProjTableType
class. Add methods to the new class that override the base methods in the
ProjTableType class. Then you must modify the type() object method on the
ProjTable.
9-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
To set up activities, open Project management and accounting > Common >
Projects > All projects. Highlight the project for which you want to set up a
WBS. In the Action Pane, select the Plan tab, and then in the Activities group,
click Work breakdown structure.
Activities are set up by using an activity hierarchy, in which sub activities are
created as smaller tasks within one large task or phase of a project.
To create a new activity, from the Work breakdown structure window, click a
specific activity and then click New.
9-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Each project activity has one record in the ProjActivity table. Each project
activity record is associated with one category. Each project can have many
different activities and many projects can have the same activities.
9-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
After transactions are posted against projects, an invoice proposal can be created.
The system creates a suggested invoice based on user-defined criteria. The
invoice proposal for each transaction type is stored in five tables. When
transactions are invoiced, they are stored in another set of five tables.
Transaction Types
After a project is created, transactions are entered through journals or project-
related business documents. The following transaction types are supported in the
Project management and accounting module.
• The system searches for sales and cost prices and applies them as a
default to the transaction. The user can override prices in the journal.
• The sales tax group is copied from the project or project contract. For
non-item transactions, the item sales tax is derived from the specified
project category.
• The line property indicates whether the registered transaction can be
invoiced or not. A line property that can be charged is only relevant
on time and material projects.
9-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The following diagram shows the correlation between shared categories, project
categories, category groups, and transaction types:
You can use category groups to share properties (primarily posting profiles)
between related categories. You must have a minimum of one category group for
each transaction type and each project category is assigned a group.
Together, the project groups, project categories, and category groups define the
posting specifications in the Project management and accounting module.
Additionally, line property defaults can also be defined for category groups.
To open the Category groups form, open Project management and accounting
> Setup > Categories > Category groups.
Project Pricing
Project transactions include a cost price, a sales price or both. The cost price is
the price for each unit that is charged to the project. If a customer is invoiced for
transactions, a sales price is specified for each unit. Sales prices are not used for
fixed-price projects or internal projects.
9-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Cost and sales prices can be specified generically at the category or employee
level, or more specifically on a project. Specifying them generically helps
standardize pricing, removing the need for users to determine the cost and sales
price at the time of transaction entry.
To access prices open Project management and accounting > Setup > Prices,
and then select one of the forms.
Line Properties
In addition to project categories and pricing, line properties are also significant to
project transactions. A line property controls whether any of the following
occurs.
The line properties are set up from the Line properties form. Open Project
management and accounting > Setup > Line properties > Line properties.
Journals
Journals are used to post the various types of transactions. Each journal uses
different tables with similar data models. The following topics review the hour’s
journal.
The basic information entered for the hour registration on a project includes the
following.
To open the hour journal form, open Project management and accounting >
Journals > Hour.
9-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
9-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
The following table lists the journal header, lines, and posting table that is used
for each of the types of journal.
9-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
/// <summary>
/// Determines whether this transaction has been invoiced.
/// </summary>
/// <returns>
/// Always returns false.
/// </returns>
/// <remarks>
/// This method should be overridden by classes that extend
this class to provide the necessary
/// functionality for the specific transaction.
/// </remarks>
//BP Deviation Documented
public display boolean invoiced()
{
ProjCostTransSale projCostTransSale;
boolean ret;
if (!SysDictClass::isSuperclass(classIdGet(this),
classNum(ProjTransCostTrans)))
{
while select projCostTransSale
where projCostTransSale.TransId == this.transId()
{
ret =
ProjTrans::newProjCostTransSale(projCostTrans,
projCostTransSale).invoiced();
if (ret)
break;
}
}
else
{
ret = super();
}
return ret;
}
9-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Scenario
The Contoso Company offers repairs to the items that they sell, and requires
employees to record time against a single project, which is titled Warranty
Repairs. It is required that the employee record in which item the repair work is
performed.
Challenge Yourself!
Use the information provided, to add a new warranty item field to the hours
journal that is copied to posted hours transaction record.
Step by Step
To create a new project, follow these steps.
9-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To add the warranty item extended data type, follow these steps.
To add the warranty item field to the ProjJournalTrans table and the
ProjJournalTransEmpl form, follow these steps.
1. Under the Data Dictionary node in the AOT window, expand tables
and locate the ProjJournalTrans table.
2. Drag the table into the project that you created earlier.
3. Expand the ProjJournalTrans table.
4. Select the warranty item extended data type that you created and
drag it to the Fields node of the ProjJournalTrans table.
5. Save the table.
6. Expand the Field groups node
7. Select the warranty item field that you created from the Fields node
on the ProjJournalTrans table, and then drag it into the
IdentificationHour field group.
8. Save the table. If the Synchronize table window opens, click
Continue.
9. In the AOT window, expand Forms and then locate the
ProjJournalTransEmpl form.
10. Drag the ProjJournalTransEmpl form into the project that you
created earlier.
11. Save the project.
12. Right-click the ProjJournalTransEmpl form and then click Restore.
13. In the Data Sources node of the form browse to ProjJournalTrans
> Fields and then select the warranty item field that you created.
14. Drag the warranty item field into the grid of the form. (To locate the
grid, browse to Designs >Design > Tab:Tab > TabPage:Overview
> Grid:Grid in the ProjJournalTransEmpl form.)
9-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
To add the warranty item field to the ProjEmplTrans table and the
ProjTransEmpl form, follow these steps.
1. Under the Data Dictionary node in the AOT window, expand tables
and locate the ProjEmplTrans table.
2. Drag the table into the project that you created earlier.
3. Expand the ProjEmplTrans table.
4. Select the warranty item extended data type that you created and
drag it to the Fields node of the ProjEmplTrans table.
5. Save the table.
6. Expand the Field groups node
7. Select the warranty item field that you created from the Fields node
on the ProjEmplTrans table, and then drag it into the Identification
field group.
8. Save the table. If the Synchronize table window opens, click
Continue.
9. In the AOT window, expand Forms and then locate the
ProjTransEmpl form.
10. Drag the ProjTransEmpl form into the project that you created
earlier.
11. Save the project.
12. Right-click the ProjTransEmpl form and then click Restore.
13. Save the form and the project.
projEmplTrans.ProjWarrantyItemID = _projJournalTrans.ProjWarrantyItemID;
9-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Test
To test the solution and verify that the Warranty item field is copied from the
journal to the posted transaction, follow these steps.
9-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Project budgeting works with general ledger (GL) budgeting. Transactions are
compared with project budgets and then against general ledger budgets. Project
budgeting is also closely related to project forecasting. You can build project
budgets from forecast models. Additionally, project budget amounts (original and
remaining) are maintained as two specified forecast models for control and
reporting. Additionally, Microsoft Dynamics AX supports a cost control
mechanism called forecast reductions.
When you create a project, you create the original budget. You can define
budgets for costs, revenues, or both. After you define the budget, you submit the
budget to workflow.
After a budget is approved, any changes to the budget must undergo the budget
revision process.
Before you create project budgets, you must define the approval process.
Approval of project budgets is implemented by using the workflow feature of
Microsoft Dynamics AX. Two workflow types are defined for project budgeting.
After the project budget is defined, make sure that the project is configured to use
the budget. You can do this in the Budget and forecast tab on the Project
details form. After you enter a budget or budget revision you can allocate the
budget amounts across periods.
When you are entering a project item task (such as a project purchase requisition,
purchase order, or vendor invoice) you can view the impact the document will
have on the transaction on the project budget.
9-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
5. Add an item to the order such as 1101, and then click on the Manage
tab in the Action Pane.
6. Enter a Quantity and Unit price for the item.
7. Click Budget > Project budget status. The Project budget status
form will display details of the budgeted amounts for the item,
category, activity, and budget period.
At the end of the year, you can transfer any remaining budget amounts for
multiyear projects to future years. You can also create budget register details for
those amounts in the associated general ledger accounts. The
ProjYearEndProcess class contains the logic to run the process.
9-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
When budgets are activated for a project, the project budget details are stored in
the ProjBudget table. Each budget amount is stored in the ProjBudgetLine table.
The ProjBudgetLine.ProjTransType field is used to determine whether the
budget is a cost or revenue.
9-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Forecasting
You can use project forecasting to forecast expected labor, machines, expenses,
and cash flow that is needed to run projects. You can also use project forecasting
to effectively use resources and to control expenses so that a reasonable profit
margin can be earned.
When you set up forecasts you can create a new record for each forecast model to
use, and create submodels if a model hierarchy must be built. The model
hierarchy can only contain two levels.
After you have defined forecast models, you can enter forecasts for hours,
expenses, fees, items and on-account payments.
Open Project management and accounting > Common > Projects > All
projects. Select a project. On the Action Pane, on the Plan tab, in the Forecast
group, you can click a specific type of forecast.
9-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Forecast Scheduling
Project managers can use the Project management and accounting module to
group forecasted hour consumption by worker. You can use the resources to plan
and schedule hours, and use the hour scheduling function to perform job
scheduling and operations scheduling.
Scheduling involves resources, not workers. With the Project management and
accounting module, you can use the type of resource and the capacity-related
options to determine the project schedule. When you use work centers, you can
schedule all resource types, and schedule whole processes, because it is not
limited to only human resources.
9-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Each hour forecast record is stored in the ProjForecastEmpl table. Each forecast
is related to a specific activity from the work breakdown structure and the
resource requirements are stored in the WrkCtrActivity... tables. These
requirements are used to schedule projects.
9-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
A similar data model exists for the other types of forecasts by using similar
tables.
Project Contracts
The project contract contains necessary customer information for correctly
issuing invoices to one or more project customers. All external projects must
refer to a project contract. This makes the setup of the project easier. The project
contract includes information on the following.
• Invoicing currency
• Customer and address information
9-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• Terms of payment
• Sales tax and tax information
• Fixed exchange rate agreement references
You can also choose to set up project funding information for a project including
funding sources, limits, and rules for funding.
After a project contract is defined, it can be used when you create a new external
(time and material or fixed-price) project.
Each project contract is stored in the ProjInvoiceTable. Each project can then be
related to one project contract. Multiple projects can be related to the same
project contract. The funding information on project contracts is stored in three
additional tables.
9-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Invoicing
You can create project invoices by using an invoice proposal that is later
confirmed and posted to the general ledger. This proposal is populated according
to selections made by the user, which can be modified if necessary and then
posted.
Invoice Proposals
The invoice proposal is generated based on the transactions registered on the
projects. The transaction types include expense, employee hours, fee, items, and
an offset on-account payment.
The Invoice proposals form includes proposed invoice lines on separate tabs,
according to the transaction type.
Invoice proposals are created by using the ProjInvoiceChoose super class and
subclasses. On account transactions use a specific subclass. The following figure
shows the ProjInvoiceChoose class hierarchy.
9-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Canceling the invoice proposal only cancels the proposal lines. To access a
canceled invoice proposal, a new invoice proposal must be created.
To delete one or more proposal lines, select the transaction(s) and then click
Remove from the toolbar. This does not delete the actual transaction, only the
line from the invoice proposal. Deleted lines are reselected as proposals the next
time that an invoice proposal is run.
If new transactions are posted within the same date range as the previously
created invoice proposal, and they must be included, use Add lines. The system
finds any transactions that fall into the same selection criteria that is specified in
the original invoice proposal and adds them to the existing proposal.
Post Invoices
After the invoice proposal is reviewed and edited, and the lines are satisfactory
you can post the invoice by clicking Post.
As with standard sales order invoicing, you can specify whether a credit limit
check of the customer must be performed when you post the invoice. The overall
control of how the system warns the user if the credit limit is exceeded is set up
in the Project management and accounting parameters form under in the
Invoice tab under Credit rating.
In addition to the Invoice proposal form, invoice proposals can also be posted by
running the periodic job, Post invoice proposals. To find this job, open Project
management and accounting > Periodic > Project invoices > Post invoice
proposals.
9-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
ProjFormLetter Class
Invoicing occurs in the ProjFormLetter class and in the ProjFormLetter_Invoice
subclass. The structure for these classes resembles the FormLetter classes used in
the Accounts receivable and Accounts payable module discussed earlier in the
“Use and Design of Sales and Purchase Modules” chapter.
When the invoice is posted new transactions are created in several tables to store
the posted information. Each invoice has a record in the ProjInvoiceJour table for
the header of the invoice. For the lines of the invoice, several tables are used for
each transaction type.
9-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Scenario
Challenge Yourself!
Put an invoice proposal on hold.
This requires a new field, OnHold, type = NoYes. If this field is set, then the
invoice cannot be posted, and a new invoice proposal can be created that could
include transactions included on the OnHold proposal.
Step by Step
To create a new project, follow these steps.
9-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
1. Under the Data Dictionary node in the AOT window, expand tables
and locate the ProjProposalJour table.
2. Drag the table into the project that you created earlier.
3. Expand the ProjProposalJour table.
4. Right-click the Fields node of the table and then click New > Enum.
5. In the Properties window, set the following values.
a. Name = OnHold
b. Label = On hold
c. HelpText = When selected the invoice proposal is on hold and
cannot be posted.
d. ExtendedDataType = NoYesId
9-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
/// <summary>
/// Contains the code that does the actual job of the class.
/// </summary>
public void run()
{
if(!this.validate())
{
throw error('@SYS21533');
}
super();
}
5. Locate the validate method and then right-click and select View
Code.
6. Add an IF statement to the end of the method that checks for the
invoice proposal to be on hold and return a warning message when it
is on hold. Use the following code sample to guide you.
if(this.parmProjProposalJour().OnHold)
{
ret = checkFailed("The proposal is on hold and cannot be posted.");
}
9-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
9-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Estimate Projects
Estimates are maintained on individual estimate projects or on batches of
estimate projects. When estimate projects are processed in batches by using
periodic jobs, the estimate projects that are selected for processing are grouped
by period code.
NOTE: The data in the Hyper-V training environment does not include any
estimates. You can create a new estimate by clicking New in the Estimates form.
Cost Templates
Cost templates are used in the calculations for revenue recognition for fixed-price
projects.
Example
You are working on a website design project for a customer for a flat fee of
10,000 United States dollars (USD). You forecast that it will take 100 hours
(5,000 USD) to complete the project, and two plane tickets and four nights in
hotels for trips to the customer’s site (1,800 USD). This results in a total
forecasted cost of 6,800 USD.
9-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
When you run the fixed-price revenue recognition process to create an estimate at
the end of the month, you find that you have already worked 35 hours on the
project to this point, without flights or hotel stays. You also had an assistant
perform five hours of research for the project that you did not plan for, at a cost
of 100 USD.
When you calculate the percent complete value for this project, you have some
choices to make.
• Do you want to include all costs (hours and expenses) or just hours?
• Do you want to include all hours or just planned hours?
• Do you want to calculate the percent complete based on the dollar
cost of the planned hours (5,000 USD) or just on the number of
hours (100)?
Your answers to these questions determine the options that you set on the cost
template and the categories that you select on the cost template lines.
The following table shows the results of different methods of calculating the
percent-complete value for this scenario.
9-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Deciding which approach to take to create a cost template can depend on several
considerations.
• If you use the third method that is listed in the table, you would only
update the planned hours for your own time to keep the percent-
complete calculation accurate. Your profitability will change when
unplanned hours are logged. However, you will remain on a known
percent-complete trajectory.
• If you use the fourth method that is listed in the table, the risk is that
expenses will occur at irregular times and might not be reflected in
your completion progress.
o Therefore, if the expenses are included, they can cause your
percent complete to fluctuate more than is desirable. For
example, because you have not yet taken a flight yet, your
percent complete is 27 percent instead of 35 percent or 37
percent if you base the calculation on time alone.
o If you had taken one trip for two nights and forecasted your
flight and hotel costs accurately, the percent complete would be
40.4 percent (1850 USD for labor and 900 USD for expenses =
2750 USD / 6800 USD = 40.4 percent). Therefore, incurring the
expenses for just one plane trip would change the percent
complete from 27 percent to 40 percent.
You can use the Project Management and Accounting Add-in to identify and
schedule workers with specified project experience. You can also assign direct
and indirect costs for service projects, and create customer invoices for billing
scenarios that are specific to service industries.
9-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Key Features
Some key industry-specific features of the Project Management and Accounting
Add-in include the following.
Summary
This chapter described the overall use and design of the Project management
and accounting module. Several types of projects exist that you can use to create
and manage project information. Projects can be linked to one another by using
subprojects to create a hierarchy of related projects. Each project is assigned to a
group that controls how the ledger postings will work for each project.
You can use the work breakdown structure to create a hierarchy of tasks or
activities that will be completed for a specific project. Activities can be
associated to resources that can be linked to resource requirements for
forecasting and scheduling the tasks.
Projects can have many transactions posted to record the various costs and
revenues for the project. The transactions can include hours, expenses, items, fee,
and on account payments. Journals are used to post these transactions. After
transactions are recorded, you can create invoice proposals and invoices to record
the project transactions against the customer's account and into the general
ledger. This requires that a project contract is set up first.
You can also record budgets and forecasts for projects to provide better reporting
and to set limits and controls on transactions.
You can use estimate projects to record estimates into the general ledger based
on cost templates that define how the revenue is to be recognized for a specific
project. Later when the project transactions are recorded, you can eliminate the
estimates.
9-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
3. Which class hierarchy is used to control the functionality for each type of
project?
( ) ProjLineType
( ) ProjTableType
( ) ProjPostingType
( ) ProjTransactionType
9-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
5. Which of the following statements are true about project contracts? (Select
all that apply)
( ) All projects must have a minimum of one project contract defined.
( ) Many projects can be related to the same project contract.
( ) Each project contract must have a minimum of one project funding
source defined.
( ) Each project or subproject can only be related to one project contract.
6. Which of the following statements are true about all journals and transactions
for projects? (Select all that apply)
( ) Users can override sales and cost prices in the journals.
( ) All transaction types can use validation functionality.
( ) On account transactions can be applied to all project types.
( ) The line property indicates whether the registered transaction can be
invoiced or not.
9-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
9-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 9: Use and Design of the Project Management and Accounting
Module
Solutions
Test Your Knowledge
1. Describe the difference between project budgeting and project forecasting.
MODEL ANSWER:
Project budgeting helps companies monitor and control project revenue and
expenditures. By comparing budget and actual amounts, your organization
can reallocate money and resources to meet budgetary goals.
3. Which class hierarchy is used to control the functionality for each type of
project?
( ) ProjLineType
(•) ProjTableType
( ) ProjPostingType
( ) ProjTransactionType
9-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
5. Which of the following statements are true about project contracts? (Select
all that apply)
( ) All projects must have a minimum of one project contract defined.
(√) Many projects can be related to the same project contract.
(√) Each project contract must have a minimum of one project funding
source defined.
(√) Each project or subproject can only be related to one project contract.
6. Which of the following statements are true about all journals and transactions
for projects? (Select all that apply)
(√) Users can override sales and cost prices in the journals.
( ) All transaction types can use validation functionality.
( ) On account transactions can be applied to all project types.
(√) The line property indicates whether the registered transaction can be
invoiced or not.
9-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Introduction
Production control in Microsoft Dynamics AX 2012 consists of many aspects of
the production environment. This includes creation, estimation, scheduling,
consumption, feedback, and cost accounting for production orders.
10-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The major processes of the Production control module are shown in the
following figure.
In this chapter, you will review the following major components of the
Production control module.
10-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Bill of Materials
A bill of materials (BOM) is a complete list of all the components, parts, raw
materials, assemblies and their quantities that are required to make a finished
product.
BOMs define the relationship between the components and the finished product
or sub-assembly. The item number that represents the BOM is often referred to as
the finished product, and the components that make up the finished good are
referred to as raw materials. In some cases the item number that represents a
BOM is not a finished good and is instead referred to as a sub-assembly which is
used in another BOM to create a finished product or another sub-assembly. A
clear definition of this relationship is important for the following.
• Allocation of materials
• Scheduling of operations or jobs
• Creation of production orders
• Costing of the BOM and production order
Every item that must be physically accounted for in a finished product or sub-
assembly product or financially accounted for in the costing phase must be
included in the BOM. Although BOMs define the components and their
relationships, they do not define the sequence of steps to produce or assemble the
finished item.
BOMs are made up of product types, versions, configurations, sites, levels, lines,
and information used for cost calculations. In the following sections, these
components and the data model for BOMs are reviewed to illustrate the
relationship between the tables.
10-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
BOM Version
A BOM can have multiple versions. When you create a BOM, you must have at
least one version. In order to use the BOM it must be approved and activated.
Later, if the BOM is no longer required, the activation and approval can be
removed. The BOM version is used to define which finished product item
numbers are linked to the BOM. You can also specify information about the date
of validity, site, quantity ranges, whether the version is active, and who approved
it.
Zero or more BOM versions can be valid or active for any item at any given
point in time. However, only one version can be applied. The applied version is
selected based on time, site, and quantity. The BOM version is useful in these
cases.
• Two products that consist of the same raw materials but different
production processes will be able to use the same BOM but different
routes. For example, the same product is produced in two different
sites by using different equipment.
• When changing the raw materials of a product over time, different
BOMs can be attached as of a specific date. In the example of the
personalized coffee mug, the paint that is used for the mug was
originally paint X, and now they are going to use paint Y to make the
mugs. This change can be reflected in a new BOM version as of the
date that the change occurs.
BOM Configuration
For planning, calculation, and consumption purposes, each BOM line must
specify whether the item has any configurations. A configuration is a standard
component combination, such as a satellite speaker and a sub-woofer that can be
specified for a BOM item during the ordering process. For example, the user
might select the size and color of speaker to be included in the home theater
system.
A finished product can be set up so that parts of the finished good can be
produced at different production sites. A typical scenario for production at
multiple sites might involve an end item that includes component items, where
the component items are produced at and moved between different sites, and the
sites share common item numbers. Each BOM version can be linked to a specific
site, or each line of BOM can have a different site assigned.
10-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
BOM Levels
BOMs can contain many levels of goods to produce. A simple BOM is all on
level one. For example, when assembling a cabinet, you will have the frame,
shelves, and hardware. These are all on the same level, because each primary
component is in the assembly.
The lines in the BOM are the individual items or services that make up the BOM.
Each product has its own BOM line. An unlimited number of lines or items can
make up the BOM.
10-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
BOM Costing
Bills of material calculations use data from several sources to calculate the
rolled-up or total costs of a manufactured item. The sources include information
about items routing details, indirect cost calculation formulas, and the costing
version. The purchased item information that is used in a standard cost BOM
calculation includes cost, cost group, and warning conditions.
The bill of material information that is used in a standard cost BOM calculation
depends on the following.
• BOM version
• BOM line item quantity
• BOM line item scrap
• BOM line item valid dates
• The default order type of the BOM line item
• Parameters for the cost calculation
• Sub-route for a manufactured component
• Effect of operation scrap percentages
10-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
The following figure shows the relationship between the BOMTable, BOM and
BOMVersion. These do not include all the available fields for the tables, because
of size limitations and relevance.
The BOMTable is the primary table of the construct. Contained within is the
setup for a Bill of Material, including Approved, BOMId, Name, Version, and
SiteId. This is best described as the header information that you must define for
the BOM. For example this is an Eight inch woofer speaker assembly.
The BOM is the line items associated with the primary table. You can have many
line items that are related to each BOMTable. Each BOM record is related to one
InventTable record to create the link for the components to the raw materials
items and services. For example, the woofer speaker assembly might include the
speakers, cabinet, and cross over assembly needed to construct the speaker. For
the speaker assemblies, they can be used for other cabinets or other
configurations.
The BOMVersion is the final table needed for the basic BOM set up. The
relationship between the BOMTable and BOMVersion is one or more versions
for each BOM. Each BOMVersion record is related to one InventTable record to
create the link to the finished product item number. For example, one version
could be used for one site and a different version for another site. Frequently
BOMs are phased out, with new components that are included in the latest
version.
10-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The ProdBOM table is used to store the production ready, approved BOM. It is
copied from the original BOMTable (header) and BOM (lines) tables. This
follows the goods being produced throughout the life cycle of the product. This
design allows users to modify the BOM for a specific production order without
affecting the original BOM definition. Frequently it is referred to as the product
revision. From this all items or services are picked, assembled, quality assured,
reported as finished, and ended.
Routes
Routes are the path or sequence that the product takes from operation to
operation, starting with the beginning of the production process and continuing to
the end. It is a set of sequential operations, or tasks, that are required to produce a
product. The route operations describe the requirements for the resources that are
required for performing each operation. Each route includes the following:
• Operations to be performed.
• Operations relations.
• Sequence of the operations.
• Resources requirements involved in completing the operations.
• Standard times for the set up and run of the production.
One or more routes can be mapped for each product, depending on the product
and the process. You can create a completely new route, or you can base a new
route on existing route information, and then adjust or update the information to
match the new production process. The same route can also be used for multiple
products.
In the following section, you will review how to use routes and operations and
the data model associated with them.
10-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Operation Relations
Sequence of Operations
Operations in a route must be attached to each other in a logical way to reflect the
production process. Depending on the complexity of the production, this can
result in a route network. For simple routes, where the operations are executed
one after the other, a route network is not required.
10-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
10-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Also important for this model, is the relationship between Routes, ReqRoute, and
ProdRoute tables. For example, a regular route includes how the task or activity
is completed, the order and operation priority, and the requirements for the
resources that will perform them. The ReqRoute table is primarily populated
during master planning to record which operations are used for a production
order, and when the planned order is firmed. This data is then combined with the
operation relation to make up the production route in the ProdRoute table. This
makes sure that the route does not change mid-process and still allows planners
and schedulers to be able to update the Route table. The route on a specific
production order can be modified; much like a BOM can be, without affecting
the original route.
Production Orders
The production order contains information about what is to be produced, how
much (quantity), and the planned finish date. The system assigns an order status
to each step in the life cycle of the order. The status shows where the item is in
the production process.
10-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
If the vendor's capacity is not scheduled, do not attach the route for the sub-
BOM. When no route is attached, the delivery time for the sub-BOM is taken
from the component items released products' base data.
If you want to schedule the vendor's capacity, create the route for the component
item and specify Vendor as the resource on the appropriate lines.
10-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
The first status of a production order is Created. When a production order has
this status, you can edit the production's BOM and route. However, changes to
the production's BOM or routes when it has any status other than Created, require
that the previous update jobs be run again. For example, if you make changes in a
BOM or route for a production in which the status is Released, then the prior
steps Estimated and Scheduled must be run again. Not all steps are required for a
production order. The steps that are required are based on the configuration of the
Production control parameters.
The following topics provide a review of the production control steps, with an
emphasis on how each step applies to financial journals and the interaction with
the general ledger.
Step 1 – Created
When you create production orders, you can specify the settings that determine
how production order transactions are posted to the ledger. These settings apply
to production orders created manually or automatically from a sales order or
master planning schedule.
Step 2 – Estimated
This step involves the calculation of the most likely material and labor for the
production. The system creates inventory transactions that are issue transactions
for raw materials with the status of On order and receipt transactions for the
BOM with the status of Ordered. In some cases, the system will create purchase
orders and subproductions for the production order. Items are reserved and the
prices of the finished goods are calculated based on parameter settings.
Step 3 – Scheduled
The third step in the production order life cycle is Scheduled. Production orders
can be scheduled based on operations scheduling or job scheduling.
Step 4 – Released
In this step, the system releases the production order when the schedule is
realistic. At this point, you can print production order documents such as the job
card and the route card. Now, the status of the production order changes to
Released and indicates that the production can start.
10-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Step 5 – Started
When a production order is started, you can post costs against the order. You can
automatically allocate estimated material and route costs to the order when it is
started. This allocation is known as forward flushing or auto consumption. You
can manually allocate material to the order by creating picking list journals. You
can also manually allocate labor and other route costs to the order. If you use
operations scheduling, you can allocate these costs by creating a route card
journal. If you use job scheduling, you can allocate these costs by creating a job
card journal.
When the production order is reported as finished, the quantity of finished goods
completed is updated in the Inventory and warehouse management module. If
you use work-in-process (WIP) accounting, the system uses the standard cost
from the On-hand form to create a ledger journal to reduce the WIP accounts
and increase the inventory of the finished goods.
If the material and labor costs associated with the production are not already
allocated in a journal or by forward flushing, they can be automatically allocated
by back-flushing. This involves the post-deducting of inventory transactions
processes.
Step 7 – Ended
Before you end production, the system calculates the actual costs for the
produced quantity and all estimated costs of material, labor, and overhead are
reversed and replaced with the actual costs. If you select the End job check box
when you run the cost calculation, the production order status changes to Ended.
This status prevents any additional costs from being unintentionally posted to a
completed production order.
10-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
The ProdTable is the primary production order table, which contains the header
information about all of the production orders. Each production order contains is
related to at least one InventTransOrigin and InventTrans table record. Each
production order can be connected to a planned production order, a sales order or
a project.
When a production order is created from master planning, the planned production
order is stored in the ReqPO table. The ProdTableProj table contains information
about production orders that belong to projects. Such a production order is
connected to a real production order stored in the ProdTable table and to a project
stored in the ProjTable table.
10-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Production journals are located by opening Production control > Common >
Production orders > All production orders. Click the View tab in the Action
Pane, and then you can view the journal types in the Journals group. The
production journal types include the following.
Production journals consist of two main parts—the journal header and the journal
lines, or actual journal records. Journal lines reflect the actual records or entries
present in the journal. These records can include a list of production materials
ready for release, the time consumed, the number of good and defective items,
and so on.
ProdMulti
You can update production orders one at a time or update multiple orders one
time. You can use the RunBaseMultiParm structure to run different parameter
(parm) tables that use the same structure. The ProdMulti class is the base class
that you can use to update production orders. It is based on the
RunBaseMultiParm class. A user interface (UI) should be implemented for
derived classes.
10-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Syntax:
From the base UI form, it makes a call to ProdMulti for all updates. For example,
updating to Estimated calls ProdMultiCostEstimation::main().
if (_args.parmEnum() == RunChoose::Run)
{
prodMultiCostEstimation =
ProdMultiCostEstimation::construct(_args);
RunBaseMultiParm::initFromForm(prodMultiCostEstimation,_arg
s);
if (! prodMultiCostEstimation.prompt())
return;
prodMultiCostEstimation.runOnServer();
prodMultiCostEstimation.refreshCaller(_args);
}
else
{
RunBaseMultiParm::runSpecial(_args);
}
/// <summary>
/// Initializes an instance of the <c>RunBaseMultiParm</c>
class by using a container of packed records.
/// </summary>
/// <param name="_includeRecords">
/// A Boolean parameter that indicates whether records are
included.
/// </param>
10-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
container _packedRecords)
{
Common common;
int recordCounter;
ParmBuffer parmBuffer;
if (_includeRecords)
{
parmBuffer = this.defaultParmBuffer();
parmBuffer.Linenum = 0;
All selected records in the form data source are added to the appropriate parm
table. If the update is called from the main menu, there is no data source and no
records are found.
10-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
if (_args.parmEnum() == RunChoose::Run)
{
prodMultiCostEstimation =
ProdMultiCostEstimation::construct(_args);
RunBaseMultiParm::initFromForm(prodMultiCostEstimation,_arg
s);
if (! prodMultiCostEstimation.prompt())
return;
prodMultiCostEstimation.runOnServer();
prodMultiCostEstimation.refreshCaller(_args);
}
else
{
RunBaseMultiParm::runSpecial(_args);
}
The prompt displays the form where the user can change the settings to update
the order. There is also a Select button on the form that the user can click to
modify the query and select more records. When the form is opened from the
main menu (Production control > Periodic > Production orders), the query is
empty and the user must click this button to select the records for update.
...
while (curParmCostEstimation)
{
try
{
prodTable =
this.initProdTable(curParmCostEstimation.ProdId);
prodTable.status().runCostEstimation(curParmCostEstimation,
false,prodPurch,this);
}
catch (Exception::Deadlock)
{
retry;
}
...
10-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
next curParmCostEstimation;
}
}
All records in the parm table are looped over. The ProdStatusType sub-class is
instantiated by using the status of the prodTable record, then the update is called.
ProdStatusType
Production order updates are controlled by using the ProdStatusType class and
subclasses.
Each stage of the update process must occur. If the current status of an order is
Estimated, and you try to update it to Report as Finished, then it must be
Scheduled, Released, and Started before it can be reported as Finished. The
required status and status sequences are configured in the Production control
parameters form.
Before each update is run, the system checks to determine whether the previous
status is already processed. If the update is not installed, then the system runs that
update. It also handles which updates can occur with a production order. For
example, a production order with the status Finished, cannot be Estimated.
1. View ProdMultiReportFinish.Run().
...
while (prodParmReportFinished)
{
try
{
this.initProdTable(prodParmReportFinished.ProdId).status().
runReportFinished(prodParmReportFinished,false,this);
}
catch (Exception::Deadlock)
{
retry;
}
...
next prodParmReportFinished;
}
}
10-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
2. View ProdStatusType.runReportFinished().
...
if (!_ask)
{
if
(this.shouldRunPreviousJob(ProdStatus::ReportedFinished))
{
ProdUpdReportFinished::runPreviousJob(
_prodParmReportFinished,
_multi);
}
prodTable.type().runReportFinished(
_prodParmReportFinished,
_multi);
}
return true;
...
ask is set to true only when the method is called to ask whether the update is
allowed, not to run the update.
3. View ProdUpdReportFinished::RunPreviousJob.
prodParmStartUp.insert();
ProdTable::find(prodParmStartUp.ProdId).status().runStartUp
(
prodParmStartUp,
10-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
false,
null,
_multi);
}
if (!_ask)
{
if (this.shouldRunPreviousJob(ProdStatus::StartedUp))
{
ProdUpdStartUp::runPreviousJob(
_prodParmStartUp,
_prodPurch,
_multi);
}
prodTable.type().runStartUp(
_prodParmStartUp,
_multi);
}
return true;
Because the previous status to Started is released, and because this order is
already released, it is not necessary to run the previous job.
10-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
ProdUpd
The ProdUpd class is the base class of production classes used to update the
production order status. The following figure shows the class hierarchy for the
ProdUpd class.
The ProdUpd class is an abstract class, and you cannot make an instance out of it.
You can only inherit this class from other production update classes. To update
production order stage, the following classes are used:
• ProdUpdBOMCalc
• ProdUpdCostEstimation
• ProdUpdScheduling
o ProdUpdScheduling_Operation
o ProdUpdScheduling_Job
• ProdUpdRelease
• ProdUpdStartUp
• ProdUpdReportFinished
• ProdUpdHistoricalCost
• ProdUpdStatusDecrease
o ProdUpdStatusDecrease_CostEstimate
o ProdUpdStatusDecrease_Finished
o ProdUpdStatusDecrease_Release
o ProdUpdStatusDecrease_Schedule
o ProdUpdStatusDecrease_StartUp
10-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When a production order is updated, there are two main events that can occur.
void run()
{
#OCCRetryCount
RecordViewCache viewCacheProdRoute;
setprefix(ProdMultiStartUp::description());
setprefix(#PreFixField(ProdParmStartUp,ProdId));
try
{
ttsbegin;
this.setParameters();
if (! this.validate())
{
throw Exception::Error;
}
viewCacheProdRoute = null;
viewCacheProdRoute =
ProdRoute::viewCacheProdId(prodTable.ProdId,true);
this.updateProduction();
this.updateBOMConsumption();
prodTable.status().startUpUpdateRouteJobs(this);
this.updateRouteConsumption();
this.startupReferences();
this.updateJobJournal(ParmJobStatus::Executed);
TransactionLog::create(TransactionLogType::ProdStartUp,
strfmt("@SYS76498",
10-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
prodTable.ProdId,
"@SYS77138"));
ttscommit;
this.printout();
}
...
void updateProduction()
{
if (prodParmStartUp.StartUpProduction)
{
prodTable.QtyStUp += prodParmStartUp.StartUpQty;
}
prodTable.ProdStatus =
prodTable.status().isBefore(ProdStatus::StartedUp) ?
ProdStatus::StartedUp : prodTable.ProdStatus;
prodTable.StUpDate = prodParmStartUp.PostDate ?
prodParmStartUp.PostDate : systemdateget();
prodTable.update();
this.addUpdateRec(prodTable);
}
5. The production route is updated and the route journal is created and posted.
(This sample comes from the ProdUpdStartUp.run method reviewed earlier.)
this.startupReferences();
this.updateJobJournal(ParmJobStatus::Executed);
TransactionLog::create(TransactionLogType::ProdStartUp,
strfmt("@SYS76498", prodTable.ProdId, "@SYS77138"));
ttscommit;
10-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Any references (meaning production orders that are created because of this
production order) are also updated, and the parm table record is updated to show
it is posted.
Scheduling
Scheduling is an iterative activity where the system tries to find a set of resources
that can deliver the product on or before the requested date. In the following
sections, you will review the main production scheduling concepts that provide
an overview of scheduling, resources, the resources data model, and jobs.
Scheduling Overview
The scheduling engine is aligned with the new resource model in Microsoft
Dynamics AX 2012. This introduces capabilities and priorities, and replaces
work centers and work center groups by using resources and resource groups.
You can run scheduling after the production order is created and estimated.
Production dates and other information important to the production process are
established at this point. The role of the scheduling system is to plan the actual
production process so that each operation in the production route is assigned a
starting and ending date and time, and that the materials needed for production
are available when the operation starts.
Another important role of the scheduling system is to assign jobs and operations
to a resource or resource groups. This depends on whether job scheduling or
operation scheduling is used. Running scheduling raises the production status to
Scheduled.
Resources Overview
Microsoft Dynamics AX 2012 introduces resources that are assigned to jobs and
operations. Resources can be different types including machines, tools, human
resources, vendors or locations. The scheduling engine aligns with the new
resource model and can schedule resources based on their capabilities. Resources
and capabilities replace work centers and task groups to provide for more
flexibility in setup and maintenance. In Microsoft Dynamics AX 2012, resources
can be allocated to jobs and operations by matching the capabilities of the
resources with the requirements of the operation.
Alternative resources with the same capabilities are considered, unless there are
requirements for a specific resource or resource group. This applies whether you
select to run job scheduling or operations scheduling. The selection process
consists of matching the requirements of the operation with the capabilities of the
resources. Other requirements, such as location, resource working time, and
resource type are also considered when planning the production. Microsoft
Dynamics AX 2012 has changed the following to the Operations Resource
Model.
10-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
• Separated the way resources are grouped for managing capacity from
the way resource requirements are specified for activities.
• Enabled resources to change resource groups and thereby location
(Site) over time.
• Eliminated the need for defining resources multiple times.
In the following section, you will review resources and recourse capabilities.
Resources
Resources are used throughout the production or project processes. They can be
machines, tools, people, vendors or locations that contribute to the production of
an item. After an operations resource is created, you can assign it to a resource
group and specific productions.
Resource groups have fixed location. You can move resources to another location
by reassigning them to a different resource group. However, a resource can only
be assigned to one resource group at a time. The Effective and Expiration date
fields on the Resource groups tab represent when the resource in question can
be used for production.
With this setup you can share a resource across many sites. When a resource
becomes a member of the resource group that has a different location, it
represents the physical move from one site to another. You can also copy
resources to make the setup of resources easier.
10-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Resource Capabilities
When designing a route, the requirements that resources must have to perform
the various operations in the route can be expressed as the set of resource
requirements. This allows the allocation of resources to be deferred until
production is scheduled.
You can define capabilities to organize the resources for your operation.
Resource planning and production scheduling depend on correctly defined
capabilities because the requirements of a production are matched with the
capabilities of a resource.
For example, a sheet metal press may have the “Aluminum sheet press”
capability assigned and have a grade of 50, whereas an older sheet metal press
would have the same capability assigned, but the older sheet metal press can only
manage a grade of 30.
EXAMPLE:
On a route, the drilling process time is set to 10 units per hour, but the
requirement itself is defined as “Drilling”.
M1 can drill two units per hour and M2 can drill 11 units per hour.
Both machines can be picked up by the scheduling engine because both satisfy
the requirement: “Drilling”. However, the M1 machine can only drill two units
per hour, far less than the 10 units per hour specified on the route. This will
cause production problems. To resolve this, two separate capabilities should be
created: “Low-speed drilling” and “High speed drilling”. “Low-speed drilling”
is defined by a drilling process time of one to nine units per hour. “High speed
drilling” is defined by a drilling process time of 10 to 19 units per hour.
10-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
In this setup, the M1 machine is given the “Low-speed drilling“ capability and
the M2 machine has the “High-speed drilling” capability. The scheduling engine
will then select the correct machine (M2).
Resource Requirements
When defining the requirements for a production route, you can also specify
skills, courses, certifications or title as requirements in addition to capabilities.
This does not require a relation to a worker. These values are set up in the
Human resource module and are not defined in the Capabilities form. When
defining skills, courses, certifications or title as requirements, you must have the
Human resources module enabled. You can define capabilities in the
Capabilities form that resemble or duplicate those from the Human resources
module. However, the Capabilities form does not contain the functionality that
is required to maintain skills, courses, certifications or titles.
• Skills: You can use the Skills form to create and manage
competencies that are specified for employees or jobs. An operation
can require a human resource with a specific skill, and the
scheduling engine will find resources with the specific skills. It does
this by searching for the skill information on the worker to which the
resource is linked. This is only applicable for job scheduling, and not
operation scheduling.
• Courses: You can create and maintain the courses your employees
have attended. An operation can require a human resource with a
specific course, and the scheduling engine can find resources with
specific courses. It does this by searching for the course information
on the worker to which the resource is linked. This is only applicable
for job scheduling.
• Certificate: You can add certificates to a user in human resources
and use this to track all employee certificates. An operation can
require a human resource with a specific certificate, and the
scheduling engine can find resources with specific certificates. It
does this by searching for the certificate information on the worker to
which the resource is linked. This is only applicable for job
scheduling.
• Title: The title an employee has can also be a requirement for a job.
An operation can require a human resource with a specific title, and
the scheduling engine can find resources with specific titles. It does
this by searching for the title information on the worker to which the
resource is linked. This is only applicable for job scheduling.
10-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To make sure the system can be easily upgraded from earlier versions, the table
names have not changed. For example, ResourcesTable continues to be called
WrkCtrTable in the physical data model, with the changes in the content of the
table, and in many new relationships.
An example of the new relationship model is the work center resource group,
represented by the WrkCtrResourceGroup table. Now through the association
with the Resource Calendar, WorkCalendarTable (new), and
WrkCtrResourceGroupResource, any resources can have scheduled working
times based on the calendar that is attached to a specific resource. Now the model
can support equipment downtime, swap outs, and upgrades. Additionally, it also
incorporates a more realistic model of human resource management where
workers and other personnel are not available continuously.
10-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Jobs Overview
Scheduling types differ from one another as measured by detail. Operations
scheduling is limited to scheduling by date (while calculating the duration of the
individual operation), whereas job scheduling calculates the starting and ending
times of individual operations throughout the day. Additionally, there is a
significant difference in the way operations are planned and in how scheduling is
performed in resource groups. Job scheduling splits the different operations into
jobs, and they are planned in detail, for each of the operation resources. When
allocating resources to an operation, the system examines the following resource
requirements types.
• Specific resource
• Specific resource group
• Resource type
• Capability
• Skill
• Course
• Certificate
• Title
10-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When the requirements are not met by the current inventory, a planned
production order can be issued that specifies what is needed and when. Then the
planner knows what is missing and he or she can make decisions about how to
meet these requirements.
NOTE: Master planning can generate several types of planned orders such as
planned transfer, planned purchases, or kanbans, not just planned production
orders.
The following figure shows the steps for the Master planning module that must
be completed to run and generate the planned production orders.
10-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
LEAN Manufacturing
Lean manufacturing is a both a process philosophy and workable process
methodology. It introduces best practice material handling and best in class
manufacturing methods that are now standard across industries. The core
concepts for lean manufacturing provide a base level understanding of the system
functionality within Microsoft Dynamics AX 2012.
In the following section, you will review the Lean production principles, the
overview and rules for Kanban, and production flow processes.
• Customer Value: When you identify the value, you specify what
creates value from the customer's perspective.
• Identify the Value Stream: The Value Stream is the sequence of
processes that start from the raw material to the final customer or
from the product concept to the market launch. If it is possible, view
the whole supply chain.
• Flow: Create flow wherever possible in the process. Use one piece of
the flow by linking all the activities and processes into the most
efficient combinations to maximize value-added content while
minimizing waste.
• Pull: Make only what is needed by the customer (short term response
to the customer’s rate of demand).
• Perfection: In striving for perfection, Lean is a journey of
continuous improvement. The goal is to economically produce
exactly what the customer wants, and exactly when the customer
wants it. Because perfection is an aspiration, anything and everything
can be improved.
Kanban Overview
In Microsoft Dynamics AX 2012, the Lean manufacturing module introduces
kanbans as a pull-based just-in-time production system. Kanbans relate to a
sequence of kanban jobs. Each kanban job has a status that indicates its current
stage in the production or transfer process. Each kanban also has a status, the so-
called handling unit status that indicates the overall state of a kanban and the
related handling unit.
10-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
• Withdrawal kanbans
• Manufacturing kanbans
• Process jobs
• Transfer jobs
10-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
A Kanban with the type “withdrawal” creates a transfer job that is based on a
single transfer activity. Withdrawal Kanbans are used to move a Kanban of a
specific item between supermarkets, warehouses, and production locations.
Withdrawal Kanbans do not add value.
A fixed quantity Kanban rule relates to a fixed number of bins or Kanban cards.
This means that the number of active Kanbans is constant. When a material
handling unit related to a Kanban is consumed (emptied), a new Kanban of the
same type is recreated. Fixed quantity Kanbans are frequently used with fixed
circulating cards, but can also be used with single use cards. When circulating
cards are used, the card is detached from the consumed Kanban and assigned to
the newly created Kanban.
Scheduled Kanbans
10-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Event Kanbans
Event Kanbans are only created out of the related demand so that those event
Kanbans belong to the category “make-to-order.” The creation of event Kanbans
is initiated when certain events occur. In Microsoft Dynamics AX 2012, these
events include when you create sales lines, estimate production orders based on
the creation of upper level Kanban demand, or when you reach a certain level of
on hand inventory.
Production Flow
Typically, a Lean manufacturing scenario is more than an accumulation of
unrelated Kanban rules or material supply policies. The flow of material and
products throughout work cells and locations for a specific production or supply
scenario is described as a sequence or small network of process or transfer
activities, which is known as a production flow.
Production flows are the backbone of Lean manufacturing, and they perform the
following functions.
10-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
• Unique name
• Description
• Legal entity that owns the operations in the production flow
• Operating unit of type value stream
• A production group.
NOTE: The production group defines the set of accounts that are used for the
financial postings that are related to the production flow. The most important
accounts are the WIP and Offset accounts. These are the basis of the variance
calculation for the production flow.
The setting of the financial dimension for the production flow is optional.
TIP: For more information about lean manufacturing, refer to the following two
whitepapers.
Additionally, you can refer to the Lean Manufacturing for Microsoft Dynamics
AX 2012 course.
Process Industries
Process Manufacturing for Microsoft Dynamics AX 2012 supports a range of
manufacturing processes. This includes make to order, make to stock, and mixed
mode. Mixed mode is a hybrid environment that enables discrete, lean, and
process requirements to coexist. You can integrate production processes to build
a flexible solution that meets your needs.
Overview
Process industry requirements are reflected in the following Microsoft Dynamics
AX 2012 functionalities.
10-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Some features can be used with any license of Microsoft Dynamics AX2012,
while other features can be used only with a Process Manufacturing installation.
If your organization wants to use the Process Manufacturing solution, you must
implement one or both of the Process Manufacturing installations.
10-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Scenario
Victor, the Business Systems Developer, is tasked to add a BOM line item field
to both the BOM and ProdBOM tables. Specifically, the Finance team wants a
new check box called "IsReturnable" to represent if the item or good is
returnable. The objective is to make sure that if the BOM is canceled before the
actual production, the Logistics group is aware they can receive a refund for the
unused goods that are planned for on the BOM, or picked for the ProdBOM.
Challenge Yourself!
Use the following tables, maps, and forms to create a new field for Victor to
track returnable items at the BOM line level.
• BOM table
• ProdBOM table
• ProdBOM form
• BOMConsistOf form
• BOMMap
10-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Step by Step
4. Save the extended data type. If you are prompted to synchronize the
database, select Yes.
5. Create a project (View > Project or Ctrl+Shift+P ).
6. Right-click the Shared space, New > Project.
7. Name the project.
8. Open the project.
9. Drag the new IsReturnable extended data type to the project.
10. Find the BOM table in the AOT.
11. Drag BOM table to the project.
12. Expand to the Fields node.
13. Find the ProdBOM table in the AOT.
14. Drag the ProdBOM table to the project.
15. Expand the Fields node.
16. Right-click IsReturnable(usr) and select Open New Window.
17. From the new window drag IsReturnable to the BOM fields and the
ProdBOM tables.
18. Close the AOT window with the IsReturn(usr) extended data type.
19. Save the project.
20. In the AOT window, expand the Forms node and locate
BOMConsistOf and ProdBom.
21. Drag the forms to the project.
22. Right-click the project and select Restore.
23. Expand the BOMConsistOf form to Data Sources > BOM > Fields
> IsReturnable, and then right-click and select Open New Window.
24. Expand the BOMConsistOf form to Designs > Design >
[Group:GroupBOM] > [Tab:Tab] > [TabPage:Overview] >
[Grid:GridBOM].
25. Drag IsReturnable to the [Grid:GridBOM].
10-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
31. In the AOT window, open Data Dictionary > Maps > BOMMap
and drag it to the project.
32. Expand BOMMap > Fields.
33. Right-click IsReturnable and select Open New Window.
34. Drag it to the BOMMap fields’ node.
35. Right-click BOMMap and select Restore.
36. Expand BOMMap > Mappings > BOM.
37. Map IsReturnable to IsReturnable in the Properties form.
38. Expand BOMMap > Mappings > ProdBOM.
39. Map IsReturnable to IsReturnable in the Properties form.
40. Save and compile the project.
41. Test and validate the Production order form.
a. In Microsoft Dynamics AX 2012, open Production Control >
Common > Production Orders > All production orders.
b. Click Production order in the New group of the Action Pane.
c. Select item number 11001 HomeTheaterSystem7.1High Perf.
d. Click Create.
e. Double-click the newly created production order.
42. Click the BOM in the Production details group of the Action Pane.
In the BOM form, verify that the Is returnable field is selected for
item number 1101.
10-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Summary
A bill of material is a complete list of all the components, parts, raw materials,
assemblies and their quantities that are required to make a finished product. The
BOM Version identifies which BOM to use for producing an item under specific
circumstances.
Routes and operations are the path that the item takes from operation to
operation, starting with the beginning of the production process and continuing to
the end. It is a set of sequential operations, or tasks, that are required to produce
an item.
Planned production orders are created by master planning when requirements are
not met by current inventory. A planned production order is issued that specifies
what is needed and when. Then the planner knows what is missing and he or she
can make decisions about how to meet these requirements. This interacts with the
journals for each step for both real time information and auditing purposes.
10-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
1. Which of the following are items that are found on a BOM? (Select all that
apply)
( ) Components
( ) Parts
( ) Assemblies
( ) Raw materials
4. Which of the follow is true about Production Orders? Select all that apply.
( ) Meeting sales demand when inventory is insufficient
( ) Creating safety stock based on possible demand
( ) Developing templates for receiving control
( ) Supply the BOM as sub-assemblies to other items in demand
10-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
10-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 10: Use and Design of the Production Control Module
Solutions
Test Your Knowledge
1. Which of the following are items that are found on a BOM? (Select all that
apply)
(√) Components
(√) Parts
(√) Assemblies
(√) Raw materials
4. Which of the follow is true about Production Orders? Select all that apply.
(√) Meeting sales demand when inventory is insufficient
(√) Creating safety stock based on possible demand
( ) Developing templates for receiving control
(√) Supply the BOM as sub-assemblies to other items in demand
10-45
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
10-46
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
Introduction
Workflow in Microsoft Dynamics AX 2012 uses a combination of Application
Object Tree (AOT) elements created by the developer and additional set up that
is completed by the end-user to control the configuration and process a workflow
will follow.
11-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Line-Item Workflows
Workflows act on business documents. Sometimes patterns exist where there is a
relationship between two tables―one is a header table; for example, Expense
header, and the other is a line-item table. The line-item table contains records that
relate to the header, for example, an expense report has many expense lines.
NOTE: Some tables are enabled for line-item workflows out of the box, such as
purchase requisitions and expense reports.
1. Identify the header and line table that have to be workflow enabled,
and then make sure that there is a table relationship between them.
a. Open the AOT and browse to Data Dictionary > Tables.
b. Select the line-item table and then expand the Relations node.
c. Verify that a relation exists back to the header table.
2. Assuming that a workflow already exists for the header table, create
a new line-item workflow under the Line-item workflow node of
the header workflow.
3. Set the properties of the new line-item workflow including the
relation, event handlers, and menu items as needed.
4. Optionally, you can set the EnableLineItemWaitSelection to Yes if
you want to give the business user access to choose whether the line-
item workflow element should be wait for all line-item workflows to
complete before you move on to the next element.
11-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
Now, the business user can create a new workflow on the line-item table by using
the line-item workflow type, then create a new workflow on the header table by
using the header workflow type, and then configure the line-item workflow
element in the header workflow by selecting the line-item workflow he or she
just created.
TIP: You can review the Purchase requisition review workflow to see how steps
2, 3 and 4 are implemented for this workflow. (Open AOT > Workflow >
Workflow Types > PurchReqReview.)
NOTE: Before you can begin this demonstration, you must create a duplicate of
the PurchOrderHeaderTemplate.
11-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Workflow Providers
Workflow providers in Microsoft Dynamics AX provide application specific data
for a workflow at run time. The application data provided can include the
following:
11-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
There are several types of workflow providers that you can implement in
Microsoft Dynamics AX workflow.
Each task or workflow must have a due date provider defined to determine the
last date by which the workflow element can be compeleted. For example, the
maximum number of days to complete a task, or the maximum time permitted to
wait for an approval before automatic denial of the approval.
A provider is also used to select a user or group of users for the task or approval
step. For example, the participant provider could select a manager from a
manager's role to approve an expense report. In Microsoft Dynamics AX 2012
the providers for a workflow element are inferred. There are no special
parameters that must be set on the elements in the AOT to specify the type of
provider. Each workflow element can have many different types of providers
available. However, only one type of provider can be selected when configuring
a workflow element.
11-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The due date provider can use the company calendar defined in the Basic module
to resolve a time span for a task or approval into a date that takes nonworking
days into consideration. For example, the default due date provider can calculate
the correct date for an expense report approval that should be approved within 10
workdays. Any holidays or non-working days specified in the calendar setup in
the Organization administration module are calculated into the approval due
date.
• WorkflowDueDateProvider.getCalendarTokens
• WorkflowDueDateProvider.resolve
• WorkflowDueDateProvider.resolveNonUser
11-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
Participant Provider
You can use a participant provider to return a list of users from any abstraction,
such as a user group. Microsoft Dynamics AX workflow provides the
WorkflowUserGroupParticipantProvider class that returns a list of users
based on a Microsoft Dynamics AX user group.
• WorkflowParticipantProvider.getParticipantTokens
• WorkflowParticipantProvider.resolve
When you implement a customer provider, the participant token represents the
abstraction when you implement a different concept. For example, if you
implemented a new provider for commission groups, the IDs could represent the
commission group ID.
Queue Provider
You can use a queue provider to return a list work item queues that are
configured in the Home module. Microsoft Dynamics AX workflow provides the
WorkflowQueueProvider class that returns a list of work item queues.
• WorkflowParticipantProvider.getQueueTokens
• WorkflowParticipantProvider.queueIDToQueueName
• WorkflowParticipantProvider.queueNameToQueueID
• WorkflowParticipantProvider.resolve
11-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
You must complete the following high level steps to implement a new workflow
provider.
1. Create a "provider" class that contains the business logic for your
new provider.
2. Create a new provider under the appropriate Providers node in the
AOT, and then set the Name, Label, and HelpText properties.
3. Specify the AssociationType property. This defines the
organizational scope of the provider. For example, organization wide
versus company specific. This requires that the business logic be
written in such a way that it respects the value of this property.
4. Set the AvailableForAllWorkflowsTypes property.
a. If a new provider is implemented for a specific workflow, then
set this property to No. Next, create new workflow types for
each type that the provider can be used for under the Workflow
Types node. This limits the visibility and use of the provider in
to the selected workflows.
b. If a new provider is general purpose in nature and does not have
an affinity to a specific workflow, then set this property to Yes
and it will be available throughout Microsoft Dynamics AX.
11-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
5. Right-click in the Code Editor window, click New, and then enter
the following code for the getParticipantTokens method.
return userGroups;
}
6. Right-click in the Code Editor window, click New, and then enter
the following code for the resolve method.
{
userList.add(userGroupList.UserId);
}
11-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
return userList;
}
7. Close the Code Editor window and then click Yes to save the
changes.
Developer Actions
The developer must complete the following high level steps to enable queues for
a document.
11-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
5. Bind the queries to the menu items for each list page. For example,
refer to the PurchReqwAllMyReports and
PurchReqMyDirectReports Display Menu Items for an example
of how this is achieved.
[
WorkflowDocIsQueueEnabledAttribute(true, "@SYS317210"),
ExpressionCurrencyFieldMapAttribute(methodstr(TrvWorkflowEx
pHeader, parmTotalExpenseAmount),
methodstr(TrvWorkflowExpHeader,
parmAccountingCurrencyCode)),
ExpressionCurrencyLEAttribute(tableStr(TrvExpTable),
fieldStr(TrvExpTable, LegalEntity)),
ExpressionCurrencyLEAttribute(tableStr(TrvExpTrans),
fieldStr(TrvExpTrans, LegalEntity)),
ExpressionCurrExchRateDateAttribute(tableStr(TrvExpTrans),
fieldStr(TrvExpTrans, TransDate))
]
class TrvWorkflowExpHeader extends WorkflowDocument
{
}
11-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. Right-click the Classes node in the AOT, and then select New Class.
2. Right-click the newly created class and select View Code.
3. In the classDeclaration, create a name the class
<Workflow>DocumentQueuedTaskEventHandler where
<Workflow> is the name of the document that you are enabling
workflow for.
4. Make sure that the class extends
WorkflowQueueCreatedEventHandler, and then save the class.
5. Right-click the new class in the AOT, and then select Override
method and select mapFields.
a. Declare the Workflow macro.
b. Declare the table that stores the data for your document.
c. Declare the WorkflowDocIsQueueEnabledAttribute.
d. Declare the DictClass.
e. Set the DictClass equal to the class that is used for your
document workflow.
f. Set the WorkflowDocIsQueueEnabledAttribute variable that you
created in step 5.c. equal to the WorkflowDocumentAttribute in
the Workflow macro.
g. Set the document table variable created in step 5.b. to the record
that is currently selected.
h. Set the parameters in the WorkflowQueueCreatedEventHandler
class equal to the fields from the table fields in the document
table that you declared in step 5.b.
TrvExpTable trvExpTable;
WorkflowDocIsQueueEnabledAttribute attribute;
DictClass dictClass;
dictClass = new
11-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
DictClass(classNum(TrvWorkflowExpHeader));
attribute =
dictClass.getAttribute(#WorkflowDocumentAttribute);
trvExpTable =
TrvExpTable::findRecId(this.parmWorkflowWorkitemTable().Ref
RecId);
this.parmDocumentId(trvExpTable.ExpNumber);
this.parmDocumentType(attribute.parmFriendlyName());
this.parmCompanyInfo(trvExpTable.company());
}
1. In the AOT, expand the Workflow node, and then expand the Tasks
node.
2. Select the task that you want to allow work item queues for, or if it
does not exist, create a new task and set the properties as required.
3. Right-click the task and select Properties.
4. Set the WorkItemsCreatedEventHandler property to the event
handler class that you created in Demonstration: Create a Workflow
Queue Event Handler.
5. Save the Task.
NOTE: Queues are not supported for approval elements because the way users
interact with them is different than tasks.
11-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
To create a query that filters for work items that are assigned to the current users,
join the WorkflowWorkItemTable and add a range on the UserID field and set
the Value property to (UserID = currentUserID()). The following sample is
taken from the TrvExpTable_AssignedToMe query that controls the filter for the
Expense reports assigned to me form located in Travel and expense > Common
> Expenses > Expense reports assigned to me.
11-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
To create a query that filters for work items that are assigned to a queue the
current users belongs to, join the WorkflowWorkItemQueueAssignee table and
add a range on the UserID field and set the Value property to (UserID =
currentUserID()). The following sample is taken from the
TrvExpTable_AssignedToMyQueues query that controls the filter for the
Expense reports assigned to me form located in Travel and expense >
Common > Expenses > Expense reports assigned to my queues.
For other examples of queries and list pages that you can add to a document,
refer to the Purchase requisition list pages that are located in Procurement and
sourcing > Common > Purchase requisitions.
To create a menu item that is bound to your query, follow these steps.
11-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
7. In the Query property, specify the query that you created in the
Create a List Page Query for Queues demonstration.
8. Specify the other properties as required and then save the menu item.
When you are finished, drag the menu item into the menu where you want the list
page to appear.
• The currency code can be obtained for a field on the left side of the
condition that contains an amount.
• The end-user can select a currency code for an amount entered on the
right side of the condition.
• The left and right side of the condition can be converted into a
common currency so that they can be evaluated.
The most basic approach to implementing currency fields in the Condition Editor
is to set meta-data that will be used by the default currency provider. This meta-
data is then used by the Condition Editor together with a default currency
provider without any additional development. This is true only when the
currency code field is on the same table as the currency amount field. In all
other cases, coding is required to either extend the default currency provider
implementation or to implement a new currency provider that meets your
application needs.
1. Set the currency meta-data for the currency code field. Refer to the
Define Currency Meta Data procedure for more information.
2. Review the behavior of the ExpressionCurrencyDefaultProvider
class to determine whether the requirements are met.
3. If the ExpressionCurrencyDefaultProvider meets your requirements,
then no additional action is required.
11-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
When the SaveDataPerLegalEntity property is set to No, then the legal entity is
represented by a field other than the dataAreaID on the record. In this scenario
the developer must add an attribute to the workflow document class to identify
the table and field that stores the legal entity value.
[ExpressionCurrencyLEAttribute('<Query.DataSource.Name>','<
Field.Name>')]
When the currency to be used is not stored in same table or is calculated, you
must set the ExpressionCurrencyFieldMappingAttribute to be the field
(calculated or otherwise) from the workflow document that provides the currency
code. Use the following code sample to guide you.
11-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
[
ExpressionCurrencyProviderAttribute(classstr(<Your>Currency
Provider),
ExpressionCurrencyFieldMappingAttribute('parm<CalculatedFie
ld1>', '<Field in the document’s root table>'),
ExpressionCurrencyFieldMappingAttribute('parm<CalculatedFie
ld2>', 'parm<CalculatedField3 representing the currency
code>')
]
class <yourWorkflowDocumentClass> extends WorkflowDocument
{
...
}
IMPORTANT: A relation must be defined on the field that stores the currency
codes. This relation is used by the system to create a lookup for currency codes
in the Condition Editor. If a relation does not exist, the ellipses button will not
appear in the Condition Editor and the user cannot select the currency code from
a list.
NOTE: You can choose to skip steps 2 through 6 and just add the Amount or
AmountMST extended data types directly to your table.
7. In the AOT expand Data Dictionary, and the under the Tables node
select the table that you want to implement a currency for.
8. Drag the extended data type that you created in step 2 into the table.
9. Drag the CurrencyCode extended data type into the table.
10. Create other fields on the table as required.
11. Save the table.
12. Right-click the Relations node on the table and select New >
Relation.
13. Enter a Name for the relation such as Currency.
14. Select Currency in the Table property.
15. Set the other properties as required. Refer to the TrvExpTrans table
> Currency relation for an example of how to implement this.
11-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
16. Right-click the relation created in step 12, and then select New >
Normal.
17. In the Field property, select the field that you created in step 9.
18. Set the Related field property to the CurrencyCode field (which is
from the Currency table).
19. If required, specify the SourceEDT property as the extended data
type for the Field.
20. Save the table.
11-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
[ExpressionCurrencyProviderAttribute(classstr(<Your>Currenc
yProvider))]
class <YourWorkflowDocumentClass> extends WorkflowDocument
{
...
}
11-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
This class also includes a method which returns the spending limit for the
requester. This method also includes the currency for the spending limit so that a
currency conversion can be complete when this field is selected in the Condition
Editor.
After you have implemented the classes and methods with the correct attributes,
you can use the Condition Editor in the workflow type to select or compare
amounts with relation and accuracy for the currencies. The following figure
illustrates two samples of how these fields can be used.
In this example, the first condition is comparing the total expense report amount
to the requesters spending limit. For both fields, the currency code is passed in
automatically based on the record passed into the query. There is no need for the
user to select a currency code.
The second condition in this example is comparing the total expense report
amount to a fixed value of 10,000 United States dollars (USD). The user can
click the ellipsis button (...) to specify the currency for the value that is entered
into the right side of the condition. The currency code is still hidden on the left
side of the condition because it is being calculated by the system in the
parmAccountingCurrencyCode method.
11-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When a field that has a hierarchical data structure is presented in the Condition
Editor for workflow, the comparison function should include operators such as
"at or above", "above", "at", "below", and "at or below".
Now you are creating a new purchase requisition line-level workflow and want to
assign a task in the workflow based on the procurement category that is assigned
to each line of the purchase orders. When you add the procurement category field
to the left side of the condition, the operator for that condition can be set to "at or
below" which will include the brand selected on the right side of the condition
and all the types and categories that are below the brand selected.
The system uses the getLookup() method to display the hierarchy in the
condition, and then at run time the condition is evaluated by using the
getDistance() method.
Developer Actions
To implement a new field that supports hierarchies in the Condition Editor, the
developer must follow these steps.
11-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
2. Register the new class on the workflow document class that is used
by decorating the class with the following attribute:
[WorkflowHierarchyProviderAttribute
(classstr(MyHierarchyProviderImplementation), myTableId,
myFieldId)]
Developer Actions
To implement a new field that supports hierarchies in the Condition Editor, the
developer must follow these steps.
2. Register the new class on the workflow document class that is used
by decorating the class with the following attribute:
[WorkflowHierarchyProviderAttribute
(classstr(MyHierarchyProviderImplementation), myTableId,
myFieldId)]
11-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The parameters myTableId and myFieldId are needed to specify the table and
field within the data source for which this applies. At run time, when the
Condition Editor is invoked, and the hierarchy-enabled field is selected on the
left side of a condition, the Condition Editor will show a set of hierarchical
operators (at or above, above, at, below, at or below), and will enable a lookup on
the right side that allows the end-user to choose a node in the hierarchy to
compare the field on the left side against.
11-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
Scenario
Contoso uses Free Text Invoices to manage service agreements with many
customers. Currently, workflow is only supported on the header level of the
document. Kevin, the Sales Manager, wants the sales representatives to approve
the free text invoices that are created by the Accounting Department by using the
free text invoice recurring invoice batch job.
Because each line of the free text invoice might be routed to a different sales
representative or might require different levels of approvals, Kevin would like to
implement workflow for each line of the free text invoice.
Kevin has also specified that the new line-item workflow for free text invoices
should include an approval element and the line-item workflow should support
work item queues.
Challenge Yourself!
By using the information that is provided in the scenario, create a new workflow
type for free text invoice lines called
CustFreeTextInvoiceLineWorkflowTemplate that includes a new approval
element. Make sure that you create a new status field on the lines of the free text
invoice and that you enable work item queues for the free text invoice template.
When you are finished, add the new free text invoice line workflow into the
CustFreeTextInvoiceTemplate as a line-item workflow.
NOTE: There are no step by step instructions for completing this. For an
example of how this is implemented, refer to the Development III in Microsoft
Dynamics AX 2012 class for more information about how this would be
achieved.
11-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. In the AOT expand Data Dictionary > Tables, and then select the
CustInvoiceLine table.
2. Drag the CustInvoiceLine table into the WorkflowWorkshop
project.
3. Expand the CustInvoiceLine table and then right-click the Fields
node.
4. Select New > Enum.
5. In the Properties window for the new field, set the Name to
WorkflowStatus.
6. Set the Enum property to CustFreeInvoiceWFApprovalStatus.
11-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
1. In the AOT, right-click the Queries node and then select New
Query.
2. Select the new query that is created, and then in the Properties
window set the Name to CustFreeTextInvoiceLineDocument.
3. Expand the query node and then right-click the Data Sources node
and select New Data Source.
4. Set the Name property to CustInvoiceLine.
5. Set the Table property to CustInvoiceLine.
6. Expand the CustInvoiceLine data source and then right-click in the
Data Sources node and select New Data Source.
7. Set the Name property to CustInvoiceTable.
8. Set the Table property to CustInvoiceTable.
9. Set the Relations property to Yes.
10. Expand the CustInvoiceTable node.
11. Right-click the Fields node under CustInvoiceLines and set the
Dynamic property to Yes.
12. Right-click the Fields node under CustInvoiceTable and set the
Relations property to Yes.
13. Right-click the Fields node under CustInvoiceTable and set the
Dynamic property to Yes.
14. Save the project.
15. Drag the new query into the WorkflowWorkshopLab project.
11-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: The code samples for this lab can be found in the
AX2012_ENUS_DEVIV_11_01_LAB_CODE.txt file. You can copy and paste
these code samples into the correct methods.
custInvoiceLineRecId =
_workflowEventArgs.parmWorkflowContext().parmRecId();
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::Pending;
custInvoiceLine.update();
ttsCommit;
}
11-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
custInvoiceLineRecId =
_workflowEventArgs.parmWorkflowContext().parmRecId();
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::Cancellation;
custInvoiceLine.update();
ttsCommit;
}
custInvoiceLineRecId =
_workflowEventArgs.parmWorkflowContext().parmRecId();
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::Completed;
custInvoiceLine.update();
ttsCommit;
}
11-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
(workflowTypeName,
recId,
note,
NoYes::No);
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::Submitted;
// Send an Infolog message.
info("Submitted to workflow.");
ttscommit;
}
catch(exception::Error)
{
info("Error on workflow activation.");
}
}
args.caller().updateWorkFlowControls();
11-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
11-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
custInvoiceLineRecId =
_workflowElementEventArgs.parmWorkflowContext().parmRecId()
;
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::Cancellation;
custInvoiceLine.update();
ttsCommit;
}
custInvoiceLineRecId =
_workflowElementEventArgs.parmWorkflowContext().parmRecId()
;
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::Completed;
custInvoiceLine.update();
ttsCommit;
}
11-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
custInvoiceLineRecId =
_workflowElementEventArgs.parmWorkflowContext().parmRecId()
;
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::ChangeRequested;
custInvoiceLine.update();
ttsCommit;
}
custInvoiceLineRecId =
_workflowElementEventArgs.parmWorkflowContext().parmRecId()
;
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::Rejected;
custInvoiceLine.update();
ttsCommit;
}
11-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
custInvoiceLineRecId =
_workflowElementEventArgs.parmWorkflowContext().parmRecId()
;
ttsBegin;
select forUpdate custInvoiceLine where
custInvoiceLine.RecId == custInvoiceLineRecId;
custInvoiceLine.WorkflowStatus =
CustFreeInvoiceWFApprovalStatus::PendingApproval;
custInvoiceLine.update();
ttsCommit;
}
11-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
Next, you must add the approval element to the workflow type. To add the
approval element to the workflow type, follow these steps.
Next, you must add the new free text invoice line template to the free text invoice
header template so that it is available as a line-item workflow. To add the line
template to the header template, follow these steps.
11-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
11-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
Summary
Workflow in Microsoft Dynamics AX 2012 supports many new advanced
features. The line-item workflow types are used to create a workflow for data that
has a header and line relationship.
This chapter also reviewed the classes and attributes that can be called and
extended by the developer to present currency and hierarchy type fields in the
Condition Editor.
11-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. Put the following steps for developing a new work item queue in order:
Step:
_____ 1. Used to provide a specific end item, when a. Due Date Provider
a particular starting item is provided. b. Participant
_____ 2. Used to determine a specific due date for Provider
a task or approval based on a specified start date. c. Queue Provider
_____ 3. Used to provide a list of users from any d. Hierarchy
abstraction, such as a user group. Provider
_____ 4. Used to provide a list of users from a
work item queue that is configured in the Home
module.
11-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
11-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
11-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
Solutions
Test Your Knowledge
1. Put the following steps for developing a new work item queue in order:
Step:
MODEL ANSWER:
getDistance(): Returns the distance from the target node to the source node in
a hierarchy. If a direct path from the source node to the target node does not
exist then a nonzero value must be returned.
getLookup(): Displays a lookup table that represents the hierarchy from
which the user can select a node. The lookup table is typically the primary
key table for this field in the foreign key table.
11-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
MODEL ANSWER:
If you want to give the business user access to choose whether the line-item
workflow element should be wait for all line-item workflows to complete
before moving on to the next element.
11-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
Introduction
SQL Server Reporting Services (SSRS) is the primary reporting platform for
Microsoft Dynamics AX 2012. The default, out-of-the-box reports that are
provided with Microsoft Dynamics AX run on the Reporting Services platform.
They give users better looking reports, more export formats, and a more capable
report designer. The goals for this transition include following:
12-1
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
This chapter introduces you to the features of SSRS and shows how to create
simple reports by using a query and an auto-design. In addition, a complex report
using by the new report data provider framework in a precision design is
reviewed. The model-view-controller coding pattern for report data providers is
discussed and tips for selecting the correct development technology for your
reports are reviewed.
Reporting Architecture
The report development pattern in used for SSRS reports Microsoft Dynamics
AX 2012 uses the Model-View-Controller (MVC) design pattern variation. This
pattern allows many client types to call Microsoft Dynamics AX 2012 Reporting
Services reports including: Microsoft Dynamics AX clients, Enterprise Portal,
and Batch Job. This also means that Reporting Services can be replaced by a
different application for rendering reports.
12-2
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
When you run the Setup wizard for Microsoft Dynamics AX 2012, you can
install the business intelligence components. While installing the business
intelligence components, the Setup wizard will:
Upgrade Consideration
Reports and cubes are not upgraded to Microsoft Dynamics AX 2012. The X++
reporting framework is being deprecated in Microsoft Dynamics AX 2012.
Reports that are based on the X++ reporting framework and existing SQL Server
Reporting Services reports will be copied to the Microsoft Dynamics AX 2012
system. However, they will not be upgraded. It is recommended to use a SQL
Server Reporting Services report that is provided with Microsoft Dynamics AX
2012 as a template and customize it to meet your needs.
Configuration
You can use the Reporting services framework to modify the queries used to
retrieve data for reports. This means that you can now use SQL Reporting
Services capabilities to filter, group, and sort data in reports.
Auto-Reports
With Microsoft Dynamics AX 2012, you can use the Auto-report wizard to
create custom, ad hoc reports that are based on the SQL Server Reporting
Services framework. To start the Auto-report wizard, click the Print icon on a
form.
Batch Support
SQL Server Reporting Services reports in Microsoft Dynamics AX 2012 are now
integrated with the Microsoft Dynamics AX batch framework. You can schedule
a long-running report to print during off-peak hours and schedule a report to print
on a recurring basis.
12-3
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The Dynamics AX data source is provided for you. It connects to the Microsoft
Dynamics AX database. With this data source, you can use queries and Report
Data Provider classes that are defined within the Application Object Tree (AOT)
in Microsoft Dynamics AX, and data methods that are defined within your
reporting project in Visual Studio.
The Microsoft Dynamics AX data source does not display in the model with the
other report elements. It is available from the drop-down menus in the reporting
tools, and it can be used for a system that works from a SQL database with no
additional modifications needed for reports.
When you select Microsoft Dynamics AX as the data source for the report, you
will point to the active Application Object Server (AOS). If you want to use an
AOS from another computer that is not the active AOS, you must configure the
Business Connector session by using the client configuration utility to point to
another AOS.
You can define additional data sources as needed. For example, you can create a
data source to connect to data from a legacy system, online analytical processing
(OLAP) data, or some other external database.
12-4
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
NOTE: You can use the Dynamics AX OLAP data source type to connect to
databases deployed by using the Cube Administration wizard.
You define a data source in a model with the other report elements, and you must
also specify a data provider and a connection string. The data provider serves as a
bridge between a report and its data and is used to retrieve the data. There are
two providers that you can choose from when defining a data source: SQL and
OLAP. The connection string that you supply contains the information that is
used when connecting to the data source.
For example, if you are connecting to an SQL database, you can specify the
server name, the database name, and the authentication method for validating a
user. After you have defined a data source, it is displayed as an element in your
model and is available as an option in drop-down menus in the reporting tools.
A data source can be shared by one or more reports. A report can use one or more
data sources.
Report Datasets
A report dataset identifies the data from a data source that displays in a report.
When you define a dataset, you must specify the data source and the means used
to retrieve the data, such as a query or data method. The following table describes
the options for retrieving data for a report.
If your report uses the Dynamics AX data source and a query that is defined in
the AOT in Microsoft Dynamics AX, you must be especially careful when
updating the query in the AOT. For example, if you remove a field in the query
and the field displays in the report, the report will display an empty column for
the field. Whenever you make updates to a query, consider how those updates
can affect your reports. Updates to a query can also require updates to your
reports.
A report can have multiple datasets. A dataset can be used by one or more data
regions in a report.
12-5
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Security Considerations
When accessing data from the Microsoft Dynamics AX database, it is
recommended that you use the Microsoft Dynamics AX data source to make sure
that appropriate security is enforced. When you use the Microsoft Dynamics AX
data source, you can use queries or Report Data Provider classes that are defined
in the AOT. All data access requests are processed by using the MorphX security
system. When you use an external SQL or OLAP data source, security from the
MorphX security system is not applied when accessing data. In this case, you can
use the role-based security features that are available from Microsoft SQL Server
to help secure the data.
The following table provides detail on when to use each data source type to
access data for your report.
12-6
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
A controller class runs the report by creating the UI, calling SQL Server
Reporting Services, and preprocessing the parameters for the report.
NOTE: Reports that use a controller class must take care of the parameters
when the report is used on the Enterprise Portal.
12-7
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Development Actions
The following demonstration shows how to create a query bound report that
exposes Customer Transaction data.
The steps that are involved include create a Microsoft Dynamics AX query, add
field data to the query, create a new report model in Visual Studio, create a report
dataset, create a report design and apply style templates.
12-8
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
1. In the Model Editor, right-click the Report1 node, and then click
Rename.
2. Type CustTrans_W1 as the name.
3. Expand the CustTrans_W1 node if it is not already expanded.
4. Right-click the Datasets node, and then click Add Dataset.
5. Select the node for the dataset.
12-9
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. In the Model Editor, select the CustTransDS node and drag it onto
the Designs node. An auto design named AutoDesign1 is created for
the report.
2. Right-click the AutoDesign1 node, and then click Preview. The
Error List pane will open with warnings. This can be ignored.
3. Click the Report tab on the Preview window to view the report. The
report appears unformatted, because you have not yet applied any
layout or style templates to it. The following figure is a sample of
how the report will look.
12-10
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
12-11
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. In the Model Editor, expand the AutoDesign1 node, and then select
the Sorting node under the CustTransDSTable data region.
2. Right-click the Sorting node, and then click Add Sort.
3. Type AccountNum as the name.
4. In the Properties window, set the Sort By property to
=Fields!AccountNum.Value.
5. In the Model Editor, right-click the AutoDesign1 node, and then
click Preview to view the new sorting for the report.
6. When the Preview window opens, click the Report tab.
7. Close the Preview window.
8. Save the report.
To modify the column properties so that the user can decide the column sorting,
follow these steps.
1. In the Model Editor, expand the AutoDesign1 node, and then select
the AccountNum field under the Data region of the
CustTransDSTable node.
2. In the Properties window, set the Interactive sorting property to
True.
3. Repeat step 1 and 2 for the AmountCur, TransDate, and
TransType1 columns.
4. In the Model Editor, right-click the AutoDesign1 node, and then
click Preview to view the new style settings for the report.
12-12
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
5. When the Preview window opens, click the Report tab. The
following figure is a sample of how the report will look when sorted
by the date. Notice the sorting arrows next to the Customer account,
Amount transaction in currency, and Date fields.
12-13
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. In the Model Editor, expand the AutoDesign1 node, and then select
the AccountNum field under the Data node.
2. Right-click the Group1 node, and then click Properties.
3. In the Properties window, expand Instance Aggregates, and set
Render Location to Group Footer.
4. Select the AmountCur field under the Data node
5. In the Properties window, expand the Aggregation item, and set
Aggregate Function to Sum.
6. In the Model Editor, right-click the AutoDesign1 node, and then
click Preview to view the new style settings for the report.
7. When the Preview window opens, click the Report tab. Notice the
totals for each customer.
12-14
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
12-15
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
At this point the report has a parameter added. However, the data on the report is
not being filtered when a value is entered into the parameter field. To filter the
report dataset, follow these steps.
12-16
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
The following demonstration shows how to filter report data based on a dynamic
parameter that is bound to a Microsoft Dynamics AX query. The steps that are
involved include creating a Microsoft Dynamics AX query, creating a new
dataset and binding it to the query, binding the report parameter to the query
results, and filtering the report dataset by using the parameter value.
12-17
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
4. In the Properties window, click the elipses (...) button in the Values
property.
5. Select the From Dataset option and set the following:
a. Dataset: CustomersDS
b. Value Field: AccountNum
c. Label Field: AccountNum
6. Click OK.
7. In the Model Editor, right-click the AutoDesign1 node, and then
click Preview to view the new settings for the report. Notice the
Account field on the Parameters tab now shows a list of all
customers and a check box next to each customer number which
allows you to select multiple customers.
8. Close the Preview window.
9. Save the report.
12-18
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
12-19
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
IMPORTANT: You cannot view the changes to the menu unless you log off
Microsoft Dynamics AX and then log on again.
12-20
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
Scenario
Challenge Yourself!
Use the information that is provided to create a query bound report that exposes
vendor transaction data. Create the new report in Visual Studio and add sorting
and grouping by vendor account to the report. Then add a report filter for the
account number, and add a dynamic parameter for the vendor account. When you
are finished, save and deploy the report and add a menu item to the Accounts
Payable module to view the report on the menu.
12-21
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
6. Right-click the Data Sources node and then select New Data
Source.
7. Enter VendTrans into the Table property field.
8. Expand the VendTrans_1 Dataset node.
9. Right-click the Fields node of the query, click Properties.
10. Change the Dynamic property to No so that fields can be removed
from the view.
11. Only include the following fields in your dataset view AccountNum,
AmountCur, TransDate, TransType, and Txt.
12. Save the query.
12-22
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
1. In the Model Editor, expand the AutoDesign1 node, and then select
the Sorting node under the VendTransDSTable data region.
2. Right-click the Sorting node and then click Add Sort.
3. Type AccountNum as the name.
4. In the Properties window, set the Sort By property to
=Fields!AccountNum.Value.
5. In the Model Editor, right-click the AutoDesign1 node, and then
click Preview to view the new style settings for the report.
6. Close the Preview window.
7. Save the report.
8. In the Model Editor, expand the AutoDesign1 node, and then select
the AccountNum field under the Data region.
9. In the Properties window, set the Interactive sorting property to
True.
10. Repeat steps 8 through 9 for the AmountCur, TransDate, and
TransType1 columns.
11. Optional: In the Model Editor, right-click the AutoDesign1 node,
and then click Preview to view the new style settings for the report.
Close the Preview window.
12. Save the report.
12-23
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
12-24
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
12-25
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
12-26
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
Model-View-Controller
Model-view-controller (MVC) is a pattern used to isolate business logic from the
user interface. By using MVC, the model represents the information (the data) of
the application and the business rules used to manipulate the data, the view
corresponds to elements of the user interface such as text, checkbox items, and so
on, and the controller manages details involving the communication between the
model and view. The controller handles user actions such as keystrokes and
mouse movements and pipes them into the model or view as required.
• Model: Responsible for retrieving data and for business logic, this
can included queries, data methods, or other classes that are designed
to retrieve data.
• View: Responsible for the User Interface, this can also be thought of
as the design for the report.
• Controller: Orchestrates the flow between Model and View
12-27
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The Creating Basic Reports from a Query topic reviewed a simple example of a
report where all of these elements existed. However, the design and the control of
the report were not modified. Instead the base classes for the SSRS reporting
framework in Microsoft Dynamics AX 2012 rendered the report dialog and
handled the logic that was required to run the report.
The steps used to create a report data provider that will deliver data to a report
follow.
The steps that are involved include review and define the data structure for the
report, create a temporary table to store the report dataset, and add table fields
required to generate the report.
12-28
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
To review and define the data structure for the report dataset, follow these steps.
The following figure is a sample of a completed report that will be built during
the following demonstrations.
TIP: Before you begin development for a new report visualize the layout of the
report using by Microsoft Office® Excel or draw the report design on a piece of
paper.
12-29
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NOTE: Some reports can require more than one temporary table to store the
information.
Report parameters that are used by custom business logic are managed by a data
contract class in X++. The steps that are involved include evaluate report
parameters, create a class in Microsoft Dynamics AX to use to manage the report
parameters, and define access methods for the contract data elements.
12-30
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
/// <summary>
/// Data Contract class for the AOT Objects SSRS report
/// </summary>
/// <remarks>
/// This is the Data Contract class for the AOT Objects
SSRS report
/// </remarks>
[DataContractAttribute]
public class AOTObjectsContract
{
Name parentNode;
Name aotProperty;
Name propertyVal;
boolean incNoValue;
}
/// <summary>
/// Gets or sets the value of the datacontract parameter
AOTProperty.
/// </summary>
/// <param name="_aotProperty">
/// The new value of the datacontract parameter
AOTProperty; required.
/// </param>
/// <returns>
/// The current value of datacontract parameter
AOTProperty
/// </returns>
[ DataMemberAttribute('AOTProperty'),
SysOperationLabelAttribute(literalstr("@SYS682'")) ]
12-31
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
TIP: Notice the use of the literalstr() function and the "@" symbol when defining
a label to be used for the SysOperationLabelAttribute.
/// <summary>
/// Gets or sets the value of the datacontract parameter
IncludeNoValue. /// </summary>
/// <param name="_incNoValue">
/// The new value of the datacontract parameter
IncludeNoValue; required. /// </param>
/// <returns>
/// The current value of datacontract parameter
IncludeNoValue
/// </returns>
[ DataMemberAttribute('IncludeNoValue'),
SysOperationLabelAttribute(literalstr("@SYS53334")) ]
/// <summary>
/// Gets or sets the value of the datacontract parameter
ParentNode.
/// </summary>
/// <param name="_parentNode">
/// The new value of the datacontract parameter
ParentNode; required.
/// </param>
/// <returns>
/// The current value of datacontract parameter ParentNode
/// </returns>
[ DataMemberAttribute('ParentNode'),
SysOperationLabelAttribute(literalstr("@SYS58556")) ]
12-32
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
/// <summary>
/// Gets or sets the value of the datacontract parameter
PropertyValue.
/// </summary>
/// <param name="_propertyVal">
/// The new value of the datacontract parameter
PropertyValue; required.
/// </param>
/// <returns>
/// The current value of datacontract parameter
PropertyValue /// </returns>
[ DataMemberAttribute('PropertyValue'),
SysOperationLabelAttribute(literalstr("@SYS23425")) ]
3. Add all the custom business logic used to generate the report dataset.
12-33
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
/// <summary>
/// The Report data provider class that supports the AOT
Objects report. /// </summary>
/// <remarks>
/// This class provides the methods that are used by the
AOT Objects report
/// </remarks>
[
SRSReportParameterAttribute(classstr(AOTObjectsContract)) ]
// contract information
Name aotProperty;
Name propertyVal;
boolean incNoValue;
}
In this demonstration, you will import the code from an XPO on the Hyper-V
image. To import the file, follow these steps.
12-34
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
3. Create a basic view of the report data grouped on the AOT Object
Property information.
4. Convert the basic design into a Precision Design to achieve the
desired report layout.
12-35
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
Now you have created a Precision Design that produces the same output as the
Auto Design automatically created to match the report dataset. Notice that this
layout is inconsistent with the desired look for the final report. The next step is to
use the Visual Studio tools to manipulate the design match the expected report
output.
12-36
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
1. Open a menu item that corresponds to the report that you want to
print.
2. Set the parameters that exist.
a. If you have queries, click the Select button and set the range.
b. Click the Destinations button to set the print destination fields.
You can print to a screen, printer, file, or email recipient.
1. In the AOT, find the code element that you want to print the report
from.
2. Right-click the code element and then click Edit.
3. Use the following code samples to print a report directly or to open
the report dialog from code.
///Declare a variable
SrsReportRunInterface reportRun;
NOTE: This example runs a simple report that does not have a modified
contract.
TIP: In a more complex example where the report uses a data contract class,
additional code will be required. For an example of how to implement this, refer
to the EPSendDocument class makeDocument() method. This class is designed to
print a different report based on the record that is passed in.
12-37
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
The following example uses the default settings and updates specific settings.
The report will be printed to file together with the file name set to
ReportExample.
Args args;
SrsReportRunInterface reportRun;
SrsReportDataContract contract;
SRSPrintDestinationSettings printSettings;
printSettings.printMediumType(SRSPrintMediumType::File);
printSettings.fileFormat(SRSReportFileFormat::PDF);
printSettings.fileName(file);
printSettings.overwriteFile(true);
12-38
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
2. Next, create a new method called setRanges that set the report ranges
based on a query that is passed in. Use the following code sample to
guide you.
/// <summary>
/// Sets the report query ranges based on caller.
/// </summary>
/// <param name="_query">
/// Report query object.
/// </param>
public void setRanges(Query _query)
{
QueryBuildDataSource queryBuildDataSource;
str range;
custTable custTable;
custTable = this.parmArgs().record();
queryBuildDataSource = _query.dataSourceTable(tableNum(custTable));
range = queryValue(custTable.AccountNum);
//Adding the account number to the range value
SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(custTable,
AccountNum)).value(range);
}
12-39
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
AccountNum accountnum;
CustTable custTable;
custTable = args.record();
accountnum = custTable.AccountNum;
q = this.getFirstQuery();
qbds = q.dataSourceTable(tableNum(custTable));
if (AccountNum)
{
qbr = qbds.addRange(fieldNum(CustTable, AccountNum));
qbr.value(queryValue(AccountNum));
}
}
this.setRanges(this.parmReportContract().parmQueryContracts().lookup(this.get
FirstQueryContractKey()));
}
5. Next override the main method. Use the following code sample to
guide you.
12-40
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
At this point you have created a controller for the report. Now you must create
some logic to programmatically run the report and override the query. In this
example a job is created to call the report. Use the following code sample to
guide you.
12-41
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
When you are finished creating the job, save, compile, and then run the job. The
report dialog will open and you should notice that the customer account 4001 is
already entered into the report query selection. If you click OK and run the report
the report should only print data for customer 4001.
To hide the report dialog for a report with the library report that contains
sensitive data, add the following code in the Code Editor. This example uses the
same job that was used in the "Set the Query Range on a Report" demonstration.
12-42
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
TIP: Other methods are available to hide various objects within the reporting
framework. For example, if you want to hide the report dialog box you can call
the showDialog() method and pass in false to set the value. For a complete list of
methods and their functionality, refer to the developer help on MSDN.
Each reporting project contains a nested business logic project. When you create
a data method within the Model Editor, a template for the data method is copied
into a code file within the nested business logic project.
When you build a business logic project, the code is compiled into a business
logic assembly (.BusinessLogic.dll). During deployment, business logic
assemblies are built and deployed to the report server and the security policy file
for the report server is updated so that .NET Business Connector has secure
access to the assemblies.
The return value for a data method can be any .NET type. The default return
value is a System.String instance. To use a data method as a source of data for a
report dataset, it must return an IEnumerable<DataRow> or
System.Data.DataTable instance.
12-43
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
public static IEnumerable<DataRow> RetrieveItemData()
{
// Retrieve records from the InventTable table.
return AxQuery.ExecuteQueryStream("select * from
InventTable");
}
TIP: To use the code sample provided, create a new SSRS report in Visual
Studio. Next, create a data method with the code sample provided, and then
create a new Data Set. Make sure that you set the Data Source Type property to
Business Logic, and then in the Query property select the RetrieveItemData
method that you created. Then you must design the report. When you are finished
you can preview the report.
Data methods can have parameters. A parameter for a data method can be any
.NET type. When a data method is used in a dataset, a report parameter is
automatically generated for each parameter in the data method. Report
parameters display below the Parameters node in the Model Editor.
• Overloading data methods is not supported. You can have only one
data method of a particular name inside a model. If you overload a
data method, you will receive an error stating that multiple data
methods with the specified name exist, and you will be unable to use
the data method within the report.
• Sharing data methods between reporting projects.
• Accessing Microsoft Dynamics AX queries by using data. Use a
report data provider class to access a Microsoft Dynamics AX query
in a report.
12-44
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
For business logic that is more complex, the recommendation is to write the
business logic inside a data method, and then call the data method from an
expression. By doing this you can take advantage of the capabilities of a full
programming language when writing your business logic. You can reference
types that are defined in other assemblies. For example, you can reference a
.NET Framework assembly, and then use an existing .NET type inside your
business logic. You can call other methods from inside a data method, as shown
in the previous code example. Additionally, you can access X++ code that is
defined in Microsoft Dynamics AX by using the managed programming interface
for reports that are defined in the [N:Microsoft.Dynamics.Framework.Reports]
namespace.
A data method can be used in multiple expressions inside a report, so that the
business logic that you define inside a data method is reusable within the report.
Expressions are not reusable inside a report. When you create an expression, it
cannot be called from another expression within the report.
NOTE: Model refactoring is currently not supported for data methods. The
model refactoring options are disabled on the context menu that displays for a
data method in the Model Editor.
You must be careful when you modify data methods. Data methods can be
referenced from data sets and expressions throughout a report. If you make a
breaking change to a data method in the code, you must manually update all
references to the data method wherever it is used in the report. The following
actions can result in a breaking change and cause errors in your report.
12-45
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
NOTE: For more information about how to use business logic in report data
methods to access report data refer to MSDN
(http://go.microsoft.com/fwlink/?LinkId=238177).
Print Management
Print management gives users control of print settings for selected Microsoft
Dynamics AX reports. Print settings include the number of copies, the printer
destination, and the multilanguage text that can be included on the report. Some
additional print management features that you can use include the following.
You should consider by using the print management framework when the
following conditions are true:
• Your new or existing feature has reports that require specialized print
management.
• You are adding a new document type to the application that
resembles the document types currently supported by print
management.
12-46
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
Architectural Overview
The print management subsystem is divided into three main parts: metadata,
setup, and retrieval. Metadata defines a series of classes that you can use to
describe how print management should work. You can describe how many levels
of defaulting are possible, what tables and columns should be involved in
queries, and other pertinent information. Setup defines a generic user experience
that can be opened throughout the application that is based on certain inputs. You
would call this in areas where print management information must be managed
by end-users. Retrieval defines an Application Programming Interface (API)
which you can use to retrieve and use the print management information set up
by the user.
Defining Metadata
Print management metadata is defined completely in code and originates from
four main classes or concepts: PrintMgmtDocType (documents), PrintMgmtNode
(nodes), PrintMgmtHierarchy (hierarchies), and PrintMgmtReportFormat
(formats).
12-47
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
A report format is the design or layout of the report. It is possible for each
report to have multiple designs.
The following diagram shows how documents, nodes and hierarchies all relate to
one another to define the print management metadata for a hypothetical Accounts
Receivable hierarchy.
The Accounts Receivable node represents the module level settings and all
documents present in the module apply at this level. The Customer node
represents settings that apply to specific customers and all documents present in
the module apply. At the lowest level the nodes represent transaction level
settings and only certain documents apply to each specific transaction.
12-48
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
12-49
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. Make sure a node does not already exist that meets your needs. Look
at the classes that derive from the PrintMgmtNode class to determine
this information. Even if an existing node defines document types
that you are not interested in using, you can still use the node. If the
existing nodes do not meet your needs, continue to step 2.
2. Create a new enumeration value in the PrintMgmtNodeType
enumeration.
12-50
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
3. Create a new class that derives from the PrintMgmtNode class. Make
sure that you reference the existing PrintMgmtNode derivatives for
examples. The class should be prefixed with 'PrintMgmtNode_' and
should follow the naming pattern of the existing nodes. If the node is
tied to a particular table, the table name should follow the prefix such
as PrintMgmtNode_CustTable, for example.
o This method controls the caption that will appear for the
instance of the node in the Print Management window.
o Return the appropriate label for Module level settings.
Refer to existing examples in PrintMgmtNode_Purch or
PrintMgmtNode_Sales.
o Return strfmt("@SYS108943", _tableBuffer.caption())
for account level settings. Refer to the existing example
in PrintMgmtNode_CustTable or
PrintMgmtNode_VendTable.
o Return strfmt("@SYS108944", _tableBuffer.caption())
for transaction level settings. Refer to existing examples
in PrintMgmtNode_SalesTable or
PrintMgmtNode_PurchTable.
o Customize as necessary for unique situations.
12-51
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
o This method controls the icon that will appear for the
instance of the node in the Print Management window.
o Return the resource ID used to display the icon
representing this node. The resAppl macro contains the
resource ID definitions for icon images. This method
should return one of those resource IDs. If additional
resource IDs are used, they should also be added to the
build method of the ImageListAppl_PrintMgmt class.
o Module level nodes should use the same icon that is used
for the module, account level nodes should use
#ImagePrintManagementAccount, and transaction level
nodes should use #ImagePrintManagementTrans.
12-52
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
7. Add the node to the appropriate hierarchy. See the Create or Modify
Hierarchies section for the steps that are required to perform this
action.
8. Add the node to the PrintMgmt shared project.
12-53
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
12-54
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
• Copy an existing SSRS report (the .RDL file) with a new name.
• Modify the new SSRS report layout by moving, deleting, or adding
report elements.
• Add a call in table PrintMgmtReport format’s populate method to the
addOther() method.
• Call the table method PrintMgmtReportFormat::populate to update
the table with the new report format so it is available to the user to
select in Print Management setup.
Summary
This chapter introduced the features of SSRS and demonstrated how to create a
simple report by using a query and an auto-design. Additionally, the chapter
showed how you can use the report data provider framework to deliver business
logic to a report in more complex business scenarios.
The MVC is a pattern used to separate the data (Model) from the user interface
(View) and the business logic (Controller) is used to communicate between the
Model and the View. You can implement this framework by decorating your
classes together with attributes such as the DataContractAttribute and the
DataMemberAttribute.
You can use the SRSReportRun framework to control how the printing and
output of a report will be handled. You can also use X++ to set parameter values
when running a report.
In addition to the query framework and the report data provider framework, you
can use business logic in Visual Studio to retrieve the data for a report. To use
business logic in a report you must create a data method that includes the
DataMethhod() attribute. A data method can also be used within report
expressions to perform data manipulations or calculations for fields that display
in the report.
12-55
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. Put the following steps in the correct order to create a new SSRS report from
a Microsoft Dynamics AX query:
Step:
3. What must you create to store the data when a report data provider class is
used for the data set?
( ) A persisted table in SQL
( ) An in-memory temporary table in the AOT
( ) A persisted table in the AOT
( ) A temporary table in SQL
4. Which of the following options is not a class that is used for implementing
print management on a new report?
( ) PrintMgmtDocType
( ) PrintMgmtHierarchy
( ) PrintMgmtReport
( ) PrintMgmtNode
12-56
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
1. Dynamics AX
2. SQL
3. Dynamics AX OLAP
6. Which of the following is not a step in the process for saving and deploying a
report project?
( ) Rebuild the solution
( ) Save the report to the AOT
( ) Import the report into the AOT
( ) Deploy the report
12-57
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1.
2.
3.
12-58
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Chapter 12: Reporting
Solutions
Test Your Knowledge
1. Put the following steps in the correct order to create a new SSRS report from
a Microsoft Dynamics AX query:
Step:
3. What must you create to store the data when a report data provider class is
used for the data set?
( ) A persisted table in SQL
(•) An in-memory temporary table in the AOT
( ) A persisted table in the AOT
( ) A temporary table in SQL
4. Which of the following options is not a class that is used for implementing
print management on a new report?
( ) PrintMgmtDocType
( ) PrintMgmtHierarchy
(•) PrintMgmtReport
( ) PrintMgmtNode
12-59
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics® AX 2012
1. Dynamics AX
2. SQL
3. Dynamics AX OLAP
2 Item 3: TSQL
6. Which of the following is not a step in the process for saving and deploying a
report project?
( ) Rebuild the solution
( ) Save the report to the AOT
(•) Import the report into the AOT
( ) Deploy the report
12-60
Microsoft Official Training Materials for Microsoft Dynamics®
Your use of this content is subject to your current services agreement