Showing posts with label AvailPhysical. Show all posts
Showing posts with label AvailPhysical. Show all posts

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();

Monday, December 7, 2015

AX 2012 : Add Custom lookup on EP

Add Custom lookup on EP

The trick is to override datasetLookup() on Dataset > data source > field > methods. You will not find this method in the list of override methods so just create this as new method.
the table which we are using for lookup should be in the Dataset


public void dataSetLookup(SysDataSetLookup sysDataSetLookup)
{
    List list = new List(Types::String);

    Query query = new Query();

    QueryBuildDataSource    queryBuildDataSource;

    QueryBuildRange qbr;

    // Add the table to the query.

    queryBuildDataSource  = query.addDataSource(tableNum(DependentDetails));

    //add the range

    qbr = queryBuildDataSource.addRange( fieldnum(DependentDetails, PersonnelNumber));

   // qbr.value(DirPersonUser::currentWorkerPersonnelNumber());

   // qbr.status(RangeStatus::Locked);

     // Specify the fields to use for the lookup.

    list.addEnd(fieldStr(DependentDetails,DependentId));

    list.addEnd(fieldStr(DependentDetails,Name));


     sysDataSetLookup.parmLookupFields(list);

     // Specify the field that is returned from the lookup.

    sysDataSetLookup.parmSelectField('DependentId');

     // Pass the query to the SysDataSetLookup so that the query is used.

    sysDataSetLookup.parmQuery(query);
 
}

Table browser URL in D365FO

Critical Thinking icon icon by Icons8