Quintiq file version 2.0
#parent: #root
Method SelectScenarioManager () id:Method_ApplicationLibMacroPlanner_SelectScenarioManager
{
  #keys: '[11660.0.300830511]'
  Body:
  [*
    // Select scenario manager if it is not selected
    if ( isnull( ScenarioManager ) )
    {
      componentmds := ComponentMDS::CreateForLoadedMDSsOnly( Application );
      foldername := GlobalParameters_MP::GetDatasetRoot();
      folder := select( componentmds, Folders, f, f.Name() = foldername );
      mdscomponentkind := select( componentmds, ComponentMDSKinds, kind, kind.Kind() = ScenarioManager::GetDatasetKind() );
      mdsinstance := select( mdscomponentkind, ComponentMDSInstances, m,
                             m.FolderID() = folder.Key(),
                             m.Name() = ScenarioManager::GetDatasetName() );
    
      if( not isnull( mdsinstance ) )
      {
        mdsinstance.ComponentMDSKind().SelectInstance( mdsinstance );
        componentmds.Apply();
      }
    }
  *]
}
