Skip to Content
Technical Articles
Author's profile photo Abhishek Sharma

How to perform field Validation in ABAP Restful Application Programming Model


In this beginner blog post we are going to see how to perform field Validation in ABAP Restful Application Programming Model.





Field validation is used almost in all of the applications, used to validate Objects to keep data consistent or we can say for data consistency.

Once the validation is invoked it checks the Business Object for any inconsistency in data to be saved. If there is any inconsistency or the data going to be saved is not per need then framework returns errors into FAILED structure.

Once any key is available in FAILED structure then Error can be reported to frontend by using REPORTED structure.


Validation is always defined in Behavior Definition for an Entity.


Validation syntax:

Validation <Method Name> <Trigger Time> { field <To Validate Field Name> <Trigger Operation>  }


<Method Name> : Name of method which will be created and have validation logic and Error handling logic.

<Trigger time> : For validation the only Trigger time available is on save

<To Validate Field Name> : Field name which needs to be validated (in our case Age field)

<Trigger Operation>  : Validation can be triggered by using different operations on Business Object ex: Create, Update, Delete. When any of these Operation triggers then Validation triggers.


Step by Step Guide


Step 1

Add Validation to Behavior Definition of Business Object


Once the Validation is added to Behavior Definition, we need to create method (validateAge)

Step 2

Follow below step to create method. Double click on item available in popup.

Once double click on Item, method will be created inside the Behavior Implementation class.


Step 3

Once method is available inside Behavior Implementation call. We put custom code to validate respective field.


Step 1 : We are reading Entity to get current Age passed from frontend.

Step 2 : If validation failed then error keys are stored into FAILED structure.

Step 3 : Finally to display Error message on frontend we need to fill REPORTED Structure with failed keys.


Activate the changes


Validate the Front end. put Invalid Age and Error message popup will be displayed.


Validation is used to checks the consistency of RAP business object instances based on trigger conditions. Validation is automatically gets called by Restful Application Programming Framework if Trigger condition (Create, Update, Delete) matches.

Validation always triggers during save.






Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Prabhjot Singh Bhatia
      Prabhjot Singh Bhatia

      Hi Abhishek,

      Nice blog on RAP Validations. As you mentioned in the last, Validations can always be trigged during save. However, in real-time scenarios, we may need validations on interaction phase before user clicks on save button and wrong data can be validated beforehand. This can be achieved by implementing prechecks on RAP BO projection layer.

      Thanks and regards,

      Prabhjot Singh