I am writing this blog to give an example to how to handle the unmanaged behavior implementation in ABAP restful programming model (RAP).
The ABAP RESTful programming model defines the architecture for efficient end-to-end development of intrinsically SAP HANA-optimized OData services (such as Fiori apps) in SAP Cloud Platform ABAP Environment. It supports the development of all types of Fiori applications as well as A2X services. It is based on technologies and frameworks such as Core Data Services (CDS) for defining semantically rich data models and a service model infrastructure for creating OData services with bindings to an OData protocol and ABAP-based application services for custom logic and SAPUI5-based user interfaces.
I have taken two tables for this example as shown below
Here the tables ZORDHDR is the header table and ZORDITM is the item table.
- Below is the root cds view for which we can create the behavior definition and services.
In the above cds view, we can observe that I have used composition to item view which gives the
- Implementation for behavior definition
For the above created behavior definition, below screen shot will show you the behavior implementation
Here the behavior implantation is nothing but a class where we can implement the our business logic. At the very bottom of this behavior implementation we can see the local types tab, where we can implement our logic.
Click on local types, in that we can implement the logic. Here I have implemented the creating, updating, deletion of data from table. We can observe how the implementation takes place in these local classes.
In the above code snippet, you may observe that separate create, update, delete methods to update the data to table of an entity.
We can also handle these crud operations via one method called ‘modify’. But SAP suggests an architecture which says like we need to hold the data in a global tables(buffer tables) in modify method.
Then implement the crud operation in save method of saver class(lsc_ZBO_A_ORDER). These methods will automatically called means we don’t need to call the methods manually. And not only these there, are some other methods like check_before_save, adjust_nmber which we can use basing on our requirement.
- Service definition
Once we completed with our implementation part, we can create service definition as shown below.
- Service binding
For above created service definition, below is the service binding and activation of service
Click on activate to activate the service.
If you liked this post, please hit the share buttons.
Thank you very much for your time!!