Professional Documents
Culture Documents
Ax2012 Enus Deviv 01 PDF
Ax2012 Enus Deviv 01 PDF
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.
This course is designed to explain how developers can perform customizations
using the number sequence framework. However, administrators may be
interested in the "Setup and Administration of Number Sequences" topic, which
describes how to configure and set up number sequences using the new number
sequence administration forms.
1-1
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.
All segments in a scope must be related to the underlying transaction or master
data entity. For example, a journal transaction will have a relationship with the
segments of a legal entity and fiscal calendar period (through the transaction or
posting date) that make up its scope. The scope can be used to partition the entity
instances or transactions based on the segment values. In this example, a journal
transaction might be partitioned into categories based on the two segments in its
scope.
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.)
The concept of a number sequence reference, which is synonymous with an
extended data type, is carried forward from Microsoft Dynamics AX 2009.
When you create a number sequence, you must first create an extended data type
(EDT) with a label-such as SalesOrderID-for the new number sequence. The
label of this EDT is used as a reference. This reference is used to define a field on
a document or master data entity that requires a number sequence.
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
Legal entity
Operating unit
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
scopesone 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
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.
In Microsoft Dynamics AX 2012, most references use either DataArea (or
company) or legal entity segments out of the box. There are several references
for master data entities that are shared across the application and do not use
segments. However, the framework allows an administrator to add segments such
as the fiscal calendar period.
1-4
1-5
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
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
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.
c. Legal entity: A separate number sequence is used for each legal
entity.
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.
d. Operating unit - A separate number sequence is used for each
operating unit.
e. Company and Fiscal calendar period - A separate number
sequence is used for each company and fiscal calendar period
combination.
f. Legal entity and Fiscal calendar period - A separate number
sequence is used for each legal entity and fiscal calendar period
combination.
1-8
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
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:
1-10
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.
NOTE: An element for FleetManagement exists in the training environment by
default.
1-11
Class declaration
public class NumberSeqModuleFleetManagement extends
NumberSeqApplicationModule
{
}
protected void loadModule()
{
NumberSeqDatatype datatype =
NumberSeqDatatype::construct();
/* 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
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.
1-13
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
NumberSeqScope
NumberSeqApplicationModule
container
TmpIdRef
numberSeqReference;
scope;
numberSeqApplicationModule;
numberSequenceModules;
tmpIdRef;
1-14
1-15
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
1-17
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
1-19
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.
void create(boolean append = false,
boolean extern = false)
externally
{
// If created
element.numberSeqFormHandler().formMethodDataSourceCreatePr
e();
super(append);
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate(t
rue);
}
}
1-20
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
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.
IMPORTANT: You must import the AX2012_ENUS_DEVIV_LAB.xpo file which
is located on the local drive of the training image before starting this lab.
1-22
1-23
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.
NOTE: The Synchronize process can take several minutes to finish.
1-24
7. Save the method, and then close the Code Editor window.
1-25
8. Save the method, and then close the Code editor window.
1-26
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.
6. Right-click the Methods node of the CustContract form in the
AOT window, and then click New Method.
7. Add the following code into the new method.
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.
To override the create() method, follow these steps.
9. Expand the Data Sources node of the CustContract form in the
AOT.
10. Expand the CustContract data source and then right-click the
Methods node of the data source, and select Override Method.
11. Select Create from the list.
12. Add the following code into the create method.
void create(boolean append = false,
boolean extern = false)
externally
{
// If created
element.numberSeqFormHandler().formMethodDataSourceCreatePr
e();
1-27
13. Save the method and then close the Code Editor window.
To override the write() method, follow these steps.
1. Expand the Data Sources node of the CustContract form in the
AOT.
2. Expand the CustContract data source and then right-click the
Methods node of the data source, and select Override Method.
3. Select Write from the list.
4. Add the following code into the write method.
void write()
{
ttsbegin;
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
ttscommit;
}
5. Save the method and then close the Code Editor window.
To override the validateWrite() method, follow these steps.
1. Expand the Data Sources node of the CustContract form in the
AOT.
2. Expand the CustContracts data source and then right-click the
Methods node of the data source, and select Override Method.
3. Select validateWrite from the list.
4. Add the following code into the validate write method.
1-28
5. Save the method and then close the Code Editor window.
To override the delete() method, follow these steps.
1. Expand the Data Sources node of the CustContract form in the
AOT.
2. Expand the CustContract data source and then right-click the
Methods node of the data source, and select Override Method.
3.
1-29
1-30
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 primary purpose of the number sequence framework is to provide unique,
user-friendly identifiers while maintaining a continuous or non-continuous
alphanumeric sequence.
An administrator can assign number sequences by using a page in the parameter
forms within individual application modules, or by using a wizard in the
Organization administration module.
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
1-32
2.
3.
1-33
Solutions
Test Your Knowledge
1. TRUE or FALSE? Scope segments cannot be modified for a number
sequence that is currently being used.
() TRUE
( ) FALSE
2. Describe the difference between a constant segment and an alphanumeric
segment on a number sequence format.
MODEL ANSWER:
Constant segments contain a set of alphanumeric characters that do not
change.
Alphanumeric segments contain a combination of number signs (#) and
ampersands (&). These characters represent letters and numbers that
increment every time that a number from the sequence is used. Use a number
sign (#) to indicate incrementing numbers and an ampersand (&) to indicate
incrementing letters.
3. Which of the following are supported scopes for number sequences in
Microsoft Dynamics AX 2012? (Select all that apply)
() DataArea
( ) Department
() Legal Entity
() Fiscal calendar
1-34