How to enhance the Base BO Data Model

In Part 2 of the Beginner’s tutorial, we’re going to take a closer look at enhancing the metadata extension of the Project BO Model. We’ll also define more association rules to make our Fiori app even better. Plus, in future tutorials, we’ll explore how to upload images. Let’s jump right in!
Before proceeding further, it’s important to complete Part 1 of the Beginner’s tutorial for ABAP RAP, where we learned how to create a database table to store travel data and generate a UI service, including the business object (BO) entity “Travel.” If you haven’t completed Part 1 of the RAP for Beginners tutorial yet, I recommend doing so first, as it’s a prerequisite.

Enhance the Base BO Data Model

Define and expose new associations in the base BO data model defined in the CDS view entity.
We are going to add 4 associations _Agency, _Customer, _OverallStatus, and _Currency under root entity. Please see code change below in the Root Entity
association [0..1] to /DMO/I_Agency as _Agency on $projection.AgencyID = _Agency.AgencyID
association [0..1] to /DMO/I_Customer as _Customer  on $projection.CustomerID = _Customer.CustomerID
association [1..1] to /DMO/I_Overall_Status_VH as _OverallStatus on $projection.OverallStatus = _OverallStatus.OverallStatus
association [0..1] to I_Currency as _Currency on $projection.CurrencyCode = _Currency.Currency
Since we’ve defined the association relationship, it’s important to note that we also need to publicly expose them in the element section of CDS. To understand why, refer to the “What is Association” tutorial.
//public associations
_Customer,
_Agency,
_OverallStatus,
_Currency
Save save icon (Ctrl+S) and activate activate icon (Ctrl+F3) the changes.

Enhance the Projected BO Data Model

Enhance the projected BO data model defined in the CDS projection view ZC_RAPTECH_TRAVEL(also known as the consumption view). For instance, you will enable full-text search on certain elements, add new elements for language-dependent descriptive texts, and define value helps.

Open Generated CDS view ZC_RAPTECH_TRAVEL, Specify the projection view as searchable by adding the following  in metadata section.

@Search.searchable: true
Now will enhance our element list of projection CDS as given below.
To display Agency Name
_Agency.Name              as AgencyName
To display customer Name
_Customer.LastName        as CustomerName
To display Overall Status text.The word Localized is used to display text in current system language.
 _OverallStatus._Text.Text as OverallStatusText : localized,
Save and Active consumption view.
To unable Fuzziness search, will write below code on Travel Id with error Tolerance.
 @Search.defaultSearchElement: true
 @Search.fuzzinessThreshold: 0.90
We have an element AgencyID, however we haven’t defined associated text to it. For this add below line of code along with full text search functionality.
@Search.defaultSearchElement: true
@ObjectModel.text.element: ['AgencyName']
Similarly we will do same for Customer ID and Overall status
@Search.defaultSearchElement: true
@ObjectModel.text.element: ['CustomerName']
@ObjectModel.text.element: ['OverallStatusText']
Save and Activate projection view. Run your application to see the result.
Agency Id, Customer Id and overall status are not displayed with its corresponding text.
In the next tutorial we are going to learn how to implement F4 help in object page

Leave a Comment

Your email address will not be published. Required fields are marked *