Quintiq file version 2.0
#parent: #root
Method GeneratePlanningMatrixData () id:Method_FormSupplyPlanning_GeneratePlanningMatrixData
{
  #keys: '[134266.2.80098287]'
  Body:
  [*
    // Generate shadow planning cells
    owner := shadow( MacroPlan.GlobalParameters_MP() );
    
    
    traverse ( ApplicationMacroPlanner.DataHolderPeriods().Data(), Elements, period, period.IsPlanning() )
    {
      traverse( DataHolderProcess.Data(), Elements, process ) // For each ROW
      {
        
        pisp := DataHolderSCVSelection.Data().Element( 0 );
        pispip := select( pisp, ProductInStockingPointInPeriodPlanning, p, p.Period_MP() = period );
        
        newsupplies := selectset( process, SupplyBase.astype( NewSupply ), ns, ns.ProductInStockingPointInPeriodPlanning() = pispip, true );
        
        qty := sum( newsupplies, Elements, e, e.Quantity() );
    
        // For Operation 
        periodtask := select( newsupplies, Elements.PeriodTask_MP.astype( PeriodTaskOperation ), e , true );
        // For trip
        productintrip := select( newsupplies, Elements.ProductInTrip, e, true );
       
        owner.PlanningCell( relnew,
                                                              Process_MP := process,
                                                              ProductInStockingPointInPeriodPlanning := pispip,
                                                              PeriodTask_MP := periodtask,
                                                              ProductInTrip := productintrip,
                                                              Quantity := qty,
                                                              InventoryQuantity := guard( pispip.InventorySupplyQuantity() + pispip.InventoryLevelStart(), 0.0 ) );                                                              
      }
    }
    DataHolderShadowGlobalParameters.Data( &owner );
  *]
}
