Quintiq file version 2.0
#parent: #root
Method New (
  internal[GUIComponent] parent
) as ServiceLevel id:Method_DialogCreateEditServiceLevel_New
{
  #keys: '[113694.2.1011960792]'
  Body:
  [*
    // Create new service level
                           
    product := guard( DataHolderChildProducts.Data().Element( 0 ), 
                      select( MacroPlan, Product_MP, e, true ) );
                      
    stockingpoint := guard( DataHolderChildStockingPoints.Data().Element( 0 ), 
                            select( MacroPlan, StockingPoint_MP, e, true ) );
    
    data := MacroPlan.ServiceLevel( relshadow,
                                    ID := MacroPlan.IDHolder().GetServiceLevelID(),
                                    Product_MP := product,
                                    StockingPoint_MP := stockingpoint,
                                    Start := MacroPlan.Start().Date(),
                                    End := MacroPlan.End().Date() );
    
    Dialog.Data( data );
    
    this.EnableDisableComponents();
    
    result := this.DoModal( parent );
    
    servicelevel := null( ServiceLevel )
    
    if( result > 0 )
    {
      servicelevel := ServiceLevel::Create( MacroPlan,
                                            '',// id, auto generate by system
                                            data.IsEnabled(),
                                            data.Name(),
                                            data.Product_MP(),
                                            data.StockingPoint_MP(),
                                            data.SalesSegment_MP(),
                                            data.TargetPercentage(),
                                            data.Start(),
                                            data.End(),
                                            true,
                                            false,
                                            false );
                                    
    }
    
    return servicelevel;
  *]
}
