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

Announcements

No record found.

News and Announcements icon
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

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans