You have a CDS view with clean data and good annotations, and someone asks: "Can we get this as an API?" On a modern ABAP stack, the answer can be one annotation. But that one annotation comes with boundaries worth understanding before you lean on it — what it generates, what it cannot do, and when to graduate to a fuller approach.
What it does
The @OData.publish: true annotation is the fastest way to turn a CDS view into a working OData service. Add it to your CDS view definition, activate, and the framework generates the service artifacts for you — no SEGW project, no manual service definition.
@AbapCatalog.sqlViewName: 'ZV_BOOKING'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Booking view'
@OData.publish: true
define view Z_C_Booking as select from zbooking {
key booking_id,
customer,
flight_date,
@Semantics.amount.currencyCode: 'currency'
price
}
What Gets Generated
When you activate a CDS view annotated with @OData.publish: true, the system generates:
- An OData service named after the view (typically
<view>_CDS). - An entity set exposing the view's fields.
- Basic query support ($filter, $orderby, $top, $skip) derived from the view definition.
You can find the generated service in transaction /IWFND/MAINT_SERVICE and register it on the hub system like any other Gateway service.
Which CDS views qualify
Not every CDS view can be published this way. The annotation works on view entities that the framework can map cleanly to an OData entity set:
- Read-shaped views: standard
define view entitydefinitions with a key. The key becomes the OData entity key. - No input parameters: views with
with parameterscannot be published — OData entity sets have no parameter concept, so the framework refuses to generate the service. Remove the parameters or wrap the view in a parameter-free projection. - Annotation-driven UI:
@UIannotations on the view flow through to the generated service's metadata, which is why a published CDS view can feed a Fiori Elements app with almost no extra work.
If activation throws an error mentioning OData generation, the view definition is usually the cause — check for parameters first, then for unsupported constructs in the projection list.
@OData.publish only works on parameter-free view entities. If your view takes input parameters, expose a parameter-free projection on top of it and publish that instead.
@OData.publish vs SEGW vs RAP: choosing the path
Three generations of "expose ABAP data as OData" coexist on SAP systems. Knowing which one fits saves real rework:
| @OData.publish | SEGW project | RAP service | |
|---|---|---|---|
| Effort | One annotation | Model + code-based implementation | Service definition + binding |
| Reads | Yes, full query support | Yes, whatever you implement | Yes |
| Writes (CUD) | No | Yes, hand-coded | Yes, with draft + validations |
| Custom actions | No | Yes (function imports) | Yes (actions/functions) |
| Best for | Quick read APIs, lookups | Legacy Gateway services | Transactional Fiori apps |
The honest rule of thumb: @OData.publish is the fastest route to a read API and the wrong route to a transactional app. SEGW is the legacy path — maintain existing projects there, but do not start new ones. RAP is where new transactional development belongs.
When to use it — and when not to
@OData.publish is ideal for read-only scenarios: exposing master data, analytical views, or simple lookups where you don't need transactional behavior. It's the quickest path from a CDS view to a consumable API.
It is not a replacement for RAP. If you need create/update/delete with draft handling, validations, and behavior logic, build a RAP business object with a service definition and service binding instead. @OData.publish gives you a flat read service; RAP gives you a full application model.
A Practical Flow
- Write your CDS view with the annotations your UI needs (
@UI,@Semantics). - Add
@OData.publish: trueat the header. - Activate. Note the generated
_CDSservice name. - Register and test the service in
/IWFND/GW_CLIENT. - Consume it from a Fiori app or external client.
A note on step 4: /IWFND/GW_CLIENT lets you fire raw requests at the service without building a client first. Test the entity set read, a $filter, and an $expand on any associations before you hand the URL to an app team. Catching a missing key or a misbehaving association here takes minutes; catching it from a Fiori app's network tab takes much longer.
Also worth knowing: the generated service gets a version from the system, and regenerating after view changes is automatic on reactivation. If you rename the CDS view, the service name changes with it — treat the published service name as derived, not stable, and point consumers at it through stable documentation rather than tribal knowledge.
Key takeaway:
@OData.publish: trueturns a CDS view into a live OData service at activation — perfect for read-only exposure. For transactional apps with behavior logic, reach for RAP instead.
Bottom line
One annotation, one activation, one working read API — @OData.publish is the shortest path from a CDS view to a consumable OData service, and for lookups, master data, and analytical views it is all you need. Just respect its boundaries: parameter-free views only, reads only, no behavior logic. The moment you need writes, drafts, or validations, that boundary is telling you to move up to RAP — which builds on the same CDS views you already wrote.