Tuesday, March 7, 2017

Item CostPrice per dimension Ax2012

Hi guys,

Just a quick code snippet to fetch the CostPrice of an Item based on the dimensions:

public void ale_GetCostPrice()
{
    InventDim       inventDim;
    InventDimParm   inventDimParm;
    InventOnHand    inventOnHand;
    InventSum       inventSum;

    select firstOnly1 ItemId from inventSum
        where inventSum.ItemId == this.ItemId;

    inventDim.InventSiteId = this.inventDim().InventSiteId;
    inventDim.InventLocationId = this.inventDim().InventLocationId;
    inventDim.wMSLocationId = this.inventDim().wMSLocationId;
    inventDim.InventProfileId_RU = this.inventDim().InventProfileId_RU;
    inventDimParm.initFromInventDim(inventDim);

    inventOnHand = InventOnHand::newItemDim(inventSum.ItemId, inventDim, inventDimParm);

    ttsBegin;
    this.CostPrice = inventOnHand.costPricePcs();
    this.inventMovement().journalSetCostPrice();
    this.update();
    ttsCommit;
}

No comments:

Post a Comment