Mastering SAP Metadata Extension in RAP: A Complete Guide (Beginner‑Friendly)

SAP Metadata extension is one of the most powerful features for enhancing UI behavior without modifying the core data model. Yet many developers either misunderstand it or underuse it.

This guide breaks down:

  • What is metadata extensions in sap
  • Why they are important
  • How they differ from annotations
  • How to create a metadata extension step‑by‑step
  • Best practices
  • Common pitfalls
  • And how it all fits into a RAP application

What is SAP Metadata Extension in CDS views?

A Metadata Extension (MDE) is a dedicated file that stores UI annotations and configurations separately from your core CDS model.

  • MDE extends a CDS entity with CDS annotations that are not specified in the DDL source code of the data definition.
  • It is defined and transported in a separate piece of DDLX source code.
  • CDS entity should have annotation Metadata.allowExtensions True to be able to use MDE
  • There can be multiple MDE for one CDS entity.
  • Each MDE is assigned to a layer such as Customer, Partner, Industry, Localization, Core .

Why Should You Use Metadata Extensions?

  • Clean Separation of Concerns : Your CDS model defines structure, not UI. Your MDE defines behavior, not business logic.
  • Team Productivity : Backend and Fiori developers can work simultaneously without stepping on each other’s changes.
  • Upgrade‑friendly : SAP recommends metadata extensions for Fiori Elements, CAP, and OData V4 because it keeps the model stable.
  • Reusability : Annotations can be grouped & reused across multiple apps or services.
  • Readability : MDEs improves readability as UI and behavior are not longer mixed up.
  • Transport : MDEs are transported independently.
  • Dependency : Avoids mass activation of dependent repository objects.
  • Flexibility : Layers and CDS variants allow frameworks, partners and customers to override the metadata of a CDS entity without making modifications.

How to create a metadata extension step‑by‑step

Continuing from where we left off in our previous blog where we have created projection views for our travel application.

To create a MDE for our root projection view we will first need to use Metadata.allowExtensions True

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Now let us create our MDE for this view. Right click on the view on which we want to create MDE and select New Metadata Extension.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations
SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Give name, details, TR and click next.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Select annotate view and finish.

Now we will provide the layer as Core for our MDE as this is a custom application and insert all elements which we want to annotate UIs.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

As I don’t want Associations those are removed.

But before doing any changes here let us create our service definition and binding so that we can preview our changes in frontend.

Right click on our root projection view and select new service definition.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations
SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Provide details click next and finish.

Expose other entities also.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Activate and let us create service binding.

Right click on service name and select New Service binding.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Give details and click Next and Finish.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Activate and publish the Service binding.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Click on preview to get a view of the application.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Select all columns in preview.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

So it is right now a basic application similar to our read only application.

Now let us go to our MDE and start adding annotations one by one. Let us start with what we to display in the main page of our application by using lineitem annotation.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Activate and refresh application.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Now let us add selection fields same as we did using @ui.selectionfield annotation in our read only application.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Activate and refresh application.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Selection fields now visible.

Now we will also add a search field.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Now I want to display Agency Name and ID together for which we used object model annotation in our read only application but since this is an ABAP level annotation let is give it in our projection view.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Activate and refresh application. Please note only UI annotations are permitted in MDEs.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Now we will add the value help also for selection fields using @Consumption in our MDE.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Preview and check for F4 help.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Now we will give identification reference annotation.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Let us add a facet also along with Header Info.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Activate and refresh and go to object page.

SAP Metadata Extension, SAP CAP Metadata Extension, SAP Fiori Metadata Extension, CAP annotations, CDS annotations SAP, SAP CAP tutorial, SAP Fiori Elements annotations, OData V4 annotations, Metadata extension in SAP CAP, CDS UI annotations, SAP runtime annotations, SAP bookshop annotations example, annotate keyword SAP CAP, create metadata extension in SAP CAP, best practices for metadata extensions, inline annotations vs metadata extension, UI annotation guide for CAP developers, metadata extension tutorial, clean CDS model, metadata extension improves Fiori UI, CAP model annotations, SAP Fiori list report customization, SAP UI behavior definitions, CAP OData service generation, SAP CDS schema annotations

Stay tuned for next blog where will proceed on the same application.

Leave a Comment

Your email address will not be published. Required fields are marked *