In the RESTful ABAP Programming model (RAP), a business object defines a particular entity, such as a flight connection. Its definition has two parts; a CDS view, which defines the structure of the object or, in other words, the fields that it contains, and a behavior definition, which describes what you can do with the business object. The behavior definition specifies which of the create, update, and delete operations are allowed. It can also contain validations; these check that the data is correct when you create or update a record and determinations, which fill fields of the business object based on the existing data. They can also contain actions, which modify the data outside of the normal scope of the standard create, update, and delete operations. Approving a purchase order or cancelling a flight are activities that you would implement as an action.
RAP business objects are commonly used in generated Fiori Elements apps or Web APIs. However, you can also access them from ABAP coding using Entity Manipulation Language (EML). This is a set of ABAP statements that allows you to create, read, update, and delete data using business objects. When you create a Fiori app based on a business object, you will often need to add code to the generated app, and you use EML in this context to access the application's data.
In this unit, you will create a class that modifies airline data. The view entity contains the fields AirlineID for the airline code, Name for the airline name, and CurrencyCode for its local currency.
Behavior Definition and Implementation
A validation is a check that the RAP runtime performs when data is changed. Here, the validation is performed when a new record is created (but not if an existing record is changed), and it is performed only if the CurrencyCode field is changed.
Validations are defined in the behavior definition. For each validation, there is a corresponding method.