Ax2012 Enus Deviv 01 PDF
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.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Most references use either Company or Legal entity scope segments. By default, references for master data entities that are shared across the application do not use scope segments. 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.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
IMPORTANT: Do not select the Continuous option if you must preallocate numbers for the number sequence. To add a scope segment to the format of a number sequence, select the format in the list, and then click Include scope in format. To remove a scope segment from the format of a number sequence, select the format in the list, and then click Remove scope from format. To exclude a number sequence from automatic generation, select the number sequence in the list, and then click Delete. Click Next >. On the Completed page, verify the information, and then click Finish.
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.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-7
Constant segments contain a set of alphanumeric characters that do not change. Use this segment type to add a hyphen or other separator between number sequence segments.
1-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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. Status list: Provides a list of numbers that are generated for continuous number sequences, but which are not committed to the database. The numbers are either currently being used in a user session, are reserved for future use in a user session, or are free for use if a new client user session requests a new number for a particular number sequence in the list. If a new number does not exist for a specific continuous number sequence, it is generated by the sequence number framework from the next value for that number sequence in the Number sequence table (NumberSequenceTable). Manual cleanup: Allows the administrator to manually clean up numbers in the status list. Use of this option is only recommended after an unexpected system failure; in such rare circumstances, numbers might not be automatically cleaned up. History: Provides the history of the changes to the number sequences.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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: Company scenario: Based on the default segment of DataArea (or company). Organization model and regulatory scenario: Based on the use of new segments such as legal entity, operating unit, and fiscal calendar period.
The Microsoft Dynamics AX 2012 number sequence framework does not currently support an extensibility scenario to add arbitrary segments such as a warehouse or a site as a segment in the definition of a number sequence for a reference. That kind of extensibility would require significant customization to the number sequence framework. 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. A developer would typically follow these steps: Make changes to support the new extended data type that corresponds to the new field in the table. Call the API to generate the values by using the number sequence for that field.
1-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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.
Procedure: Create a Number Sequences Page in the Parameters Form of the New Module
Next, you must create or modify a Number sequences page on the FMSetup form for the new Fleet management module. This requires you to override the numberSeqPreInit method. You can refer to existing forms such as CustParameters or LedgerParameters for examples of the implementation. The following is sample code for the numberSeqPreInit method on the form for Fleet management.
void numberSeqPreInit() { numberSequenceModules = [NumberSeqModule::FleetManagement]; numberSeqApplicationModule = new NumberSeqModuleFleetManagement(); scope = NumberSeqScopeFactory::createDataAreaScope(); NumberSeqApplicationModule::createReferencesMulti(numberSeq uenceModules, scope); tmpIdRef.setTmpData
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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;
NOTE: A FleetManagementParameters table does not exist in the training environment by default. You can create one, or alternatively use one of the tables in the FMSetup form.
1-14
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
NOTE: A FleetManagementParameters table does not exist in the training environment by default. You can create one, or alternatively use any of the tables in the FMSetup form.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Next, create a new method called numberSeqFormHandler. This method should call the static method newForm() on the numberSeqFormHandler class. Make sure that you pass in the number sequence reference from your parameters table, the data source which stores the number, and the table and field that will hold the number that is generated. Use the following code sample to guide you.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
The formMethodDataSourceCreatePre() method is used to validate that there is a last number on the number sequence. The call to this method must be positioned before the call to super(). The formMethodDataSourceCreate() method is used to create a record with a number sequence value. The call to this method must be positioned after the call to super().
1-20
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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(); }
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
NOTE: You may need to extract the files in the 80313_DevelopmentIV_XPOFiles.zip folder first. You can do this by rightclicking on the folder and selecting Extract All....
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7. Save the method, and then close the Code Editor window.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-25
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
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();
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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. Select Delete from the list.
To override the close() method, follow these steps. 1. Right-click the Methods node of the CustContract form in the AOT, and select Override Method. 2. Select Close from the list. 3. Add the following code into the close method.
void close() { if (numberSeqFormHandler) { numberSeqFormHandler.formMethodClose(); } super(); }
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-29
1-30
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-31
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-32
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2.
3.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
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
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement