Quintiq file version 2.0
#parent: #root
Method GeneratePlanningMatrixData () id:Method_FormSupplyPlanWebClient_GeneratePlanningMatrixData
{
  #keys: '[127710.1.1993166152]'
  Body:
  [*
    // Generate shadow planning cells
    
    if( not isnull( DataHolderProductInSPIP.Data() ) and DataHolderProductInSPIP.Data().Size() > 0 )
    {   
      DataHolderShadowGlobalParameters.Data( null( shadow[GlobalParameters_MP], owning ) );
      owner := shadow( MacroPlan.GlobalParameters_MP() );
      DataHolderShadowGlobalParameters.Data( &owner );
      
      traverse ( DataHolderMatrixEditorColumns.Data(), Elements, period )
      {        
        traverse( DataHolderMatrixEditorRows.Data(), Elements, process ) // For each ROW
        {
          pisp := DataHolderProductInStockingPoints.Data().Element( 0 );
          pispip := select( pisp, ProductInStockingPointInPeriodPlanning, p, p.Period_MP() = period )
            
          qty := sum(  process, SupplyBase.astype(  NewSupply ), ns, ns.ProductInStockingPointInPeriodPlanning() = pispip, ns.Quantity() );
          //total qty this routing has produced on the selected pispip
          if( process.istype(  Operation ) )
          {
            routing := process.astype(  Operation ).RoutingStep().Routing();                                    
            qty := sum(  routing, OperationOutput.NewSupply, ns, ns.ProductInStockingPointInPeriodPlanning() = pispip, ns.Quantity() );
          }  
    
          // Create a new shadow AccountCostInPeriod
          DataHolderShadowGlobalParameters.Data().PlanningCell( relnew,
                                                                Process_MP := process,
                                                                ProductInStockingPointInPeriodPlanning := pispip,
                                                                Quantity := qty,
                                                                InventoryQuantity := pispip.InventorySupplyQuantity() + pispip.InventoryLevelStart() );
        }
      }
    }
  *]
}
