Hi All,
I just want to get all the items present in an warehouse with the on hand quantity of an item through X++.
Thanking you in advance.
Thanks & Regards,
Kedar
*This post is locked for comments
Hey to further open this question, how do I list the warehouses containing x-item? for example I searched for an item, it will return all the warehouses that contains said item.
What does "in" mean without on-hand? You want to know items with open sales orders or open purchase orders in a specific warehouse?
Hi Brandon,
If I want items present in specific irrespective of on hand then the below code is enough right?
InventSum inventSum;
InventDim inventDimCriteria;
InventDimParm inventDimParmCriteria;
InventDimParm inventDimParmGroupBy;
Query q;
QueryBuildDataSource qbds;
QueryRun qr;
;
inventDimCriteria.InventLocationId = 'W'; // warehouse
inventDimParmCriteria.InventLocationIdFlag = true; // filter on warehouse
inventDimParmGroupBy.ItemIdFlag = true; // group by item
q = InventSum::newQuery(q, '', inventDimCriteria, inventDimParmCriteria, inventDimParmGroupBy);
qr = new QueryRun(q);
while (qr.next())
{
inventSum = qr.get(tableNum(InventSum));
info(strFmt("Item number: %1", inventSum.ItemId));
}
Thank you brandon.
Depending on what you call on-hand, this type of approach is quite easy.
In this code, the filter is on PhysicalInvent, which is PostedQty + Received - Deducted + Registered - Picked. If you're interested in a more "accounting" type of on-hand, that would be PostedQty + Received - Deducted and would require some tweaks.
InventSum inventSum; InventDim inventDimCriteria; InventDimParm inventDimParmCriteria; InventDimParm inventDimParmGroupBy; Query q; QueryBuildDataSource qbds; QueryRun qr; ; inventDimCriteria.InventLocationId = 'W'; // warehouse inventDimParmCriteria.InventLocationIdFlag = true; // filter on warehouse inventDimParmGroupBy.ItemIdFlag = true; // group by item q = InventSum::newQuery(q, '', inventDimCriteria, inventDimParmCriteria, inventDimParmGroupBy); qbds = q.dataSourceTable(tableNum(InventSum)); qbds.addRange(fieldNum(InventSum, PhysicalInvent)).value(SysQuery::valueNot(0)); qr = new QueryRun(q); while (qr.next()) { inventSum = qr.get(tableNum(InventSum)); info(strFmt("Item number: %1", inventSum.ItemId)); }
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Community Member 4
Guy Terry 2 Moderator
Nayyar Siddiqi 2