Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Task 3 - Enhancing CDS View Entities with Annotations

sheenamk
Developer Advocate
Developer Advocate
19,258

Another Wednesday and we are back with Task 3 of the August Developer Challenge on ABAP Core Data Services. We are thrilled to see the amazing response to Task 1 and Task 2. Whoever missed it can find all the information in our blogpost August Developer Challenge.

Today for Task 3 we decided to take you all through one of the interesting and widely used feature of ABAP Core Data Services – Annotations.

Annotations allow you to add domain-specific metadata and text labels to CDS objects that goes beyond the syntax features of ABAP SQL. This means that it enhances the technical properties of CDS view entities such as adding search , capabilities or controlling access to your data. To know more about Annotations watch the SAP TechByte on Annotations or go through the CDS Annotation Help Documentation

Task 3 – In this task we will add annotations to the CDS View Entity created in Task1 and then create a Fiori app to view the results.

  1. Add annotations to display all the fields in the Fiori app by default.
  2. Add annotations to provide a search field and enable search by ‘Description’ in the filter bar.
  3. Add annotations to provide a value help filter on the ‘Status text’ field based on Overall Status text.
  4. Add annotations to provide a filter for the Travel ID field.
  5. Create a Service Definition
  6. Create a Service Binding to preview the Fiori app.  

Follow the instructions carefully and share with us the screenshots of the items mentioned in the ‘Validation’ section of this discussion.

Please use this separate thread to ask your questions and discuss issues.

Validation :-

Note:- Please do not search with '*'

Please share screenshots after performing the following :

  1. Preview the App showing all the columns, search and filter options in the CDS view entity.
  2. Search records based on a specific value from 'Description' field and select an available value from the 'Status' field.

We are eagerly waiting to see your submissions. Enjoy!!

196 REPLIES 196

0 Kudos
4,104

Hi @Shilpa_Shankar - Thanks for your feedback. Changed the filter to Status Text instead of the Status Code.

Please find the below screen shot for the same.

Chandana_Pamarthi_0-1724675461346.png

Regards,

Chandana.

 

Yuvaraj_S88
Explorer
5,429

Week Task - 3 Completed 
1. Search enabled for Travel Description. 

YuviSAP_0-1724329094337.png

2. Value help given for status description field 

YuviSAP_1-1724329183775.png

 

diveshkalra
Explorer
0 Kudos
4,949

Hi,

Can any one help on the third point?

c. Add annotations to provide a value help filter on the ‘Status text’ field based on Overall Status text.

3,458

Hi @diveshkalra ,

The task is to add 'Status text' field in the filter bar. As it has only 3 values we need to define an annotation which makes it is a value help where the values will be displayed and can be filtered on. 

Hint: Check the Annotation TechByte video: https://www.youtube.com/watch?v=GXFHjq5L8M8&t=1030s

 

0 Kudos
3,447

Hi @Shilpa_Shankar ,

I tried same way by following the youtube link but not sure where it's going wrong.

Below is the code:

@AbapCatalog.viewEnhancementCategory: [#NONE]

@AccessControl.authorizationCheck: #NOT_REQUIRED

@EndUserText.label: 'CDS View entity'

@Metadata.ignorePropagatedAnnotations: true

@ObjectModel.usageType:{

serviceQuality: #X,

sizeCategory: #S,

dataClass: #MIXED

}

@UI.headerInfo.typeName: 'Travel'

@UI.headerInfo.typeNamePlural: 'Travels'

@Search.searchable: true

@ObjectModel.semanticKey: [ 'Description' ]

 

define view entity Ztravel_entity5 as select from ztravel_new5

association [0..1] to /DMO/I_Overall_Status_VH as _Status on _Status.OverallStatus = $projection.Status

{

@UI.lineItem: [{ position: 10 }]

@UI.selectionField: [{ position: 10 }]

key

travel_id as TravelId,

@UI.lineItem: [{ position: 20 }]

@Search.defaultSearchElement: true

@Search.fuzzinessThreshold: 0.90

description as Description,

@Semantics.amount.currencyCode: 'CurrencyCode'

@UI.lineItem: [{ position: 30 }]

total_price as TotalPrice,

currency_code as CurrencyCode,

@UI.lineItem: [{ position: 40 }]

concat_with_space( cast ( total_price as abap.char(25) ), currency_code, 1) as NewPriceCurrencyCode,

@UI.lineItem: [{ position: 50 }]

status as Status,

@UI.lineItem: [{ position: 60 }]

@UI.selectionField: [{ position: 20 }]

@Consumption.valueHelpDefinition: [{ entity: {name: 'zhelp_new5', element: 'overallStatus' } }]

_Status._Text.Text as overallStatusText,

_Status

 

}

Alpesa1990
Participant

sheenamk
Developer Advocate
Developer Advocate
0 Kudos
2,016

Hi,

  Thanks for the submission. Could you please search without a '*' ?

siva1990
Explorer
4,071

Hi team,

Please find the screenshots below,

All entries

siva1990_0-1724334812163.png

With filer

siva1990_1-1724334859617.png

Regards
Siva G

0 Kudos
3,310

Hi @siva1990 ,

Thanks for the submission. For better readability you can filter out on the Status Text instead of the Status Code.

Regards,

Shilpa

adrianng
Explorer
0 Kudos
3,843

Hi everyone,

Thank you for this August challenge—it's been incredibly interesting and I've learned a lot!

Here’s my solution:


1. Preview the app showing all the columns, search and filter options.
adrianng_0-1724341524379.png

2. Search record based on vac descriptiond and Status accepted

adrianng_1-1724341573679.png

 

0 Kudos
3,314

Hi,

Thanks for the submission. Kindly add a search field for the challenge to be complete.

 

geek
Participant
3,764

geek_0-1724347818080.png

geek_1-1724347855227.png

Will try fiddling with the Status filter as am sure that there's a way to make it more presentable.

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos
3,315

Hi @geek ,

Thanks for the submission. For better readability you can filter out on the Status Text instead of the Status Code.

Regards,

Shilpa

 

0 Kudos
3,189

@Shilpa_Shankar Thanks. It's the searching by text that I've struggled with. For textArrangement: #SEPARATE the search help is by technical key, so how to attach the search to the text field. Setting the textArrangement: #TEXT_ONLY shows Status as Text but removes the Technical value from the list:

 

geek_1-1724411199018.png

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos
1,888

Hi @geek ,

This is how I do it. I have 2 fields Status which has technical key and StatusText which has corresponding values. For the Status field add this annotation:

@Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Overall_Status_VH',element: 'OverallStatus' } }]
@ObjectModel.text.element: [ 'StatusText' ]
@UI.textArrangement: #TEXT_ONLY

and hide the StatusText field as anyway the Text value will be displayed under Status

0 Kudos
1,817

@Shilpa_Shankar That's where I ended up, see later posting describing it as a "fudge", spent a lot of time trying to use, @UI.textArrangement: #SEPARATE and attaching the Search to the Text, before adding a second Status field. Thanks for the feedback.

Latifa
Explorer
3,736

Hello everyone, here is the screenshot for the initial state of the FIORI application

Latifa_0-1724349768109.png

if we type 'Christine' on the description field, we get

Latifa_1-1724349838563.png

We filter on Accepted status:

Latifa_2-1724349872345.png

Looking forward for the next week already, as I find this enjoyable 😂💙

Have a great day 😉 

0 Kudos
3,319

Hi @Latifa 

Thanks for the submission. For better readability you can filter out on the Status Text instead of the Status Code.

Regards,

Shilpa

0 Kudos
3,319

Hi @Jorge_Cervantes,

Thanks for the submission. For better readability you can filter out on the Status Text instead of the Code.

Regards,

Shilpa

Aditya1231
Discoverer

diveshkalra
Explorer
0 Kudos
3,332

Hi @Shilpa_Shankar ,

I have almost complete this task but facing issue in point c.

Please advise.

0 Kudos
2,087

Hi,

Kindly add consumption.valuehelpdefinition for the status field and map the text to the status text field. 
You can use Objectmod.text

EzgiKarabay
Explorer
3,278

 

👍💪

CDS View with no filter:

EzgiKarabay_4-1724402620523.png

CDS View with description filter which is including 'vac' and status text filter:

EzgiKarabay_2-1724402316361.png

CSS View with description filter which is including 'vac' ,travel ıd and status text filter:

EzgiKarabay_3-1724402338665.png

 

 

BerkayZdmr
Explorer
3,280

1. All the columns, search and filter options;

BerkayZdmr_0-1724402763280.png

2. Specific value from 'Description' field and value from the 'Status' field;

BerkayZdmr_1-1724402817297.png

3. TravelId filter;

BerkayZdmr_2-1724402848533.png

 

 

mohit_dev
Contributor
3,273

Preview of the App showing all the columns, search and filter options in the CDS view entity:

mohit_dev_0-1724403372411.png

Search records based on a specific value from 'Description' field and select an available value from the 'Status' field.

mohit_dev_1-1724403479208.png

Saikumar_Vendoti
Discoverer

Henning_T
Explorer

ojeswinisanaka
Explorer
3,187

Hi @sheenamk 

1. Preview for all fields

ojeswinisanaka_0-1724414548437.png

 

Value Help for Status Text

ojeswinisanaka_1-1724414594416.png

 

2. Search records based on Description and Status text

ojeswinisanaka_2-1724414741584.png

 

 

jochenlittleq
Explorer
3,188

Here is my preview for this weeks task:

jochenlittleq_0-1724415316025.png

 

3,187

Validation 1:

MallareddyBuchammagari_0-1724416370745.png

Validation 2:

Search with Description

MallareddyBuchammagari_1-1724416396783.png

Filter with Status

MallareddyBuchammagari_2-1724416413242.png

Filter with Travel Id

MallareddyBuchammagari_3-1724416449966.png

 

PedroARomero
Explorer
0 Kudos
3,178

Task 3 Done!

1. All without filters

PedroARomero_0-1724416684108.png

2. Using Description and Status

PedroARomero_1-1724416969094.png

 

 

 

 

0 Kudos
2,100

Hi @PedroARomero ,

Thanks for the submission. Please enable search field and search with a description.

0 Kudos
2,009

Hi Shilpa

Yes, Filter with description

 

PedroARomero_1-1724682681250.png

 

0 Kudos
1,982

Hi Shilpa,

I didn't get well the idea. This is the correction using the @Search.searchable

PedroARomero_0-1724689202431.png

and using the status filter

PedroARomero_1-1724689236846.png

 

Regards