Quintiq file version 2.0
|
#parent: #root
|
Method SynchronizeInventorySpecInServiceLevel
|
{
|
Description:
|
[*
|
This method updates the InventorySpecificationInServiceLevel instances that link this service level to the relevant inventory specifications.
|
An inventory specification is relevant for the service level if it can influence the service level.
|
This means that it is specified either on a pispip of the service level, or on an upstream pispip of this service level.
|
*]
|
TextBody:
|
[*
|
// Martijn Oct-18-2016 (created)
|
|
// Set all IsSynchronized of the InventorySpecificationInServiceLevel related to this service level to false
|
// This allows us to track which InvSpecInSL are outdated and need to be deleted
|
traverse( this, InventorySpecificationInServiceLevel, invspecinsl )
|
{
|
invspecinsl.IsSynchronized( false );
|
}
|
|
sdips := this.GetSalesDemandInPeriods()
|
pispips := selectset( sdips, Elements.AsSalesDemandInPeriodBase, pispip, true );
|
|
// Add all upstream pispips to the pispips set
|
traverse( pispips, Elements, pispip )
|
{
|
pispip.GetUpstreamPISPIPs( 20, pispips );
|
}
|
|
traverse( pispips, Elements.InventorySpecification, invspec )
|
{
|
// Create the instance of the invspecinservicelevel that links the inventory specification to the service level
|
// The create method will check whether it already exists
|
invspecinsl := InventorySpecificationInServiceLevel::Create( invspec, this );
|
// This invspecinsl has been synchronized
|
invspecinsl.IsSynchronized( true );
|
}
|
|
// Delete all the remaining invspecinsl that have not been synchronized
|
// since these invspecinsl are outdated
|
traverse( this, InventorySpecificationInServiceLevel, invspecinsl, not invspecinsl.IsSynchronized() )
|
{
|
invspecinsl.Delete()
|
}
|
|
// Delete all the unused PeriodTaskOperations and Trips (that were created to identify the upstream pispips )
|
// Any PeriodTaskOperation/Trip with a userquantity or with feedback should not be deleted
|
traverse( this, AsAllServiceLevelBase.Unit.Operation.PeriodTaskOperation, periodtaskoperation,
|
periodtaskoperation.Quantity() = 0.0
|
and not periodtaskoperation.HasUserQuantity()
|
and not periodtaskoperation.HasFeedback() )
|
{
|
periodtaskoperation.Delete();
|
}
|
traverse( this, AsAllServiceLevelBase.Unit.Lane.LaneLeg.Trip, trip )
|
{
|
traverse( trip, ProductInTrip, pit,
|
pit.Quantity() = 0.0
|
and not pit.HasUserQuantity()
|
and not pit.HasFeedback() )
|
{
|
pit.Delete();
|
}
|
if( trip.ProductInTrip( relsize ) = 0 )
|
{
|
trip.Delete();
|
}
|
}
|
*]
|
}
|