| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod ValidateInput ( | 
|   output String feedback_o, | 
|   output String sanitycheckcategory_o, | 
|   MacroPlan owner, | 
|   FulfillmentTarget fulfillmenttarget, | 
|   String name, | 
|   Product_MP product, | 
|   StockingPoint_MP stockingpoint, | 
|   SalesSegment_MP salessegment, | 
|   Real targetpercentage, | 
|   Date start, | 
|   Date end, | 
|   Boolean isforsafetystock, | 
|   String objecttype | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Validate inputs for service level.' | 
|   TextBody: | 
|   [* | 
|     feedback_o := '' | 
|     sanitycheckcategory_o := ''; | 
|      | 
|     // If name is not entered | 
|     if( name = '' ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsInvalidName( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // If target percentage is out of range (0-100) | 
|     else if( targetpercentage <= 0 or targetpercentage > 100 ) | 
|     { | 
|       feedback_o := Translations::MP_FulfillmentTarget_ValidateInput_IsInvalidTargetPercentage( targetpercentage ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // If the start time is larger than end time | 
|     else if( start > end ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsInvalidStart( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // If another FulfillmentTarget with the same specifications exists | 
|     else if( exists( owner, FulfillmentTarget, sl, | 
|                      sl <> fulfillmenttarget | 
|                      and sl.IsUsedForSafetyStockCalculation() = isforsafetystock | 
|                      and sl.Product_MP() = product | 
|                      and sl.StockingPoint_MP() = stockingpoint | 
|                      and sl.SalesSegment_MP() = salessegment  | 
|                      and sl.Start() = start | 
|                      and sl.End() = end ) ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsNotUnique( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // If product, stocking point, and sales segment are not provided | 
|     else if( isnull( product ) and isnull( stockingpoint ) and isnull( salessegment ) ) | 
|     { | 
|       feedback_o := Translations::MP_ServiceLevel_ValidateInput_IsNullLinks( objecttype ); | 
|       sanitycheckcategory_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); | 
|     } | 
|      | 
|     // If any of the precondition is 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 = ''; | 
|   *] | 
| } |