Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method SetSupplyForProcess ( 
 | 
  ProductInStockingPointInPeriodPlanning pispip, 
 | 
  Process_MP process, 
 | 
  Real userQty 
 | 
) 
 | 
{ 
 | 
  Description: 'Set supply quantity for process (operation or lane leg) for particular period. Creates period task operation or trip if not exists.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Get supply for the process 
 | 
    // Used by supply planning matrix (web) and emulating the thin client supply planning matrix 
 | 
    productionSupply := select( pispip, Supply_MP, supply, supply.Process_MP() = process ); 
 | 
     
 | 
    // If supply not exists, create the period task operation or trip 
 | 
    if( isnull( productionSupply ) ) 
 | 
    { 
 | 
      if( process.istype( LaneLeg ) ) 
 | 
      { 
 | 
        pispips := construct( ProductInStockingPointInPeriodPlannings ); 
 | 
        pispips.Add( pispip ); 
 | 
        Trip::CreateWithProductInTrips( pispips, process.astype( LaneLeg ) ); 
 | 
      } 
 | 
      else if( process.istype( Operation ) ) 
 | 
      { 
 | 
        pispip.CreateUpdateOperationNewSupplies( process.astype( Operation ), userQty );  
 | 
      } 
 | 
       
 | 
      // Refresh the new supply so we can update the quantity 
 | 
      Transaction::Transaction().Propagate(); 
 | 
       
 | 
      productionSupply := select( pispip, Supply_MP, supply, supply.Process_MP() = process ); 
 | 
    } 
 | 
     
 | 
    if( not isnull( productionSupply ) ) 
 | 
    { 
 | 
      if ( productionSupply.istype( NewSupply ) ) 
 | 
      { 
 | 
        productionSupply.astype( NewSupply ).Update( userQty,  true );   
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        productionSupply.Update( userQty ); 
 | 
      }   
 | 
    } 
 | 
  *] 
 | 
} 
 |