Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method GetHasValidConversionFactorInUse ( 
 | 
  output Strings feedback_o, 
 | 
  output Strings sanitycheckfeedback_o 
 | 
) declarative remote as Boolean 
 | 
{ 
 | 
  Description: 'Check if the unit of measure is in use and have conversion factor defined.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Check if the unit of measure is in use and have conversion factor defined 
 | 
    isvalid := true; 
 | 
     
 | 
    // Check whether the UnitOfMeasure has valid conversion factor only if it is in use 
 | 
    if( this.IsInUse() ) 
 | 
    { 
 | 
      feedback := ''; 
 | 
      // Select the invalid process IO 
 | 
      invalidpio := select( this, AsPISPUnitOfMeasurement, pio, not pio.HasValidConversionFactor() ); 
 | 
     
 | 
      isvalid := isnull( invalidpio ); 
 | 
     
 | 
      // Check if any invalid process IO is found 
 | 
      // Invalid process IO found 
 | 
      if( not isvalid ) 
 | 
      { 
 | 
        // Generate feedback text with the invalid process IO found 
 | 
        entityname := invalidpio.DefinitionName() + ' ' + invalidpio.GetProcessName(); 
 | 
        spuomname := MacroPlan::GetSubstituteName( guard( invalidpio.PISPUnitOfMeasurement().Name(), '' ) ); 
 | 
        unitoumname := MacroPlan::GetSubstituteName( guard( invalidpio.UnitUnitOfMeasurement().Name(), '' ) ); 
 | 
     
 | 
        feedback := Translations::MP_UnitOfMeasure_ViolateHasValidConversionFactorInUse( spuomname, 
 | 
                                                                                         unitoumname, 
 | 
                                                                                         entityname ); 
 | 
        sanitycheckfeedback_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() ); 
 | 
      } 
 | 
      // No invalid process IO found 
 | 
      else 
 | 
      { 
 | 
        // Select the invalid sales demand 
 | 
        invalidsd := select( this, SalesDemand, sd, not sd.HasValidConversionFactor() ); 
 | 
     
 | 
        isvalid := isnull( invalidsd ); 
 | 
     
 | 
        // Check if any invalid sales demand is found 
 | 
        if( not isvalid ) 
 | 
        { 
 | 
          // Generate feedback text with the invalid sales demand found 
 | 
          entityname := Translations::MP_SalesDemand_Instance( invalidsd.ProductInStockingPoint_MP().Name(), 
 | 
                                                               guard( invalidsd.SalesSegment_MP().Name(), "" ), 
 | 
                                                               invalidsd.StartDate(), 
 | 
                                                               invalidsd.EndDate(), 
 | 
                                                               invalidsd.GetTypeName() ); 
 | 
     
 | 
          sduomname := MacroPlan::GetSubstituteName( guard( invalidsd.UnitOfMeasure_MP().Name(), '' ) ); 
 | 
          uompispname := MacroPlan::GetSubstituteName( guard( invalidsd.ProductInStockingPoint_MP().UnitOfMeasure_MP().Name(), '' ) ); 
 | 
     
 | 
          feedback := Translations::MP_UnitOfMeasure_ViolateHasValidConversionFactorInUse( sduomname, 
 | 
                                                                                           uompispname, 
 | 
                                                                                           entityname ); 
 | 
          sanitycheckfeedback_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() ); 
 | 
        } 
 | 
      } 
 | 
     
 | 
      // Add instance text if any of the preconditions above are violated 
 | 
      if( not isnull( feedback_o ) and not isvalid ) 
 | 
      { 
 | 
        instance := UnitOfMeasure_MP::GetInstanceText( this.Name() ); 
 | 
        feedback_o.Add( SanityCheckMessage::GetFormattedMessage( instance, feedback ) ); 
 | 
      } 
 | 
    } 
 | 
     
 | 
    return isvalid; 
 | 
  *] 
 | 
} 
 |