
A validation is an optional part of the business object behavior that checks the consistency of business object instances based on trigger conditions. Validations, like actions, are defined in the behavior definition of the RAP BO and implemented in the behavior pool through a dedicated method of the local handler class.
A validation is implicitly invoked by the business objects framework if the trigger condition of the validation is fulfilled. Trigger conditions can be modify operations (create, update, delete) and modified fields. The trigger condition is evaluated at the trigger time, a predefined point during the BO runtime.
An invoked validation can reject inconsistent instance data from being saved by passing the keys of failed instances to the corresponding table in the FAILED structure. Also, a validation can return messages to the consumer by passing them to the corresponding table in the REPORTED structure.
Note
Validations are available for managed scenarios and for unmanaged scenarios with draft. They are not available for unmanaged, non draft scenarios.

Validations are defined in the entity behavior definition with the following statement: validation <validation_name> on save { <trigger_conditions> }.
Note
For validations, only the trigger time on save is supported.
It is mandatory to provide at least one trigger condition within the curly brackets.
The following trigger conditions are supported:
- Create;
- The validation is executed when an instance is created.
- Update;
- The validation is executed when an instance is updated.
- Delete;
- The validation is executed when an instance is deleted.
- Field <field1>, <field2>, …;
- The validation is executed when the value of one of the specified fields is changed by a create or update operation.
Multiple trigger conditions can be combined. The conditions are linked with OR that means at runtime it is sufficient that one of the trigger conditions is met.
Note
The trigger condition update; is only allowed in combination with the trigger condition create;.
The behavior definition in the example defines two validations. The first is triggered by any create or update operation. The other is triggered by any create operation or by changes to the CustomerID field.
Note
The order of execution for validations is not fixed. If more than one validation is triggered by the same condition, you cannot know which validation is executed first.



