web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Wrong on hand value for WHS enabled item. X++ Ax2012 R3

(0) ShareShare
ReportReport
Posted on by 3,248

Hi

I am using below piece of code to calculate on hand for an item.  Generally it works fine, however for the items that are used in the WHS processes the value returned is wrong. Basically inventOnHand.availPhysical() method fails, i have added the code form std Ax , for the "AvailPhysical method looks like it not returning  correct values. Does anyone encountered it before?


public InventQtyAvailPhysical A_onHand()
{
    InventDim   inventDim;
    InventOnHand    inventOnhand;
    InventDimParm  InventDimParm;
    ;

    InventDimParm.initFromInventDim(inventDim);
    inventOnhand = inventOnhand::newParameters(this.ItemId, inventDim, InventDimParm);
    return inventOnhand.availPhysical();
}

STD AX code:

/// <summary>
/// Gets the the quantity available for physical reservation.
/// </summary>
/// <returns>
/// The quantity in the inventory unit.
/// </returns>
public InventQtyAvailPhysical availPhysical()
{
    // Don't do math for this quantity, instead use the value in InventSum
    // because it's the correct number for WHS Items
    if (itemUsesWHS)
    {
        this.setInventSum();
        this.setAvailability();

        return inventSum.AvailPhysical;
    }
    else
    {
        return (this.physicalInvent() - this.reservPhysical());
    }
}

Thanks

P

*This post is locked for comments

I have the same question (0)
  • Lalit Jivnani Profile Picture
    395 on at

    Hello Pradeep,

    I am encountering the same issue. Can you help me with the piece of code what you did in order to resolve this issue?

  • Lalit Jivnani Profile Picture
    395 on at

    I did every piece of bit..This issue happens only for item with WHS enabled as described by Pradeep..For rest items the code works fine.

  • Suggested answer
    Faqruddin Profile Picture
    1,909 on at

    Hello Pradeep,

    The below code will works for you. It returns Available physical items from Warehouse.

    static void Job3(Args _args)
    {

    InventOnhand inventOnhand;

    InventDim inventDim;

    InventDimParm inventDimParm;

    ItemId itemId;

    InventQty availQty;

    ;

    itemId = 'PN-VC841A'; 

    inventDim.InventSiteId = 'ENPRO'; //site

    inventDim.InventLocationId = 'IT-KHB'; //WHS

    inventDimParm.initFromInventDim(inventDim);

    inventOnhand = InventOnhand::newParameters(itemId, inventDim, inventDimParm);

    availQty = inventOnhand.availPhysical();

    info(strFmt("%1", availQty));

    }

    Regards,

    Faqru

  • Suggested answer
    fatihgork Profile Picture
    3,817 on at

    Hi,

    We have encountered the same issue. The main thing is considering Physical On Hand form's attidute in Warehouse Management module as reference.

    I'm not a developer, so I can't provide you the code but, we develop our codes to show On-hand based on WhsInventReserve table.

    I hope that information helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#2
Volodya Profile Picture

Volodya 2

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans