- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
How to Use CDS Annotations in SAP CAP Fiori Elements
Introduction
SAP BTP CAP Fiori helps developers build business applications that are easy to use and maintain. These applications can display business data, accept user input, and perform daily tasks. But a good application needs more than data and screens. Users also need clear labels, useful tables, search filters, and well-organized forms. This is where CDS annotations become important. They help developers control how business information appears on the screen without writing separate code for every small UI change. For learners taking a SAP Fiori Course, understanding CDS annotations is a useful step toward building practical business applications.
![]() |
| How to Use CDS Annotations in SAP CAP Fiori Elements |
1. What Are CDS Annotations in SAP CAP?
CDS stands for Core Data Services. In SAP CAP, developers use CDS models to describe business data, such as products, customers, orders, and employees.
Annotations are extra details added to these models. They tell supported tools how to display or interpret the data. For example, an annotation can provide a friendly label for a field or tell a Fiori Elements application which columns to show in a table.
Imagine a shop application with a product list. The database field might be called product Name. However, users may understand the label “Product Name” more easily. An annotation can provide that label.
CDS annotations help keep the data model and user interface connected. They also reduce the need to build every screen from scratch.
2. How Do CDS Annotations Work with Fiori Elements?
SAP Fiori Elements uses metadata and annotations to create standard application pages. Instead of manually building every table, form, and filter, developers define the data model and describe the desired user interface.
A typical process looks like this:
1. Create a CDS model for your business data.
2. Add annotations to describe labels and UI elements.
3. Expose the model through a CAP service.
4. Configure the Fiori Elements application to use that service.
5. Run the application and check the displayed information.
For example, a product management application may use annotations to display a product table with product names, prices, and availability. The same model can support filters and detailed product pages.
This approach makes application development more consistent. However, the exact result depends on the annotations used, the OData service metadata, and the Fiori Elements floorplan.
3. How to Add Labels and Descriptions
Clear labels help users understand what each field means. Without them, a screen may show technical names that are difficult for business users to understand.
Consider this simple CDS model:
namespace shop;
entity Products {
key ID : Integer;
productName : String(100);
price : Decimal(10,2);
category : String(50);
}
You can add labels using @title annotations:
namespace shop;
entity Products {
key ID : Integer;
@title: 'Product Name'
productName : String(100);
@title: 'Product Price'
price : Decimal(10,2);
@title: 'Product Category'
category : String(50);
}
These annotations provide meaningful titles for the fields in supported metadata and UI contexts. The exact display depends on the generated metadata and application configuration.
When working on a real project, use short and clear labels. Keep the naming style consistent across tables, forms, and object pages. This makes the application easier to learn and reduces confusion.
4. How to Display Table Columns Using UI Annotations
A table should show the information users need most often. Displaying too many fields can make a page difficult to read.
The UI.LineItem annotation describes the fields that should appear in a list report table. For example:
annotate shop.Products with @(
UI.LineItem: [
{ Value: productName },
{ Value: price },
{ Value: category }
]
);
This example identifies three fields for the table: product name, price, and category. The annotation should be placed in the appropriate CDS annotation context for your project.
For an actual application, make sure the fields and annotation syntax match your CAP version and service model. You may also need to configure the Fiori Elements application to use the relevant entity set.
Good table design starts with a simple question: what does the user need to see first? Put important information in the table and leave less frequently used details for the object page.
5. How to Configure Search Filters
Users often need to find one record among hundreds or thousands of entries. Filters help them narrow the results without scrolling through the entire list.
The UI.SelectionFields annotation identifies fields that can appear in the filter area of a supported Fiori Elements list report.
For example:
annotate shop.Products with @(
UI.SelectionFields: [
productName,
category
]
);
In this example, users can be offered filters for product name and category. They can use these fields to narrow the displayed results.
Choose filters based on real business needs. A product manager may search by category, while an order manager may need an order number or customer name. Too many filters can make the page harder to use, so select the fields that offer the most value.
For developers attending SAP BTP CAP Training, practicing annotations with a small sample service is a useful way to understand how CDS models, OData metadata, and Fiori Elements work together.
6. How to Organize Object Pages and Forms
An object page shows the details of one selected record. For example, when a user opens a product from a list, the object page can display its name, price, category, and other information.
The UI.Facets annotation helps organize an object page into sections. The UI.FieldGroup annotation can group related fields.
A simple field group might contain product details such as:
- Product name
- Product category
- Product price
- Product description
For example, a project can define a field group named ProductDetails and reference it from a facet. The precise annotation structure depends on the CDS model and the supported UI vocabulary.
Organize fields in a way that matches the user's daily work. Keep related information together and avoid unnecessary sections. Before finalizing the page, check that important details are easy to find on both desktop and smaller screens.
7. How to Check and Troubleshoot CDS Annotations
Annotations may not appear as expected if the service metadata, annotation syntax, or application configuration is incorrect.
Use this checklist when something goes wrong:
1. Check the CDS model for syntax errors.
2. Confirm that the annotated entity is exposed through the correct service.
3. Review the generated OData metadata.
4. Confirm that the Fiori Elements application uses the intended service and entity set.
5. Check the browser console and application logs for errors.
6. Refresh or restart the local development setup when necessary.
Also confirm that each annotation is supported by the Fiori Elements floorplan and version used by the project. Some annotations apply only to specific page types or require additional configuration.
A useful debugging method is to start with one annotation, test the application, and then add the next one. This makes it easier to identify the cause of a problem.
8. Best Practices for Using CDS Annotations
Following a few simple practices can make CDS models easier to maintain.
Use meaningful names: Choose field labels that business users understand.
Keep tables focused: Show important information first instead of displaying every available field.
Choose useful filters: Add fields that help users find records quickly.
Group related details: Use object page sections to make forms easier to scan.
Test the actual application: Do not assume that an annotation will work just because the code compiles.
Follow project conventions: Keep annotation files and model definitions organized according to your team's approach.
Developers exploring SAP BTP CAP Fiori Online Training can apply these practices by creating a small product or employee application and gradually adding labels, tables, filters, and object page sections.
9. Frequently Asked Questions
Q1. What are CDS annotations in SAP CAP?
A. CDS annotations are metadata that describe additional information about a data model, including labels and supported user interface settings.
Q2. Why are CDS annotations used in Fiori Elements?
A. They help Fiori Elements generate and configure standard application screens using service metadata and UI definitions.
Q3. Which annotations are commonly used in SAP CAP Fiori Elements?
A. Common examples include UI.LineItem, UI.SelectionFields, UI.Facets, UI.FieldGroup, and Common.Label.
Q4. Can CDS annotations reduce frontend coding?
A. Yes. Supported annotations allow Fiori Elements to generate many standard UI features, reducing the need to code every screen manually.
Q5. Why are CDS annotations not appearing in my Fiori application?
A. Check the annotation syntax, exposed service, OData metadata, application configuration, and compatibility with the selected Fiori Elements floorplan.
Conclusion
CDS annotations make SAP CAP applications easier to present and maintain by connecting business data with useful user interface settings. They help developers create readable tables, practical filters, and well-organized object pages. Start with a small CDS model, add one annotation at a time, and test the result in your Fiori Elements application. With regular practice, you can build business applications that are clearer for users and easier for development teams to maintain.
Trending Courses: Azure Data Engineering, Azure AI, Microsoft Power Apps, SAP UI5 Fiori.
Visualpath is the Leading and Best Software Online Training Institute in Hyderabad.
For More Information about Best SAP BTP CAP with Fiori
Contact Call/WhatsApp: +91-7032290546
Visit: https://www.visualpath.in/sap-btp-cap-fiori-training.html
SAP Fiori Classes
Sap fiori course
SAP Fiori Online Training
SAP Fiori Training
SAP Fiori Training in Bangalore
SAP Fiori Training in Chennai
SAP Fiori Training in Hyderabad
SAP Fiori Training in Pune
- Get link
- X
- Other Apps

Comments
Post a Comment