The data model in this workshop consists of two transactional tables (travel and booking) as well as some master data that we will re-use from the already existing demo content (Agency, Customer and Flight), as well as a few more.
A Travel entity defines general travel data, such as the agency ID or customer ID, the overall status of the travel and the price of travel.
A Booking entity comprises general flight and booking data, the customer ID for whom the flight is booked as well as the travel ID to which the booking belongs to – and some admin fields.
You've already defined a group ID and created an ABAP package as described in the Getting Started section.
In the current exercise you will create a helper class which will take care of the generation of the following RAP artefacts:
- two database tables (
ZRAP_A*
) to store the travel and booking data - both filled with some sample data - two BO CDS views (
ZRAP_I_*
) for the root entity travel and child entity booking (CDS composition model) - two Projection CDS views - aka Consumption views - (
ZRAP_C_*
) for the root entity travel and child entity booking (CDS data model projection) - two CDS metadata extensions (
ZRAP_C_*
) to enrich the projected root entity travel and projected child entity booking with UI semantics for the later rendering of the SAP Fiori Elements app (UI semantics).
In the ABAP trial systems we have prepared a helper class /dmo/cl_gen_dev260_artifacts to generate the database tables and different CDS artefacts needed for the next exercises. The helper class will also fill some demo data into the database tables. For this purpose, demo data provided by the ABAP Flight Reference Scenario (main package: /DMO/FLIGHT
) will be used.
-
Select the Open ABAP Development Object icon or press Ctrl+Shift+A.
-
In the Open ABAP Development Object dialogue enter /dmo/cl_gen_dev260_artifacts as search string and press OK.
-
The class /dmo/cl_gen_dev260_artifacts is displayed in a new tab.
-
Press F9 to run the ABAP class as a console application. As a result, you will see a success message in the Console.
-
Please note down your group ID
####
and copy the name of the newly created package ZRAP_TRAVEL_####... - Package: ZRAP_TRAVEL_#### - Group ID: #### ...
-
Right click on the folder Favorite Packages and select Add Package....
-
Enter the name of your package ZRAP_TRAVEL_#### and press OK.
-
Go to your package
ZRAP_TRAVEL_####
in the Project Explorer (where####
is your group ID) and press F5 to refresh the project explorer. It should now contain the generated objects.
You can preview the data from a database table or a CDS view by choosing the relevant objects in the Project Explorer and pressing F8.- Dictionary > Database Tables:
ZRAP_ATRAV_####
andZRAP_ABOOK_####
- Core Data Services > Data Definitions:
ZI_RAP_TRAVEL_####
,ZI_RAP_BOOKING_####
,ZC_RAP_TRAVEL_####
andZC_RAP_BOOKING_####
- Core Data Services > Metadata Extensions:
ZC_RAP_TRAVEL_####
andZC_RAP_BOOKING_####
You can preview the data of a database table or a CDS view in the Data Preview editor by selecting it and pressing F8. Short explanations about the generated artefacts are provided below (where
####
is your group ID). - Dictionary > Database Tables:
-
Database tables
ZRAP_ATRAV_####
is used to store Travel data. Its table key consists of theclient
field and thetravel_uuid
field which is a technical key (16 Byte UUID). It also contains a human-readable travel identifiertravel_id
.ZRAP_ABOOK_####
is used to store Booking data. Its table key consists of theclient
field and thebooking_uuid
field which is a technical key (16 Byte UUID). It also comprises a human-readable booking identifier:booking_id
. -
CDS Data Model (Composition Model)
Both CDS data definitionsZI_RAP_Travel_####
andZI_RAP_Booking_####
(where####
is your group ID) are CDS view entities used to define the composition model of our RAP BO. They are called BO views or Interface views, and typically beginn with the suffix<namespace>I_
(e.g.ZI_
) - following the naming convention of the SAP S/4HANA's Virtual Data Model (VDM).Our composition model consists of two nodes: The root node travel (
ZI_RAP_Travel_####
) and its child node booking (ZI_RAP_Booking_####
). The root node (Travel) is explicitly defined by adding the keywordroot
to the define statement. Associations that define the composition model are explicitly defined using the keywordcomposition
. Their corresponding on-condition is defined in the child entity.In the child node (Booking), the corresponding
to parent
association is defined with the related on-condition. -
CDS Data Model Projection
Both CDS data definitionsZC_RAP_Travel_####
andZC_RAP_Booking_####
(where####
is your group ID) are CDS projection views used to define the use case or consumption specific CDS data model projection of our RAP BO. They are called Consumption views or Projection views, and typically beginn with the suffix<namespace>C_
(e.g.ZC_
) following the naming convention of the SAP S/4HANA's Virtual Data Model (VDM). They are defined on top of the interface views (ZI_*
).The Travel projection view exposes all the elements and Booking composition defined in the underlying Travel interface view - enhanced with additional metadata such as value Helps and searches. However, the composition to the booking BO child node - i.e. the association
_Booking
- must be redirected to the Booking BO projection view. This is done using theredirected to composition child
statement.In the Booking projection view, the association to the Travel BO parent node has been redirected to the Travel BO projection view using the
redirect to parent
statement. -
CDS Metadata Extensions
Both CDS metadata extensionsZC_RAP_Travel_####
andZC_RAP_Booking_####
(where####
is your group ID) are used to enrich respectively the Travel projection view and the Booking projection view with UI semantics for the later rendering of the SAP Fiori elements-based Travel app - using UI-specific CDS annotations. The metadata extensions define e.g. the columns and fields shown on the list report page as well as on the object page in the SAP Fiori elements app.
Due to some current restrictions in the helper class, some adjustments of the Travel and Booking projection views are required.
-
Open the Travel projection view
ZC_RAP_Travel_####
by double-clicking on it in the Project Explorer and adjust it as described next two steps. -
Replace the line
AgencyID,
with
@ObjectModel.text.element: ['AgencyName'] @Search.defaultSearchElement: true AgencyID, _Agency.Name as AgencyName,
-
Also replace the line
CustomerID,
with
@ObjectModel.text.element: ['CustomerName'] @Search.defaultSearchElement: true CustomerID, _Customer.LastName as CustomerName,
The changes should look as follows:
-
Save and activate the changes.
You can preview (F8) the result of the changes in the Data Preview editor. -
Now open the Booking projection view
ZC_RAP_Booking_####
by double-clicking on it in the Project Explorer and adjust it as described in the next two steps. -
Replace the line
CustomerID,
with
@ObjectModel.text.element: ['CustomerName'] @Search.defaultSearchElement: true CustomerID, _Customer.LastName as CustomerName,
-
Also replace the line
CarrierID,
with
@ObjectModel.text.element: ['CarrierName'] CarrierID, _Carrier.Name as CarrierName,
The changes should look as follows:
Now that you've...
- created the enriched data model: database tables, interface views, projections view and metadata extensions
- filled the database tables with sample data,
- and adjusted the projections views and the metadata extensions
You can continue with - Exercise 5 - Business Service
Find the source code for the CDS views in the sources folder. Don't forget to replace the placeholder ####
with your group ID.
Find the source code for the database tables and the helper class in the sources folder. Don't forget to replace the placeholder ####
with your group ID or chosen suffix.