Quintiq file version 2.0
|
#parent: #root
|
Method CleanUpTransportCapacity
|
{
|
Description: 'Find sets of equivalent transport capacities in consecutive periods and remove all but the first one'
|
TextBody:
|
[*
|
// Clean up transport capacity
|
// Get a sorted set of all transport capacities of this unit
|
sortedtcs := selectsortedset( this, TransportCapacity, tc,
|
true,
|
tc.Start() );
|
|
head := null( TransportCapacity );
|
|
// Traverse the sorted set of transport capacities
|
traverse( sortedtcs, Elements, tc )
|
{
|
// Check if there's any transport capacity is selected, if there's none, set the current transport capacity as selected
|
if( isnull( head ) )
|
{
|
head := tc;
|
}
|
|
// Get the index of the selected transport capacity in the sorted set
|
headpos := sortedtcs.Find( head );
|
// Get the next transport capacity after the selected transport capacity in the sorted set
|
nexttc := guard( sortedtcs.Element( headpos + 1 ), null( TransportCapacity ) );
|
|
// Check if there's any next transport capacity
|
if( not isnull( nexttc ) )
|
{
|
// Check if the next transport capacity has the same data as the selected one
|
// If the data is the same, remove the next transport capacity from the sorted set and dataset
|
if( head.HasSameData( nexttc ) )
|
{
|
sortedtcs.Remove( nexttc );
|
nexttc.Delete();
|
}
|
// Else, set the next transport capacity as the selected one
|
else
|
{
|
head := nexttc;
|
}
|
}
|
|
}
|
*]
|
}
|