Tuesday, July 23, 2019

Get OnHand Stock value using Warehouse, Date and ItemId using X++

 public real GetOnHandStock(InventLocationId _warehouse,TransDate _transDate,Itemid _itemid)
    {
        InventDim                   inventDim;
        InventDimParm               inventDimParm;
        InventLocation              inventLocation;
        InventSumDatePhysicalDim    inventSumDatePhysicalDim;
        real                        OnhandQty;
        inventLocation              = InventLocation::find(_warehouse);
        inventDim.wMSLocationId     =inventLocation.WMSLocationIdDefaultReceipt;
        inventDim.InventLocationId  = inventLocation.InventLocationId;
        inventDim.InventSiteId      =inventLocation.InventSiteId;
        inventDim                   = InventDim::findOrCreate(inventDim);
        inventDimParm.initFromInventDim(inventDim);
        OnhandQty                    =    InventSumDatePhysicalDim::onHandQty(_transDate,_itemid,inventDim,inventDimParm);
        return OnhandQty;
    }

No comments:

Post a Comment

using SQL Query in X++

 If you need to execute sql query inside your X++ code then below example can help you. To pass value to SQL query we need to use strfmt() f...