| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod Delete ( | 
|   PeriodSpecification_MPs perioddefinitions | 
| ) | 
| { | 
|   Description: 'Delete multiple period definitions' | 
|   TextBody: | 
|   [* | 
|     // Cannot use MacroPlan::DeleteObjects because the logic is different. | 
|      | 
|     macroplan := guard( perioddefinitions.Element( 0 ).MacroPlan(), null( MacroPlan ) ); | 
|      | 
|     traverse( perioddefinitions, Elements, pdef ) | 
|     { | 
|       pdef.Delete(); | 
|     } | 
|      | 
|     //Synchronize periods | 
|     traverse( macroplan, PeriodSpecification_MP, periodspec ) | 
|     { | 
|       periodspec.SynchronizePeriods(); | 
|     } | 
|      | 
|     if( not isnull( macroplan ) ) | 
|     { | 
|       macroplan.SynchronizeBasePeriods(); | 
|       macroplan.SynchronizeGapPlanningPeriods(); | 
|      | 
|       // We need to create pispips for new base periods | 
|       // Now that pispip has different subclasses, we need to | 
|       // recreate them whenever the following attributes change | 
|       // Product.IsLeaf, Period.IsBase and Period.IsPlanning | 
|       periods := selectset( macroplan, Period_MP, period, true ) | 
|       pisps := selectset( macroplan, Product_MP.ProductInStockingPoint_MP, pisp, true ) | 
|       macroplan.CreateProductInStockingPointInPeriod( pisps, periods, false /*isondelete*/ ); | 
|      | 
|       // when period spec is deleted, planning is not changed so just pass in false | 
|       Forecast::SynchronizeSalesDemand( macroplan, false ); | 
|     } | 
|   *] | 
| } |