Available and reserved inventory quantities in AX 2012 R3, BP check implementation

As you might already know it is not safe to use inventSum in the code for items that are using warehouse management processes.
For more details you can follow next link: Upgrading code that relies on available and reserved inventory quantities in AX 2012 R3
In short there is replacement table:
Obsolete field/method			Corresponding InventIAvailability method

InventSum.AvailOrdered			InventIAvailability.availTotal()
InventSum.availOrderedCalculated()	InventIAvailability.availTotal()
InventSum.AvailPhysical			InventIAvailability.availPhysical()
InventSum.availPhysicalCalculated()	InventIAvailability.availPhysical()
InventSum.availReservation()		InventIAvailability.availReservation()
InventSum.Ordered			InventIAvailability.ordered()
InventSum.orderedSum()			InventIAvailability.orderedSum()
InventSum.ReservOrdered			InventIAvailability.reservOrdered()
InventSum.ReservPhysical		InventIAvailability.reservPhysical()
For example:
inventSum.ReservPhysical
Should be replaced with:
InventAvailabilityProvider::findByItemIdDim(_itemId, _inventDimCriteria).reservPhysical().parmInventQty()

To be on safe side implement BP check, class to modify SysBPCheckMemberFunction:
Add new method:
/*
    This method checks the source text for calls to InventSum methods that should not be called
    see http://blogs.msdn.com/b/dynamicsaxscm/archive/2014/05/05/upgrading-code-that-relies-on-available-and-reserved-inventory-quantities-in-ax-2012-r3.aspx
*/
protected boolean CheckObsoleteInventSum()
{
    xRefTmpReferences thisRefererences;
    boolean           ret = false;
    Map                 deprecatedFields = new Map(Types::String, Types::String);
    Map                 deprecatedMethods = new Map(Types::String, Types::String);

    deprecatedFields.insert('AvailOrdered', 'InventIAvailability.availTotal()');
    deprecatedFields.insert('AvailPhysical', 'InventIAvailability.availPhysical()');
    deprecatedFields.insert('Ordered', 'InventIAvailability.ordered()');
    deprecatedFields.insert('ReservOrdered', 'InventIAvailability.reservOrdered()');
    deprecatedFields.insert('ReservPhysical', 'InventIAvailability.reservPhysical()');

    deprecatedMethods.insert('availOrderedCalculated','InventIAvailability.availTotal()');
    deprecatedMethods.insert('availPhysicalCalculated','InventIAvailability.availPhysical()');
    deprecatedMethods.insert('availReservation','InventIAvailability.availReservation()');
    deprecatedMethods.insert('orderedSum','InventIAvailability.orderedSum()');


    // check if things are used, that are being superseed by something new
    thisRefererences.setTmpData(tmpxRefReferences);
    while select thisRefererences
        where thisRefererences.ParentName == 'InventSum'
        &&   (thisRefererences.Kind == xRefKind::TableInstanceMethod ||
               thisRefererences.Kind == xRefKind::TableField)
    {
        switch (thisRefererences.Kind)
        {
            case xRefKind::TableInstanceMethod:
                if ( deprecatedMethods.exists(thisRefererences.name) )
                {
                    ret = true;
                    sysBPCheck.addError(#BPErrorMethodDiscontinuedInLaterVers, thisRefererences.Line, thisRefererences.Column, strFmt("@SYS68910", thisRefererences.ParentName,
                                       (thisRefererences.Kind == xRefKind::ClassInstanceMethod || thisRefererences.Kind == xRefKind::TableInstanceMethod || thisRefererences.Kind == xRefKind::MapInstanceMethod) ? '.' : '::',
                                        thisRefererences.Name, deprecatedMethods.lookup(thisRefererences.name)));
                    break;
                }
            case xRefKind::TableField:
                if ( deprecatedFields.exists(thisRefererences.name) )
                {
                    ret = true;
                    sysBPCheck.addError(#BPErrorMethodDiscontinuedInLaterVers, thisRefererences.Line, thisRefererences.Column, strFmt("@SYS68910", thisRefererences.ParentName,
                                       '.',
                                        thisRefererences.Name, deprecatedFields.lookup(thisRefererences.name)));
                    break;
                }
        }
    }
    return ret;
}
Modify \Classes\SysBPCheckMemberFunction\check and add to the end:
this.CheckObsoleteInventSum();

 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags