How to get advance license in sales order in ax 2012

Description: -

In this article we will see about how to get advance license and date from sales order in ax 2012.

Here I have given simple demonstration to get advance license and date from sales order if you have export order and you have bind advance license with line then you can get advance license number and date from authorization table. Use below Job to get advance license for particular sales order. 

Example:-

static void GetAdvanceLicense(Args _args)
{
    SalesLine SalesLine;
    SalesTable SalesTable;
    EximSalesLine_IN ObjEximSalesLine_IN;
    EximIncentiveSchemeData_IN ObjEximIncentiveSchemeData_IN;
    EximIncentiveSchemeGroup_IN ObjEximIncentiveSchemeGroup_IN;
    EximProductGroupTable_IN ObjEximProductGroupTable_IN;
    EximAuthorizationSchemesLine_IN  authorizationSchemesLine;
    EximAuthorizationSchemesTable_IN authorizationSchemesTable;
    str 50 Authorization;
    BaseDate AuthoDate;
    SalesId _Salesid;

    _Salesid = SalesOrderNumber';
    Authorization ='';
    AuthoDate = dateNull();
    SalesLine.clear();
    SalesTable.clear();
    ObjEximSalesLine_IN.clear();
    ObjEximIncentiveSchemeData_IN.clear();
    ObjEximIncentiveSchemeGroup_IN.clear();
    ObjEximProductGroupTable_IN.clear();
    authorizationSchemesLine.clear();
    authorizationSchemesTable.clear();

    //While start
    while select * from SalesLine
    join SalesTable
    where SalesTable.SalesId == SalesLine.SalesId
    join ObjEximSalesLine_IN
    where ObjEximSalesLine_IN.SalesLineRecId == SalesLine.RecId
    join ObjEximProductGroupTable_IN
    where ObjEximProductGroupTable_IN.RecId == ObjEximSalesLine_IN.EximProductGroupTable
    join ObjEximIncentiveSchemeGroup_IN
    where ObjEximIncentiveSchemeGroup_IN.RecId == ObjEximSalesLine_IN.EximIncentiveSchemeGroup
    && SalesTable.SalesId == _Salesid
    {
        if(SalesLine.RecId != 0 && ObjEximSalesLine_IN.SalesLineRecId != 0 && ObjEximIncentiveSchemeGroup_IN.RecId != 0 && ObjEximProductGroupTable_IN.RecId != 0)
        {
            select * from ObjEximIncentiveSchemeData_IN
            where ObjEximIncentiveSchemeData_IN.EximIncentiveSchemeGroup == ObjEximIncentiveSchemeGroup_IN.RecId
            && ObjEximIncentiveSchemeData_IN.EximProductGroupTable == ObjEximProductGroupTable_IN.RecId;
            if(ObjEximIncentiveSchemeData_IN.RecId != 0)
            {
                //Get AuthorizationId Here
                Authorization =  EximAuthorizationSchemesTable_IN::findByAuthorizationTypeId(ObjEximIncentiveSchemeData_IN.IncentiveScheme,ObjEximIncentiveSchemeData_IN.AuthorizationId).LicenseNum;
                if (ObjEximIncentiveSchemeData_IN.AuthorizationId)
                {
                    select RecId from authorizationSchemesTable
                        where authorizationSchemesTable.AuthorizationId   == ObjEximIncentiveSchemeData_IN.AuthorizationId
                           && authorizationSchemesTable.AuthorizationType == ObjEximIncentiveSchemeData_IN.IncentiveScheme
                        join reverse firstonly ExportExpiryDate
                            from authorizationSchemesLine
                            order by RecId
                            where authorizationSchemesLine.AuthorizationSchemesTableRecId == authorizationSchemesTable.RecId
                               && authorizationSchemesLine.LicenseStatus                  != EximLicenseStatus_IN::Sold;
                    if(authorizationSchemesTable.RecId != 0)
                    {
                        //Get AuthorizationDate Here
                        AuthoDate = authorizationSchemesLine.ExportExpiryDate;
                        info(strFmt("AuthorizationId = %1, Date.%2",Authorization,authorizationSchemesLine.ExportExpiryDate));
                    }
                }
            }
        }
    }
    //While end
}

Related Posts

Previous
Next Post »

Thanks for comments.....