In the previous exercise, you've implemented the late numbering for the late numbering for drawing the primary keys of the travel and the booking BO entities at a later time, during the first storing of the data (see Exercise 4).
In this exercise, you will adjust the layout of the list reports and object pages of your Travel App by enhancing the metadata extension of the travel and the booking BO entities with UI semantics in form of UI-specific annotations (
@UI
).
- 5.1 - Adjust the UI Semantics in the Travel Metadata Extension 💡
- 5.2 - Adjust the UI Semantics in the Booking Metadata Extension 💡
- 5.3 - Preview and Test the Enhanced Travel App
- Summary
Reminder: Do not forget to replace the suffix placeholder
###
with your assigned suffix in the exercise steps below.
Click to expand!
UI-specific CDS annotations can be used to solve the most common UI layout tasks in SAP Fiori elements apps built with RAP.
Read more: Develop UI Specifics
UI annotations represent semantic views on business data through the use of specific patterns that are independent of UI technologies. They can be defined either in the ABAP system using UI-specific ABAP CDS annotations or in the SAP Fiori tools.
Read more: All CDS Annotations | UI Annotations
The SAP Fiori Elements Feature Showcase App for RAP provides a reference technical app that showcases the SAP Fiori Elements UI features which can be implemented using ABAP CDS annotations. The feature showcase app is developed using the ABAP RESTful Application Programming Model (RAP) for oData V4 and is transactional- and draft-enabled.
Read more: SAP Fiori elements Showcase App@SAP Blogs | SAP Fiori elements Showcase App@GitHub
Adjust the appearence of the generated Fiori elements based Travel App by adding the action
acceptTravel
,rejectTravel
, andcreateTravel
, and specifying a colored-based indication of the overall travel statusOverallStatus
for the travel BO entity.
💡 There are two (2) ways to complete exercise 5.1:
Option 1️⃣: This is the recommended option. Replace the complete source code of the metadata extension
ZRAP110_C_TRAVELTP_###
with the source code provided in the source code document linked below and replace the placeholder###
with your assigned suffix. The changes are marked with an appropriate comment in the source code document. Then proceed directly with Exercise 5.2.📄 Source code document:
CDS Metadata extension ZRAP110_C_TravelTP_###
Option 2️⃣: Carry out the steps described below in sequence.
🔵 Click to expand!
-
Open the CDS metadata extension of the projected travel entity
ZRAP110_C_TRAVELTP_###
. -
Specify the appearance of both instance actions
acceptTravel
andrejectTravel
on the list report and the object page of the travel entity.For that, replace the annotation block placed before the element
TravelID
with the code snippet provided below as shown on the screenshot.@UI.lineItem: [ { position: 10 , importance: #HIGH } ,{ type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' } ,{ type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } ] @UI.identification: [ { position: 10 , importance: #HIGH } ,{ type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' } //added line ,{ type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } //added line ] @UI.selectionField: [ { position: 10 } ]
-
Specify a color-based indicator for the overall status
OverallStatus
on the list report and the object page of the travel entity instance. The criticality will be determined by the virtual elementOverallStatusIndicator
.For that, add the attribute
criticality
to the annotations@UI.lineItem
and@UI.identification
for the elementOverallStatus
as shown on the screenshot., criticality: 'OverallStatusIndicator'
Enhance the booking metadata extension
ZRAP110_C_BOOKINGTP_###
to change the appearence of the generated Fiori elements based Travel App. You will define the criticality for the booking status (BookingStatus
) and display the virtual elementRemainingDaysToFlight
as progress bar on the UI.
💡 There are two (2) ways to complete exercise 5.2:
Option 1️⃣: This is the recommended option. Replace the complete source code of the metadata extension
ZRAP110_C_BOOKINGTP_###
with the source code provided in the source code document linked below and replace the placeholder###
with your assigned suffix. The changes are marked with an appropriate comment in the source code document. Then proceed directly with Exercise 5.3.📄 Source code document:
CDS Metadata extension ZRAP110_C_BookingTP_###
Option 2️⃣: Carry out the steps described below in sequence.
🔵 Click to expand!
-
Specify the virtual element
BookingStatusIndicator
as criticality for the booking status by adding the attributecriticality
to the element annotations@UI.lineItem
and@UI.identification
for the elementBookingStatus
as shown on the screenshot.,criticality: 'BookingStatusIndicator'
-
Add the virtual element
RemainingDaysToFlight
to the list report and the object page, and specify its visualization as progress bar using the annotation@UI.dataPoint
. The virtual elementsDaysToFlightIndicator
andInitialDaysToFlight
are respectively specified as itscriticality
andtargetValue
.Insert the code snippet below to the metadata extension after the element
BookingStatus
as shown on the screenshot.@UI: { dataPoint: { title: 'Days to Flight Indicator', criticality: 'DaysToFlightIndicator', targetValue: #(InitialDaysToFlight), visualization: #PROGRESS }, lineItem: [{ type: #AS_DATAPOINT, position: 110, importance: #HIGH}], identification: [{ type: #AS_DATAPOINT, position: 110 }] } RemainingDaysToFlight;
You can now preview and test the changes by creating a new travel BO instance in the Travel app.
⚠Please note⚠ that clicking on the Accept Travel and Reject Travel buttons at this stage will lead to errors on the UI, because they are not yet implemented.
🔵 Click to expand!
Now that you've ...
- adjusted the UI semantics in the metadata extensions by with criticality and datapoint,
- previewed the enhanced app,
you can continue with the next exercise – Exercise 6: Implement the Base BO Behavior - Validations