Application Development and Automation 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: 
Read only

Task 3 - Enhancing CDS View Entities with Annotations

sheenamk
Developer Advocate
Developer Advocate
61,399

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
Read only

0 Likes
11,593

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.

 

Read only

Yuvaraj_S88
Explorer
12,918

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

 

Read only

diveshkalra
Explorer
0 Likes
12,438

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.

Read only

10,947

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

 

Read only

0 Likes
10,936

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

 

}

Read only

Alpesa1990
Participant
Read only

sheenamk
Developer Advocate
Developer Advocate
0 Likes
9,505

Hi,

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

Read only

siva1990
Explorer
11,559

Hi team,

Please find the screenshots below,

All entries

siva1990_0-1724334812163.png

With filer

siva1990_1-1724334859617.png

Regards
Siva G

Read only

0 Likes
10,798

Hi @siva1990 ,

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

Regards,

Shilpa

Read only

adrianng
Explorer
0 Likes
11,331

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

 

Read only

0 Likes
10,802

Hi,

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

 

Read only

geek61
Participant
11,252

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.

Read only

0 Likes
10,803

Hi @geek61 ,

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

Regards,

Shilpa

 

Read only

0 Likes
10,677

@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

Read only

0 Likes
9,376

Hi @geek61 ,

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

Read only

0 Likes
9,305

@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.

Read only

Latifa
Explorer
11,224

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 😉 

Read only

0 Likes
10,807

Hi @Latifa 

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

Regards,

Shilpa

Read only

0 Likes
10,807

Hi @Jorge_Cervantes1,

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

Regards,

Shilpa

Read only

Aditya1231
Discoverer
Read only

diveshkalra
Explorer
0 Likes
10,820

Hi @Shilpa_Shankar ,

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

Please advise.

Read only

0 Likes
9,575

Hi,

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

Read only

EzgiKarabay
Explorer
10,766

 

👍💪

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

 

 

Read only

BerkayZdmr21
Explorer
10,768

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

 

 

Read only

mohit_dev
Contributor
10,761

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

Read only

viveksingh
Discoverer
Read only

Saikumar_Vendoti
Discoverer
Read only

Henning_T
Explorer
Read only

Ojeswini_Sanaka
Explorer
10,675

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

 

 

Read only

jochenlittleq20
Explorer
10,676

Here is my preview for this weeks task:

jochenlittleq_0-1724415316025.png

 

Read only

10,675

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

 

Read only

PedroARomero
Explorer
0 Likes
10,666

Task 3 Done!

1. All without filters

PedroARomero_0-1724416684108.png

2. Using Description and Status

PedroARomero_1-1724416969094.png

 

 

 

 

Read only

0 Likes
9,588

Hi @PedroARomero ,

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

Read only

0 Likes
9,497

Hi Shilpa

Yes, Filter with description

 

PedroARomero_1-1724682681250.png

 

Read only

0 Likes
9,470

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