| Quintiq file version 2.0 | 
| #parent: #root | 
| Method SmartPlanGapFill ( | 
|   Boolean isusingselectedunits, | 
|   Units units, | 
|   LibOpt_Scope scope, | 
|   RunContextForCapacityPlanning runcontext | 
| ) | 
| { | 
|   Description: 'gap filling routing to make optimizer horizon contiguous per pispip' | 
|   TextBody: | 
|   [* | 
|     if ( runcontext.IsMetaIteration() )  | 
|     { | 
|       error( 'Not expecting to use this case anymore' );  | 
|     } | 
|     else | 
|     { | 
|       hasgap := true | 
|        | 
|       for( i:= 1; i<= 100 and hasgap; i++ ) | 
|       {    | 
|         nomoregap := true; | 
|        | 
|         traverse( scope.GetProductInStockingPointInOptimizerRun(), Elements, pisp ) | 
|         { | 
|           firstpispip := minselect( pisp, ProductInStockingPointInPeriodPlanning, pispip, scope.Contains( pispip.PISPIPInOptimizerRun() ), pispip.Start() ); | 
|           lastpispip := maxselect( pisp, ProductInStockingPointInPeriodPlanning, pispip, scope.Contains( pispip.PISPIPInOptimizerRun() ), pispip.End() ); | 
|            | 
|           traverse( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispip, | 
|                     not scope.Contains( pispip.PISPIPInOptimizerRun() )  | 
|                     and pispip.Start() >= firstpispip.Start() | 
|                     and pispip.End() <= lastpispip.End() ) | 
|           { | 
|             this.SetOptimizerInputSmartPlan( pispip, isusingselectedunits, units, 0 /*depth*/, scope, runcontext ); | 
|             nomoregap := false; | 
|           } | 
|         } | 
|         hasgap := not nomoregap; | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |