Showing posts with label inventDim. Show all posts
Showing posts with label inventDim. Show all posts

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;
}

Wednesday, December 14, 2016

Display method on InventOnHandItem form

Hi guys,

Today I faced a very typical issue while adding a new display field in InvnetOnHandItem. I had to show the sum of a quantity from a customized table based on ItemId and Warehouse. Now the problem here was the grouping between InventSum and InventDim due to which I was not getting the value of InventDimId in InventSum.

So after a lot of failed techniques, I found a solution to use the InventDim values and the code is below:

display public InventQtyReservOrdered ale_PendingVerificationQty(InventSum _inventSum)
{
    InboundWebOrderLine     inboundWebOrderLine;
    InventDim               joinDim, dimValues;
    InventDimParm           dimParm;

    dimValues.data(_inventSum.joinChild());
    dimParm.initFromInventDim(dimValues);

    select sum(QtyOrdered) from inboundWebOrderLine
        where inboundWebOrderLine.ItemId == _inventSum.ItemId
        && (inboundWebOrderLine.EcomMerchantLocation == dimValues.InventLocationId
        || inboundWebOrderLine.EcomMerchantLocation != '')
        && inboundWebOrderLine.EcomBridgeOrderItemStatus == EcomBridgeOrderItemStatus::Ordered;

    return inboundWebOrderLine.QtyOrdered;
}

This method worked like a charm and a had sigh of relief. :)