CRUD Operation in SAP BOPF

From our data model of Airline which we have created, there are three Composite Interface views. It is always good practice to add semantic business object annotations to the composite interface views. Because Basic Interface views has to be reused in other applications as well, so we apply business object annotations on Composite interface views. To generate a BOPF business object based on the three composite CDS views, we must add several @ObjectModel annotations to the views.

In the Airline root view (ZAPF_I_AIRLINE), we must add the annotations on the header level.

Below is the list of BOPF Business Object annotations.

# BOPF BO Annotations Purpose/Relevance
1. @ObjectModel.modelCategory: #BUSINESS_OBJECT Indicates that the CDS view represents a BOPF business object.
2. @ObjectModel.compositionRoot: true A business object is represented as a hierarchical tree of nodes, and by adding this annotation, a view is characterized as the root view of the node hierarchy.
3. @ObjectModel.writeActivePersistence: ‘SCARR’ This annotation specifies where created or updated data must be stored or deleted from.
4. @ObjectModel.transactionalProcessingEnabled: true To enable the transactional run-time for the view, this annotation is used. This annotation can only be added to Root view of BOPF hierarchy. Also, this annotation has to be added along with @ObjectModel.writeActivePersistence: ‘SCARR’.
5. @ObjectModel.createEnabled: true,
@ObjectModel.deleteEnabled: true, and @ObjectModel.updateEnabled: true
With these annotations, we specify which operations will be supported by the transactional runtime. When we set everything to true, then all operations are supported by our Airline root node.
6. /* Associations*/
@ObjectModel.association.type:#TO_COMPOSITION_CHILD
_Flight,
@ObjectModel.association.type:#TO_COMPOSITION_CHILD
_Fsched
To build up the business object node hierarchy, we must also annotate the association to Flight Info. and Flight schedule views as a child association.
7. /* Associations*/
@ObjectModel.association.type: [#TO_COMPOSITION_PARENT,#TO_COMPOSITION_
ROOT]
_Airline
Views that don’t represent the root node of the hierarchy must also specify their root node association, which, in our case, is equivalent to the parent association.

Lets apply the above BOPF BO annotations in our Airline model.

Root view – Airline
Flight Info.
Flight Schedule

On activation of the transactional or business object views, the BOPF runtime will generate a business object together with several structures and table types based on the CDS view field structures. The generated BOPF object has the same name as the
root CDS view, in our case, ZAPF_I_AIRLINE.

BO tree of Airline Data Model

To enable our existing consumption views for transactional processing via the generated BOPF business object, we must add some of the @ObjectModel annotations on the header level. To the Airline Consumption view (ZAPF_C_AIRLINE), we must add the annotations given as below

We should mark the view as the root view of our hierarchy node structure by introducing @ObjectModel.compositionRoot: true. Additionally, we must enable all transactional operations separately because they are already known from the Interface views. The only new annotation is the @ObjectModel.transactionalProcessingDelegated: true, which indicates that transactional processing is delegated to the transactional runtime of the underlying view. In our case, ZAPF_I_AIRLINE is the business object and view. Moreover, we must also specify the same association type annotations as in the underlying views, from Airline to Flights Info. and vice-versa.

Additionally, we have to add annotations to Flights Info. Consumption view (ZAPF_C_FLIGHTS) and Flight Schedule Consumption view(ZAPF_C_FLI_SCHED), to enable transactional processing delegation.

Consumption view of Airline
Consumption view of Flights Info.
Consumption view of Flight Schedule

Once all the BOPF BO annotations are added, our Fiori App will look like below.

Let’s insert data with below details in all three views.

View Data
Airline Airline code = SQ;
Airline Name = Phillipines Airlines
Currency Code = SG;
URL = –
Flights Info. Airline Code = SQ;
Connection No = 0158;
Flight Date = 22.03.2020;
Airfare = 4000 SGD;
Currency = SGD;
Max capacity = 300;
Occupied seats = 201;
Booking Total = 804000 SGD
Flight Schedule Airline Code = SQ;
Connection No = 0158;
Country From = SG;
Departure city = Singapore;
Country To = ID;
Arrival City = Jakarta

Below are the outputs once save operation is performed.

Airline
Flight Schedule
Flight Info.

With the help BOPF, we were able to save entities into corresponding table, without any issues. In following chapters, let us discuss further on other features available with BOPF.

Next Chapter

ABAP Programming Model for SAP Fiori

We are planning to start an Instructor Led Paid Online Practical Training on ABAP Programming Model for SAP Fiori. If learning this new programming model is in you study kitty, you may want to register and enroll in this course. Please register using below link and we will provide more information to the registered participants.

Introduction to ABAP Programming Model for SAP Fiori Training – Registration Form

Please follow our LinkedIn Page, LinkedIn Group, Facebook Page, Twitter and Instagram.

Save our number +1-646-727-9273 and send us a Whatsapp message ‘LEARN’ to be part of our Learning Community.

All SAP Fiori Tutorials

Check BOPF Tutorials




Previous articleABAP Programming Model for SAP Fiori – 7 – BOPF – Introduction
Next articleABAP Programming Model for SAP Fiori – 9 – Use of Determinations in BOPF

Avatar

Source Article