Modify MRP behavior in a Customization

How to alter MRP functionality in the MrpProcessCustomization

This guide will step through the process of coding a CanBatchCapacity customization. If you are just getting started, you can learn about getting started with customizations

Process Overrides

Creating the Class

To start, we will need to create a new class that inherits from PT.Scheduler.Simulation.Customizations.MRP.MrpProcessCustomization.

Here is what a  sample class that resets supply job need dates to the Sales Order date

public class ResetJobNeedDates : PT.Scheduler.Simulation.Customizations.MRP.MrpProcessCustomization
{
public override string Name => "MRP Re-peg job need dates";

public override string Description => "Reset all job need dates to sales order demand during MRP";

/// <summary>
/// Adjust need date to match SalesOrder demand. It's possible the SO required date was updated since the job was generated. Re-peg the need dates
/// </summary>
protected override DateTime? PegAllocationNeedDate(ScenarioDetail a_sd, Job a_existingJob, Adjustment a_negativeAdjustment)
{
if (a_negativeAdjustment.Reason is SalesOrderLineDistribution a_soDistribution)
{
if (a_existingJob.NeedDateTime != a_soDistribution.RequiredAvailableDate)
{
return a_soDistribution.RequiredAvailableDate;
}
}

return null;
}
}

Reset Supplying Job Need Date

Let's take a look at the parameters for ExistingOrderNeedDateReset:

  • ScenarioDetail a_sd: The current scenario data. This can be used to reference objects within the system, however, the data cannot be changed.
  • Job a_existingJob: The existing job that MRP is using to satsify a demand.
  • Adjustment a_positiveAdjustment: The current supply adjustment. This includes the time, quantity, and Reason of the supply. Reason is a reference to the object, for example, the PurchaseToStock, InternalActivity or TransferOrderDistribution.
  • decimal a_unallocatedQty: The quantity from this supply that has not been allocated to a demand yet.

Example

//Set the need date of the job if it's still planned/estimate and it's not partially allocated to a previous negative adjustment
protected override DateTime? ExistingOrderNeedDateReset(ScenarioDetail a_sd, Job a_existingJob, Adjustment a_positiveAdjustment, decimal a_unallocatedQty)
{
if (a_existingJob.NeedDateTime != a_positiveAdjustment.AdjDate)
{
if (a_existingJob.Commitment != JobDefs.commitmentTypes.Released
&& a_existingJob.Commitment != JobDefs.commitmentTypes.Firm
&& a_unallocatedQty == a_positiveAdjustment.ChangeQty)
{
return a_positiveAdjustment.AdjDate;
}
}

return null;
}

Decide whether a supply job can satisfy a demand

Let's take a look at the parameters for CanExistingSupplySatisfyDemand:

  • ScenarioDetail a_sd: The current scenario data. This can be used to reference objects within the system, however, the data cannot be changed.
  • Job a_potentialSupplyJob: The existing job that MRP is using to satisfy a demand.
  • DateTime a_demandAdjustmentDate: The need date of the demand.

Example

public override bool CanExistingSupplySatisfyDemand(ScenarioDetail a_sd, Job a_potentialSupplyJob, DateTime a_demandAdjustmentDate)
{
if ((a_potentialSupplyJob.Commitment == JobDefs.commitmentTypes.Released || a_potentialSupplyJob.Commitment == JobDefs.commitmentTypes.Firm) && (a_potentialSupplyJob.NeedDateTime > a_demandAdjustmentDate))
{
//This is a released or firm job. It's possible that it is late and can't satisfy the demand, however if it is planned (ie NeedDate) before the required date, peg this job anyways
return false;
}

return true;
}

Set Supply Order Need Date when pegged to Demand

Let's take a look at the parameters for PegAllocationNeedDate:

  • ScenarioDetail a_sd: The current scenario data. This can be used to reference objects within the system, however, the data cannot be changed.
  • Job a_existingJob: The existing job that MRP is using to satisfy a demand.
  • Adjustment a_negativeAdjustment: The current demand adjustment. This includes the time, quantity, and Reason of the demand. Reason is a reference to the object, for example, the SalesOrderLineDistribution, InternalActivity, ForecastShipment, or TransferOrderDistribution.

Example

protected override DateTime? PegAllocationNeedDate(ScenarioDetail a_sd, Job a_existingJob, Adjustment a_negativeAdjustment)
{
//Add additional buffer by setting the needdate a few days earlier than when needed
return a_negativeAdjustment.AdjDate.Subtract(TimeSpan.FromDays(3));
}

Next Steps

Take a look at other customization that can be used to modify the way orders schedule after MRP: Customization Index