| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetHasCycle ( | 
|   ProductInStockingPointInPeriod targetpispip, | 
|   output Process_MPs processes_o, | 
|   Number currentdepth, | 
|   Number maxdepth | 
| ) remote as Boolean | 
| { | 
|   Description: | 
|   [* | 
|     Return false if there are a set of processes form a cycle for this pispip, and returns the paths (processes) which form the cycle. | 
|     Used to check pegging circularity | 
|   *] | 
|   TextBody: | 
|   [* | 
|     // soh yee Aug-14-2014 (created) | 
|      | 
|     foundtarget := false; | 
|     currentdepth := currentdepth + 1; | 
|      | 
|     // Start with the dependent demands of all the new supplies. If the targetpispip is found again when performing the depth first search, | 
|     // it means that a cycle is found | 
|     if( currentdepth <= maxdepth ) | 
|     { | 
|       traverse( this, NewSupply.PeriodTask_MP.DependentDemand, dd, | 
|                 not foundtarget           // Stop the search once a cycle is found, or the foundtarget Boolean will be resetted | 
|                 and not dd.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().Product_MP().IsByProduct() ) | 
|       { | 
|         pispip := dd.ProductInStockingPointInPeriodPlanningLeaf(); | 
|      | 
|         foundtarget := pispip = targetpispip | 
|                        or pispip.GetHasCycle( targetpispip, processes_o, currentdepth, maxdepth ); | 
|      | 
|         // Save the period task if a cycle is found for the search branch | 
|         if( foundtarget ) | 
|         { | 
|           processes_o.Add( dd.PeriodTask_MP().Process_MP() ); | 
|         } | 
|       } | 
|     } | 
|      | 
|     return foundtarget; | 
|   *] | 
| } |