Generate Number Sequence based on Fynancial year in ax 2012

Description:-

In this article we will see about how to generate number sequence based on financial year in ax 2012.
Here I have Create code for generate number sequence.
Create DataSource Create method and copy paste below code and change your table objects.

    str 60 Value;
    str 60 _newCode;
    int max1;
    FiscalCalendarYear  ObjFiscalCalendarYear;
    str CurrentYear,PreYear,NextYear;
    ;
    super(_append);
    //Getting Year start
    select firstOnly ObjFiscalCalendarYear order by ObjFiscalCalendarYear.StartDate desc
    where ObjFiscalCalendarYear.StartDate <= today()
    && ObjFiscalCalendarYear.EndDate >= today();
    if(ObjFiscalCalendarYear)
    {
       CurrentYear = subStr(int2str(year(ObjFiscalCalendarYear.StartDate)),3,2);
       NextYear = subStr(int2str(year(ObjFiscalCalendarYear.StartDate)+1),3,2);
    }
    if(CurrentYear != NextYear)
    {
        select ObjProdEfficiencyTable order by RecId desc
        where ObjProdEfficiencyTable.ProdEfficiencyNo like subStr(int2str(year(ObjFiscalCalendarYear.StartDate)),3,2)+"*";
        if(!ObjProdEfficiencyTable)
        {
            _newCode= CurrentYear + strRFix(int2str(1),8, "0");
            ProdEfficiencyTable.ProdEfficiencyNo =_newCode;
        }
         else
        {
            max1=str2int(subStr(ObjProdEfficiencyTable.ProdEfficiencyNo,8,4))+1;
            ProdEfficiencyTable.ProdEfficiencyNo = CurrentYear + strRFix(int2str(max1),8, "0");
        }
    }

OUTPUT:- 160000001 160000002 160000003

Related Posts

Previous
Next Post »

Thanks for comments.....