SEGW OData Modeling versus CDS-Based Service Exposure
SEGW builds an OData service by hand: model provider and data provider classes generated from a manually drawn entity model, with fetch logic written in ABAP inside DPC_EXT redefinitions. CDS-based exposure generates the same kind of service automatically from an annotated CDS view (via a service definition and binding, or the older @OData.publish annotation), with no data provider class to write for read access. CDS-based exposure is now the default path; SEGW is legacy.
This page compares the classic SAP Gateway Service Builder (SEGW) approach to exposing OData services against generating services directly from annotated CDS views, including through RAP service definitions and bindings. It covers when each is legitimate, how they sit relative to BAPIs, CDS views and RAP behavior definitions in the stack, and the practical failure modes seen when migrating or mixing the two.
Published 16 Sept 2026· 1,462 words
What it is
SEGW is the Service Builder transaction where a developer models an OData service by hand: entity types, entity sets, associations, drawn manually, then generated into a model provider class and a data provider class. Fetch and transform logic is written as ABAP inside DPC_EXT redefinitions, usually calling BAPIs or reading tables directly. CDS-based exposure works the other way round: an existing CDS view entity carries annotations, either the older @OData.publish flag or a RAP service definition activated through a service binding, and the framework generates the service automatically from the view's fields and associations, with no data provider class needed for read scenarios. The one structural fact that explains most confusion: SEGW puts the mapping logic in imperative ABAP inside generated classes, while CDS exposure puts that logic in declarative metadata on the view itself. SEGW services take longer to build but tolerate arbitrary logic; CDS exposure is fast but is only as expressive as the view and its annotations.
When to use it
Default to CDS-based exposure for any new development, especially list report and object page scenarios, because a service definition and binding plus a RAP behavior definition give read and write with very little handwritten code. Use SEGW only when maintaining an existing service already deployed on a system that predates RAP, when a consumer contractually depends on an already-shipped classic OData V2 service with no CDS equivalent, or on an ECC landscape without RAP tooling. Building a new SEGW service on a current S/4HANA system is almost always a mistake: it duplicates what a CDS view and behavior definition express more concisely, and it is the pattern explicitly discouraged under clean core guidance. If business logic genuinely cannot be expressed declaratively — heavy cross-system orchestration, unusual locking, mid-request calls to remote systems — the answer is normally an unmanaged RAP business object behind the CDS exposure, not a fallback to SEGW.
How it fits the stack
Below SEGW sit BAPIs, function modules or direct table reads invoked from DPC_EXT redefinitions. Below CDS-based exposure sit CDS view entities with their associations, plus a RAP behavior definition and implementation for anything beyond read. Above both sits the OData protocol layer — V2 only for SEGW-generated services, V2 or V4 for CDS-based ones — and then a Fiori Elements or freestyle UI consuming the service. SEGW services are registered through the IWBEP model and runtime and the service catalog. CDS-based services are registered through a service definition bound to a chosen OData protocol version in a service binding, generated straight from the annotated view. CDS-based exposure with RAP is the object model that supersedes SEGW for anything transactional going forward; SEGW is not receiving new capability and is treated as the legacy path in current landscapes.
A worked example
A consultant needs a read-only list of purchase requisitions, header plus items, for a Fiori list report. With SEGW: model an entity type in the Service Builder matching a custom structure, generate the runtime artifacts, then write a GET_ENTITYSET redefinition in the DPC_EXT class that selects from the requisition tables, applies the filters arriving as OData query options, and maps the result field by field into the generated structure. With CDS-based exposure: build a CDS view entity selecting from the requisition header table with an association to items, then either annotate it with @OData.publish: true or, in RAP style, expose it through a service definition and activate that definition for OData V2 or V4 in a service binding. Filtering, sorting and paging on exposed fields work without any handwritten ABAP, because the generated service delegates straight to the view's SQL. The CDS route produces a working service in a fraction of the lines; the only logic written is inside the view definition itself — associations, access conditions — rather than inside a data provider class.
How to choose
- Target landscape: is this a current S/4HANA system with RAP available, or an older system where CDS-based service definitions and bindings are not an option — the second case is the only honest justification for touching SEGW today.
- Read-only versus transactional: pure read exposure from a CDS view costs almost nothing to build; full create/update/delete support means committing to a RAP behavior definition, which is more setup than a read-only @OData.publish view but far less than a hand-written DPC with locking and BAPI calls wired in manually.
- Existing service inventory: is there already a working SEGW service for this business object that consumers depend on — if so, the cost of a rewrite has to be weighed against the ongoing maintenance and upgrade cost of leaving it as SEGW.
- Flexibility for edge cases: does the requirement include logic that resists declarative expression, such as orchestrating several remote calls inside one request — if so the choice is not SEGW versus CDS, it is managed RAP versus unmanaged RAP, both still exposed through CDS.
- Team skillset and time available: a team fluent in classic ABAP OO but new to CDS annotations and RAP will be faster with SEGW in the short term, but that speed advantage disappears once the service needs upgrading or extending.
- Governance: does the organization have a clean core policy that already rules SEGW out for new builds — if so this is not really a technical decision at all, it is a compliance check.
Common pitfalls
- Writing ABAP-side filtering and sorting inside a DPC_EXT method instead of pushing conditions down into the underlying select — passes with a handful of test records, produces full table scans once the requisition table has production volume.
- Assuming a SEGW-to-CDS migration is a mechanical field rename — entity keys, associations and cardinalities rarely line up one-to-one, and mismatched keys silently break ETag-based concurrency control on the new service.
- Reaching for @OData.publish for a quick exposure, then discovering the requirement has grown to include custom validations or multi-step create logic that the generated write behavior cannot express, forcing a rebuild under a proper RAP behavior definition later at higher cost than building it correctly the first time.
- Forgetting that SEGW-generated services are OData V2 only, then being surprised when a newer UI framework or integration expects V4 semantics.
- Adding a custom field to a SEGW entity type by hand and later replacing that service with a CDS-based one without carrying the field into the view or its associations, so UI annotations that reference the field by name fail to bind at runtime.
- Maintaining parallel SEGW and CDS-based services for the same business object during a phased migration, so the same business rule ends up implemented twice and drifts apart over successive changes.
ECC, S/4HANA and clean core
On S/4HANA, CDS-based exposure through RAP is the recommended path and, for extensibility purposes, effectively the only sanctioned one for new service development. SEGW still runs and existing generated services keep functioning, but building new SEGW services is discouraged under clean core principles, since the generated data provider classes sit outside the released API surface and complicate future upgrades. Moving an existing SEGW service to CDS-based exposure is not a mechanical conversion: it usually means re-modeling the entity as a CDS view and, for anything beyond read, building a RAP behavior definition and implementation from scratch, then repointing the consuming UI's service binding at the new service.
Whose problem this is
This is primarily a build-time developer decision, but an architect should set a landscape-wide standard so individual developers are not each re-deciding SEGW versus CDS project by project. Functional consultants get pulled in when annotations need to carry business semantics such as currency conversion, unit handling or value help. A handover should record the service definition or SEGW service name, the OData protocol version, and which underlying tables or CDS views back it.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-technical-topics/segw-versus-cds-based-service-exposureERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.