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)

On-Hand Inventory within selected dates

(0) ShareShare
ReportReport
Posted on by 10,796 User Group Leader

Hi experts,

Is there any way in AX 2009 that I can get the On-Hand Inventory within the selected date ranges by user.

e.g. I want to have the inventory like How much I had in month January. 

Do I need to maintain the history for it separately or Is there any other way to achieve this requirement.

*This post is locked for comments

I have the same question (0)
  • Amir Nazim Profile Picture
    5,994 on at

    few days back i came accrose similar scenario, and the below jobs helps me, but you might needs to modify it for your date range.

    static void findingOnHandByDate(Args _args)
    {
        ItemId itemId;
        InventDim inventDimCriteria;
        InventDimParm inventDimParm;
        InventSumDateDim inventSumDateDim;
        ;
        // Specify the item to get onhand info on
        itemId = "1001";
        inventDimCriteria.InventColorId = "02";
        inventDimParm.initFromInventDim(inventDimCriteria);
        inventSumDateDim =
        InventSumDateDim::newParameters(mkdate(01,01,2009),
        itemId,
        inventDimCriteria,
        inventDimParm);
        info(strfmt("PostedQty: %1",inventSumDateDim.postedQty()));
        info(strfmt("DeductedQty: %1",inventSumDateDim.deductedQty()));
        info(strfmt("ReceivedQty: %1",inventSumDateDim.receivedQty()));
    }

  • kr@nthi Profile Picture
    210 on at

    Generally on hand will be viewed on a particular date. But not between the days.

    Even if you want that - you need find out the difference of receipts and issue transactions in that period. the value may be negative some time, if the issues are more than receipts(it can happen if you have opening stock)

  • Community Member Profile Picture
    on at

    Amir,

    The x++ job you posted, can you explain a little bit more about the InventSumDateDim class?  I too have a similar request, to be able to view on hand inventory for the entire previous year, so we can then get an average on hand inventory for the year per item.

    The AX report "Inventory by item group aging report" will show on hand quantities for a particular date but we would have to run this for every item group 365 times.  (That would take us an entire year to do!)

    I was thinking about writing another class that uses the inventReport_Age class to somehow calculate these quantities quickly and perhaps store them in a custom table.  Do you have any experience with using this class?

    I was going to start development on this until I saw your post using InventSumDateDim, which there really is no documentation anywhere about what it does or what it is intended for.

    Also thinking maybe of writing a SQL stored procedure to query inventTrans table to find the on hand for the past year but this presents some challenges like kr@nthi mentioned.

    Would really like to hear your thoughts / suggestions.

    Thanks in advance.

    -Kent

  • Suggested answer
    Community Member Profile Picture
    on at

    I think I have a solution using Amir's job.  The following will loop through each day of the year, get the on hand quantity and then divide by 365 to get the avg on hand qty per year for one specific item.  You can further modify this by looping through each item in inventtable and perhaps creating a custom table that stores the values.  Thanks to Amir for the idea!~

    static void findingOnHandByDate(Args _args)
    {
        ItemId itemId;
        InventDim inventDimCriteria;
        InventDimParm inventDimParm;
        InventSumDateDim inventSumDateDim;
        TransDate start, finish;
        int c;
        int onHandTotal;
        ;
        start = str2date("1/1/2010", 213);
        finish = str2date("12/31/2010", 213);
        onHandTotal = 0;
        while(start != finish)
        {
            c++;
            // Specify the item to get onhand info on
            itemId = "00017470";

            inventSumDateDim =
            InventSumDateDim::newParameters(start,
                                    itemId,
                                    inventDimCriteria,
                                    inventDimParm);

            info(strfmt("Date: %1 on hand: %2", start, num2str(inventSumDateDim.postedQty() + inventSumDateDim.receivedQty() - inventSumDateDim.deductedQty(), 0, 2, 1, 1)));
            onHandTotal += (inventSumDateDim.postedQty() + inventSumDateDim.receivedQty() - inventSumDateDim.deductedQty());
            start += 1;
        }
        info(strfmt("Avg on hand per year: %1", onHandTotal / 365));
    }

  • Elchin Ibrahimov Profile Picture
    10 on at

    Hi Kent,

    isn't there any default report to pull report about same information (average inventory on hand during one year)? I dont know programming so i cant use what you have written above.

  • Sumit Bhagat Profile Picture
    121 on at

    Hi,

    How can I get a unit price for a particular date for an Item. Suppose I have used your code to find On hand inventory for particular Item. But It only shows its quantity. Then How can I get Price for that Item on that particular date.

  • Community Member Profile Picture
    on at

    Elchin, I do not know of any in AX 2009.  You could build one of course using the above code I have provided.  You will need to contact your developer or partner.  Good luck!

  • Suggested answer
    Community Member Profile Picture
    on at

    Sumit,

    Without digging into your question, if you sell the item everyday, you can join your result set back to your inventory transactions or your sales line data and pull the unit price from there.  As far as I know, out of the box functionality does not store unit prices on a daily basis.  You can however build something in AX to save this data.  Good luck!

  • Suggested answer
    Tungman Profile Picture
    110 on at

    Qty                         qtyonhand;

       Qty findOnHandByDate(ItemId _itemId, InventDim _inventDim, Date _date)

       {

           InventDimParm    inventDimParmCrit;

           InventSumDateDim inventSumDateDim;

       ;

           // Set the dimensions

           inventDimParmCrit.initFromInventDim(_inventDim);

           inventSumDateDim = inventSumDateDim::newParameters(_date, _itemId, _inventDim, inventDimParmCrit);

           return InventSumDateDim.postedQty() - InventSumDateDim.deductedQty() + InventSumDateDim.receivedQty();

       }

       dim.initValue();

       dim.InventLocationId = "At Site";

       dim.InventSiteId = "STM";

       dim.wMSLocationId = "I/O";

       dim = InventDim::findOrCreate(dim);

       qtyonhand = findOnHandByDate("150010000029",dim,mkDate(01,11,2016));

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans