Blog Listem

9 Ağustos 2016 Salı

AXAPTA - Eldeki miktar (invent on hand)

//source: http://microsoft-dynamics-ax-erp.blogspot.com.tr/2012/07/find-inventonhand-in-axapta-x.html
static InventOnHand findOnHandByLocationId(ItemId _itemId, InventLocationId _inventLocationId = "")
{
    InventDim           inventDim;
    InventDimParm       inventDimParm;
    InventOnHand        inventOnHand = new InventOnHand();
    ;

    if (_inventLocationId == "")

         return InventOnhand::newItemId(_itemId);
    //Take a combination of dimension , against which you want to find the stock
    inventDim.InventLocationId  = _inventLocationId;

    //Set the flag for the selected dimensions as active
    inventDimParm.initFromInventDim(inventDim);

    //Initialize the inventSumDateDim with Date,item,dimension and dim parameter
    inventOnHand = InventOnHand::newParameters(_itemid,
                                               inventDim,
                                               inventDimParm);

    return inventOnHand;
}



veya:

//http://daxtechies.blogspot.com/2013/03/to-find-stock-on-hand-in-ax-through-x.html
InventSum           inventsum;
    Qty                 availableQty = 0;
    ;

    select sum(PostedQty),
        sum(Received),
        sum(Deducted),
        sum(Registered),
        sum(Picked),
        sum(ReservPhysical),
        sum(Ordered),
        sum(Arrived),
        sum(ReservOrdered),
        sum(OnOrder) from inventsum
        where inventsum.ItemId      == "KCYIWU001";
    if (inventsum)
    {
        availableQty = inventsum.PostedQty
            + inventsum.Received
            - inventsum.Deducted
            + inventsum.Registered
            - inventSum.Picked
            - inventSum.ReservPhysical
            + inventsum.Ordered
            + inventsum.Arrived
            - inventsum.ReservOrdered
            - inventsum.OnOrder;

    }