| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetHasNoDirectLoop ( | 
|   output Strings feedback_o, | 
|   output Strings sanitychecklevel_o | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Check if the lane leg has no direct loop (loop within 1 level, e.g. A->B and B->A)' | 
|   TextBody: | 
|   [* | 
|     isvalid := true; | 
|      | 
|     // The loop should only be violated if both legs that are causing the loop are enabled | 
|      | 
|     if( this.IsEnabled() and exists( this, LaneLegInputOutput.ProductInStockingPoint_MP.Product_MP, product, product.HasShelfLifeOrMaturation() ) ) | 
|     { | 
|       directlooplaneleg := select( this, AsDestinationStockingPointLeg.StockingPoint_MP.StockingPointInLane.OriginStockingPointLeg, o, | 
|                                    o.IsEnabled() | 
|                                    and o.DestinationStockingPointID() = this.OriginStockingPointID() ); | 
|       | 
|      //check whether there are any overlap product in both laneleg                               | 
|       productindirectlooplaneleg := selectset( directlooplaneleg, Lane.ProductInLane.Product_MP, p, p.HasShelfLifeOrMaturation() ); | 
|       currentproduct := selectset( this, Lane.ProductInLane.Product_MP, p, p.HasShelfLifeOrMaturation() ); | 
|       productoverlap := currentproduct.Intersect( productindirectlooplaneleg );  | 
|        | 
|       isvalid := isnull( directlooplaneleg ) or productoverlap.Size() =0 ; | 
|        | 
|       if( not isnull( feedback_o ) and not isvalid ) | 
|       { | 
|         name := MacroPlan::GetSubstituteName( this.Name() ); | 
|         feedback_o.Add( SanityCheckMessage::GetFormattedMessage( Translations::MP_Process_Instance( this.DefinitionName(), name ), | 
|                                                                  Translations::MP_LaneLeg_ViolateHasNoDirectLoop( directlooplaneleg.Lane().Name() ) ) ); | 
|         sanitychecklevel_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() );                                                            | 
|       } | 
|     } | 
|      | 
|     return isvalid; | 
|   *] | 
| } |