SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Refine the List Report with Annotations

Add additional annotations to show filter fields and columns on the list report as well as to allow the selection of data using a value help.

Overview

🎓 beginner 30 min. SAP FioriSAP Fiori ElementsBeginnerSAP Business Technology PlatformSAP BTP ABAP Environment

You will learn

  • โœ”How to add additional columns and filter fields
  • โœ”How to update the frontend application
  • โœ”How to add list report header information
  • โœ”How to define a value help as a drop-down list
  • โœ”How to define criticality ratings
Unknown U Unknown September 3, 2024
Created by February 17, 2021
Contributors

Prerequisites

Prerequisites

Steps

Intro

Whenever your unique suffix for creating objects is needed, the object names within this tutorial are named with suffix “######”. For the screenshots, the suffix “000100” was used. In the CDS files of your RAP-based service you can add annotations to refine the user interface. These CDS annotations will be translated into OData annotations used by SAP Fiori elements to generate the UIs. UI annotations are stored within metadata extension files to separate them from the CDS view structure for better reading.


Step 1 Create metadata extension file for travel entity
โ€”

Annotations controlling the UI can be stored in metadata extension files. In this section such a file will be created for the Travel entity and a first annotation will be added.

Right click the ZC_FE_TRAVEL_###### projection view for the Travel entity to open the context menu. Choose New Metadata Extension.

Create new metadata extension file
Create new metadata extension file

Enter the name of your metadata extension file. Choose the same name as your projection view file name ZC_FE_TRAVEL_###### and enter a description as well. Choose Next.

Create new metadata extension file
Create new metadata extension file

A transport request is already assigned to the metadata extension file. Choose Finish to confirm the creation of the file.

Create new metadata extension file
Create new metadata extension file

Now open the new metadata extension file ZC_FE_TRAVEL_###### within the Metadata Extensions folder. To show a first column within the list report table, add the content shown in the coding example below. You can use code completion by pressing CTRL-SPACE at the related coding positions, e.g. when adding the @UI.lineItem annotation, just type @UI and then press CTRL-SPACE to choose the entry from the list of proposals.

CDS
@Metadata.layer: #CORE
annotate view ZC_FE_TRAVEL_###### with
{
    @UI.lineItem: [{ position: 10 }]
    TravelID;
}

To finish this step, choose Save and Activate to take over the changes in your metadata extensions file.

Create new metadata extension file
Create new metadata extension file

Check your changes by refreshing of your real application preview in BAS or use the quick service preview in ADT. Choose Go to load the data.

Create new metadata extension file
Create new metadata extension file

You will now see the column Travel ID made visible on the list report table by the @UI.lineItem annotation added to the metadata extensions file. The data shown in the column is loaded from the database with the request triggered by the Go button.

Step 2 Add table columns and filter bar selection fields
+

Again save and activate the file and refresh the application to see the changes on the UI.

You can now filter the data loaded into the list report by specifying values for these additional selection fields.

add selection fields to the list report
add selection fields to the list report

Step 3 Add header information and default sorting
+
Step 4 Refine columns that have IDs
+
CDS
@EndUserText.label: 'Customer'
@ObjectModel.text.element: ['LastName']
CustomerID,
_Customer.LastName as LastName,
CDS
@EndUserText.label: 'Status'
OverallStatus,
CDS
@EndUserText.label: 'Last Changed At'
LocalLastChangedAt,

The semantic key for the view will be TravelID. The content of the field will be highlighted, and the draft indicator will be shown while the Travel item is being worked on.

Add the corresponding annotation @ObjectModel.semanticKey before the definition of the view.

CDS
...
@Search.searchable: true

@ObjectModel.semanticKey: ['TravelID']

define root view entity ZC_FE_TRAVEL_######
...

After saving and activating the file and refreshing the application, you will see the changed labels and content for the fields Travel, Agency, Customer, Status and Last Changed At.

refine ids
refine ids

Step 5 Implement value help for selection fields Customer and Status
+

Save and activate the view.

  • Open the CDS view for the status description ZI_FE_STAT_######. Just above the view definition, insert an @ObjectModel.resultSet.sizeCategory annotation with value #XS. This results in a drop-down list.

    CDS
    ...
    @EndUserText.label: 'Travel Status view entity'
    @ObjectModel.resultSet.sizeCategory: #XS -- drop down menu for value help
    define view ZI_FE_STAT_######
    ...
  • Save and activate the view.

  • After refreshing the application the Status field is now a drop-down list. Select one or more of the available status codes and choose Go to load the filtered list.

    overall status fixed value help
    overall status fixed value help

  • Step 6 Display a description for Status
    +

    Save and activate the view.

  • With these settings the description is displayed in the column Status but additionally, the key is shown within parentheses. You can use the @UI.textArrangement annotation with value #TEXT_ONLY to omit the key. Open the metadata extensions file ZC_FE_TRAVEL_###### and add the text arrangement annotation to the field OverallStatus (line 3).

    CDS
    @UI.lineItem: [{ position: 80 }]
    @UI.selectionField: [{ position: 30 }]
    @UI.textArrangement: #TEXT_ONLY
    OverallStatus;
  • Save and activate the metadata extensions file.

  • After refreshing your application you will see the status description within the Status column.

    overall status text arrangement
    overall status text arrangement

  • Step 7 Implement the criticality feature
    +

    Save and activate the projection view.

  • As a last step you need to add the criticality to the metadata extensions file for the Travel entity ZC_FE_TRAVEL_######.

    This can be done by adding the property criticality with value OverallStatusCriticality to the @UI.lineItem annotation of field OverallStatus (see line 5 in the coding fragment).

    CDS
    ...
    @UI.lineItem: [{ position: 70 }]
    TotalPrice;
    
    @UI.lineItem: [{ position: 80, criticality: 'OverallStatusCriticality' }]
    @UI.selectionField: [{ position: 30 }]
    @UI.textArrangement: #TEXT_ONLY
    OverallStatus;
    
    @UI.lineItem: [{ position: 90 }]
    LocalLastChangedAt;
    ...
  • Save and activate the metadata extension file.

    Refresh your application and reload the data by choosing Go in the list report. Now the content of column Status is shown in different colors depending on the value of the field.

    overall status criticality
    overall status criticality


    Resources

    Discussion

    Share feedback on this tutorial or join the conversation in SAP Community.

    Submit detailed feedback Discuss in Community
    Steps
    Step 1 of 7
    1. Create metadata extension file for travel entity 2. Add table columns and filter bar selection fields 3. Add header information and default sorting 4. Refine columns that have IDs 5. Implement value help for selection fields Customer and Status 6. Display a description for Status 7. Implement the criticality feature

    Learn more →