| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod ValidateInput ( | 
|   output String feedback_o, | 
|   output String sanitycheckcategory_o, | 
|   MacroPlan owner, | 
|   ServiceLevelBase servicelevel, | 
|   String name, | 
|   Product_MP product, | 
|   StockingPoint_MP stockingpoint, | 
|   Real targetpercentage, | 
|   Date start, | 
|   Date end, | 
|   String objecttype | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Validate inputs for service level.' | 
|   TextBody: | 
|   [* | 
|     feedback_o := '' | 
|     sanitycheckcategory_o := ''; | 
|      | 
|     // Check if name is entered | 
|     if( name = '' ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsInvalidName( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if target percentage is within the allowed range | 
|     else if( targetpercentage <= 50 or targetpercentage >= 100 ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsInvalidTargetPercentage( targetpercentage ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if start and end combination is valid | 
|     else if( start > end ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsInvalidStart( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if the new values for service level's safety stock is overlapping with any existing service level | 
|     else if( exists( owner, ServiceLevel, sl, | 
|                      sl <> servicelevel | 
|                      and sl.Product_MP() = product | 
|                      and sl.StockingPoint_MP() = stockingpoint | 
|                      and ( start < sl.End() and end > sl.Start() ) ) ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsOverlap( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if product and stocking point is provided | 
|     else if( isnull( product ) and isnull( stockingpoint ) ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsNullPISP( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); | 
|     } | 
|      | 
|     // Add feedback text if any of the preconditions above are violated | 
|     if( feedback_o <> '' ) | 
|     { | 
|       displayname := MacroPlan::GetSubstituteName( name ); | 
|       instance := Translations::MP_ServiceLevel_Instance( objecttype, displayname ); | 
|       feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o ); | 
|     } | 
|      | 
|     return feedback_o = ''; | 
|   *] | 
| } |