[AX] AX2012 number sequence framework: (iii) re-talk number sequence

Source: Internet
Author: User
Tags microsoft dynamics

The AX2012 number sequence Framework introduces two scope and segment concepts, and their specific roles are described in the following sequence of examples.

The French / Chinese law requires that the Journal number of the financial document contain the company code and the financial period, such as such numbers j-20-jan11-000340, on theJ table Journal, represents the company code,Jan11 for the financial period,000340 is the system generated serial number.

You can select the Scope you want on the interface to create Numer sequence:

Company and fiscal calendar period is a more complex scope type, requiring the appropriate corporate and financial calendar periods to be selected:

Segment automatically includes company and Fiscal calendar period for generating specific serial numbers,Segment can still be modified, including company and Fiscal Calendar period segment are all possible, and also allow the creation of multiple company and Fiscal Calendar period segment.

EDT sequence reference for company Scope

Sequence number is often used for automatic generation of the EDT type field, and it can be considered that the EDT type and Sequence number refrence are one thing, in a custom Numberseqapplicationmodule.loadmodule () registers A serial number reference for the EDT type:

Sequence number is often used for automatic generation of the EDT type field, and it can be considered that the EDT type and Sequence number refrence are one thing. Register the serial number reference for the EDT type in the Custom Numberseqapplicationmodule.loadmodule (): Public voidLoadModule () {Numberseqdatatype datatype=numberseqdatatype::construct ();    ; /*Work Order number*/Datatype.parmdatatypeid (Extendedtypenum (workordernum)); Datatype.parmreferencehelp ("Unique identifier for work orders"); Datatype.parmwizardiscontinuous (false);    Datatype.parmwizardismanual (Noyes::no);    Datatype.parmwizardischangedownallowed (Noyes::no);    Datatype.parmwizardischangeupallowed (Noyes::no); Datatype.parmsortfield (1); Datatype.parmwizardhighest (999999); Datatype.addparametertype (numberseqparametertype::D Ataarea,true,false);  This. Create (datatype);}

note datatype.addparametertype (numberseqparametertype::D Ataarea, True, False) numberseqparametertype::D ataareaedt reference to sequence number scope type companyorganization Administration > Common > Number sequences > Number Sequences interface generate for this edt type auto-created sequence numberscope company

Usually we will create the Numrefxxx () method in the module's parameter table to facilitate reference in the code, in the above example, the numrefxxx () method of EDT is similar:

Static numbersequencereference Numrefworkordernum () {    = Numberseqscopefactory::createdataareascope ( Selectabledataarea _dataarea = curext ());     return numberseqreference::findreference (Extendedtypenum (workordernum), scope);}

Note Call Numberseqscopefactory::createdataareascope (Curext ()) from the sequence that is created based on the current company Scope.

Company and fiscal calendar period Scope EDT sequence reference

The first place to modify is to create a sequence reference for the company and fiscal calendar period Scope for the EDT is LoadModule:

 Public voidLoadModule () {Numberseqdatatype datatype=numberseqdatatype::construct ();       ; /*Work Order number-company and fiscal calendar*/Datatype.parmdatatypeid (Extendedtypenum (workordernum_compfiscal)); Datatype.parmreferencehelp ("Unique identifier for work orders-company and fiscal calendar"); Datatype.parmwizardiscontinuous (false);    Datatype.parmwizardismanual (Noyes::no);    Datatype.parmwizardischangedownallowed (Noyes::no);    Datatype.parmwizardischangeupallowed (Noyes::no); Datatype.parmsortfield (1); Datatype.parmwizardhighest (999999); Datatype.addparametertype (numberseqparametertype::D Ataarea,true,false); Datatype.addparametertype (Numberseqparametertype::fiscalcalendarperiod,true,false);  This. Create (datatype); }

Note that two times Addparametertype () is called to add dataarea and fiscalcalendarperiod two Scope types, this type of Refrence may not be visible on the Parameters form of the module , usually in the Numberseqpreinit () method of the Parameter form, we usually create a Scope object for DataArea:

Scope = Numberseqscopefactory::createdataareascope ();

The second place to modify is the numrefxxx () method on the parameter table , and we need to create the corresponding dataareafiscalcalendarperiod Scope:

Static Numbersequencereference numrefworkordernum_compfiscal (transdate _date = systemdateget ()) {    =  Numberseqscopefactory::createdataareafiscalcalendarperiodscope (        curext (),        fiscalcalendars:: Findperiodbyperiodcodedate (Companyinfo::fiscalcalendarrecid (), _date). RecId         );     return numberseqreference::findreference (Extendedtypenum (workordernum), scope);}

For the company and fiscal calendar period Scope EDT, the "Set up numbersequence" Wizard The tool does not create the corresponding sequence for us, we can only create it manually, Select the reference to the specific EDT type under the Refrence of the number sequence edit window .

the EDT sequence reference for Shared Scope

The shared scope is a rather special sequence scope, which is not associated with any company and financial calendar, and the EDT type reference that creates a Shared scope does not need to be called Addparametertype ():

 Public voidLoadModule () {Numberseqdatatype datatype=numberseqdatatype::construct ();        ; /*Work Order number-shared*/Datatype.parmdatatypeid (Extendedtypenum (workordernum_shared)); Datatype.parmreferencehelp ("Unique identifier for work orders-shared"); Datatype.parmwizardiscontinuous (false);    Datatype.parmwizardismanual (Noyes::no);    Datatype.parmwizardischangedownallowed (Noyes::no);    Datatype.parmwizardischangeupallowed (Noyes::no); Datatype.parmsortfield (1); Datatype.parmwizardhighest (999999);  This. Create (datatype); }

Also need to modify the Numrefxxx () method, we need to create a Global Scope:

Static numbersequencereference numrefworkordernum_shared () {    = numberseqscopefactory:: Createglobalscope ();     return numberseqreference::findreference (Extendedtypenum (workordernum), scope);}

TheSet up number sequence Wizard Tool creates a reference sequence for the EDT type of Shared scope , and of course creates only one sequence Number, not a company a Sequence number.

Configurable EDT sequence reference

The last parameter of Datatype.addparametertype (numberseqparametertype::D Ataarea, True, false) has not been mentioned , this parameter is true indicates that the sequence type referenced by the EDT can be configured, as shown in the following example:

 Public voidLoadModule () {Numberseqdatatype datatype=numberseqdatatype::construct ();        ; /*Work Order number-configurable*/Datatype.parmdatatypeid (Extendedtypenum (workordernum_configurable)); Datatype.parmreferencehelp ("Unique identifier for work orders-configurable"); Datatype.parmwizardiscontinuous (false);    Datatype.parmwizardismanual (Noyes::no);    Datatype.parmwizardischangedownallowed (Noyes::no);    Datatype.parmwizardischangeupallowed (Noyes::no); Datatype.parmsortfield (1); Datatype.parmwizardhighest (999999); Datatype.addparametertype (numberseqparametertype::D Ataarea,true,true);  This. Create (datatype); }

Configurable in Organization Administration > Common > Number sequences > Segment Configuration Interface You can modify the options under segments:

Because this is the EDT of company SOCPE , all the options that can be modified are "company". If we uncheck "Company", the workorders-configurable EDT becomes the Shared scope type.

The "countries/regions" content on this window is alsoderived from the countryregioncodes property setting for the EDT type .

It should be noted that number sequence cannot be assigned to a different Scope type of EDT, andAX will report "unable to find a unique number" Sequence code record corresponding to the entered values. "error message to automatically filter out incompatible EDT in the Refrence add Refrence box in the Sequence edit window.

Delete a EDT sequence reference

Finally, call numberseqapplicationmodule.create () edtedtnumberseqapplicationmodule.create () internally called numberseqdatatype.create () The table involved is numbersequencedatatype Numbersequencedatatypeparametertypeedt

Static void deletenumseqref (Args _args) {    numberseqdatatype datatype= numberseqdatatype::construct ();    Numbersequencedatatype record;    Numbersequencedatatypeparametertype parameter;    Datatype.find (Extendedtypenum (WorkOrderNum2));     if (Datatype.parmrecid ())    {        ttsbegin;         where parameter. Numbersequencedatatype = = datatype.parmrecid ()        ; where record. recid==datatype.parmrecid ();        Ttscommit;    }    }

Reference: White paper:using The enhanced number Sequence frameworks in Microsoft Dynamics AX 2012

[AX] AX2012 number sequence framework: (iii) re-talk number sequence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.