Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 6 of 6

Adding an SAP Fiori elements UI

9 min

Listen to this lesson

0:00 / 9:22

The fleet desk needs a list of inquiries with filters, an object page per inquiry with its notes, and the related sales order status. SAP Fiori elements generates such UIs from OData metadata and annotations, so most screens need no UI code. CAP has built-in support for Fiori elements, including Fiori annotations and drafts; CAP itself has no UI technology of its own, so other frameworks can be used where Fiori elements does not fit.

Where the app lives

Each Fiori app is a subfolder of app/, for example app/inquiries, with its own manifest. Developers usually create it with the SAP Fiori tools application generator in SAP Business Application Studio or Visual Studio Code, choosing a floorplan (list report and object page for the fleet desk) and the local CAP service. Annotations belong in .cds files in the app folders, such as app/inquiries/annotations.cds, not in the service definition. CAP's documentation describes this as separation of concerns: the service stays UI-neutral, and each app annotates what it needs.

Annotations drive the screens

A minimal list report annotation:
annotate FleetService.Inquiries with @(UI: {
SelectionFields: [ status, priority, customer ],
LineItem: [ {Value: salesOrder}, {Value: customer}, {Value: topic_code}, {Value: priority}, {Value: status} ]
});
SelectionFields become the filter bar; LineItem becomes the table columns. On the object page, UI.HeaderInfo sets the title, and UI.Facets with UI.FieldGroup annotations arrange sections, including a table of notes through the composition. Labels should come from i18n text files so they can be translated.

List report filter barUI.SelectionFields: status, priority, customer
List report tableUI.LineItem: sales order, customer, topic, priority, status
Object page headerUI.HeaderInfo: inquiry title and description
Object page sectionsUI.Facets referencing UI.FieldGroup blocks and the notes table
Value helps@cds.odata.valuelist on Topics or explicit Common.ValueList annotations
Which annotation shapes which part of the fleet desk's Fiori elements app.
The Sign-Off Table · thesignofftable.com/academy/sap-btp-202

Drafts and value helps

Annotating the entity with @odata.draft.enabled turns on draft handling: CAP generates draft tables and the choreography for edit, save and discard, so a user can work on an inquiry and its notes over several steps without saving half-finished data. For value helps, @cds.odata.valuelist on the Topics entity gives every managed association to Topics a value list automatically; code lists from @sap/cds/common already carry it.

With @odata.draft.enabled, edits live in a draft until the user saves or discards it, so a closed browser leaves a recoverable draft instead of half-saved data.
The Sign-Off Table · thesignofftable.com/academy/sap-btp-202

During development, the CAP index page at http://localhost:4004 lists services, and for OData V4 entities offers a Fiori preview link: a generic list page for checking annotations without a full app. It is disabled in production by default. Apps in app/ also appear as links on the index page. For Contoso, the finished app is deployed with the MTA and added to SAP Build Work Zone, where the fleet desk opens it from a tile.

CheckWhy it matters
Filters return the expected rows, including empty resultsSelection fields map to real elements and indexes
Create, edit and discard draft work as expectedDraft choreography and validation messages are correct
Validation errors show the agreed messages next to the fieldDeclarative constraints and handler errors reach the user
Value help for topic offers only valid codesValue list annotations match the code list
Labels are translated and no technical names appeari18n texts are complete for each language in scope

UI checks for the fleet app's first test cycle.

  1. Day 1Generate the appSAP Fiori tools creates app/inquiries with a list report and object page on FleetService
  2. Days 2 to 4AnnotateSelection fields, line items, header info, facets and value helps; labels in i18n files
  3. Day 5Enable drafts@odata.draft.enabled on Inquiries; checks of edit, save and discard
  4. Week 2Deploy to cmc-ext-devBuilt and deployed with the MTA; first check with real roles
  5. Week 3Transport to cmc-ext-testTile added in SAP Build Work Zone; Maria runs the UI checks with fleet agent users
How the fleet desk UI moved from generator to the first test cycle.
The Sign-Off Table · thesignofftable.com/academy/sap-btp-202

Because the UI is generated from annotations, many UI defects are really annotation defects: a missing value help, a label that shows a technical name, a field that should be read-only but is editable. Reviewing the annotation files is therefore part of reviewing the UI, and annotation changes deserve the same regression checks as code. When SAP updates the SAP Fiori elements libraries used by the app, rerun the UI checks even if no annotation changed, since generated screens can shift with the library version.

What would you do?

Maria reports that when she edits an inquiry, adds two notes and then closes the browser by mistake, the notes are gone and the inquiry shows half of her changes. Which change addresses the root cause?

Key points
  • SAP Fiori elements builds list reports and object pages from metadata and annotations.
  • Each app lives in its own app/ subfolder; annotations go in app-level .cds files, not in the service.
  • UI.SelectionFields, UI.LineItem, UI.HeaderInfo, UI.Facets and UI.FieldGroup shape the main screens.
  • @odata.draft.enabled adds draft handling; @cds.odata.valuelist adds value helps.
  • Use the Fiori preview locally; test the real app with business roles, not administrator users.

Check your understanding · not graded

Lesson check

  1. 1. Which annotation defines the columns of a list report table?

  2. 2. Where should Fiori annotations for the inquiries app be placed?

  3. 3. What does @odata.draft.enabled give the fleet desk?

  4. 4. Why should the UI be tested with a fleet agent user instead of an administrator?