Sunday, April 11, 2021

InventOnHand for item based on inventory dimensions

class RunnableClass1
{
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        changecompany ("PT01")
        {
            InventDim inventDimLoc;
      
            inventDimLoc.InventSiteId      = "O";
            inventDimLoc.InventLocationId  = "FG";
          //  inventDimLoc.InventStatusId    = "Available";
           // inventDimLoc.wMSLocationId  = "TRO";

            inventDimLoc = InventDim::findOrCreate(inventDimLoc);
            inventDimParm inventDimParmCriteria;
            inventDimParmCriteria.initFromInventDim(inventDimLoc);

            InventOnHandQty inventOnHandQty = InventOnHandQty::newItemDim("110240", inventDimLoc, inventDimParmCriteria);

         //   InventOnhand onhand = InventOnhand::newItemId("110240");
           // onhand.parmInventDimId(InventDimLoc.inventDimId);
            Info(strFmt("%1", inventOnHandQty.availTotal()));
            Info(strFmt("%1", inventOnHandQty.availPhysical()));
            Info(strFmt("%1", inventOnHandQty.physicalInvent()));
        }
    }

}
InventDim inventDimLoc;

inventDimLoc.InventSiteId      = transferOrderProposal.InventSiteIdFrom;

inventDimLoc = InventDim::findOrCreate(inventDimLoc);
inventDimParm inventDimParmCriteria;
inventDimParmCriteria.initFromInventDim(inventDimLoc);

InventOnhand InventOnhand = InventOnhand::newParameters(transferOrderProposal.ItemId, inventDimLoc, inventDimParmCriteria);

temptable.ItemId            = transferOrderProposal.ItemId;
temptable.ProposalModel     = transferOrderProposal.ProposalModel;
temptable.InventSiteIdFrom  = transferOrderProposal.InventSiteIdFrom;
temptable.PhysicalInvent    = InventOnhand.inventSum().PhysicalInvent;
temptable.ReservPhysical    = InventOnhand.inventSum().ReservPhysical;
temptable.AvailPhysical     = InventOnhand.inventSum().AvailPhysical;
temptable.OrderedSum        = InventOnhand.inventSum().orderedSum();
temptable.OnOrder           = InventOnhand.inventSum().OnOrder;
temptable.ReservOrdered     = InventOnhand.inventSum().ReservOrdered;
temptable.AvailReserved     = InventOnhand.inventSum().availReservation(reserveOnOrdered);
temptable.AvailOrdered      = InventOnhand.availTotal();

temptable.insert();

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8