ERPClimb logoERPClimb
OData Gateway
Architect / Cross-trackintermediate 7 min read

OData Gateway Part 2: SEGW vs RAP — Two Ways to Build OData

Preview · a free account unlocks the full lesson

Key takeaway

Compare the classic SEGW approach (code-based DPC EXT, referenced data sources, mapped CDS) with RAP (CDS + behavior definition + service definition + service binding), including the obsolete @OData. publish shortcut, and decide which to use on a given system and project.

In this lessonShow sections

Visual overview

OData Gateway Part 2: SEGW vs RAP — Two Ways to Build OData — learning sheetFlow: Open your Part 1 SEGW project and list what you had to code → In ADT, look at a released RAP service (e.g. a service binding in your system) and its service definition → Compare: what does RAP give for free (paging, filter, $expand)? → Decide for one planned app which model you would choose and why. Key ideas: SEGW CODE-BASED; SEGW WITH CDS (REFERENCED DATA SOURCE / MAPPING); @OData.PUBLISH (OBSOLETE SHORTCUT); RAP. Watch out: @OData.publish: true on a CDS view was a shortcut in S/4 1511–1909-era systems; it is considered obsolete — do not start new services with it.ERPClimb.com / ARCH / LESSON 2/10 / LEARNING SHEETOData Gateway Part 2: SEGW vs RAP — Two Ways to BuildOData1 · HOW IT FLOWS1Open your Part 1SEGW project andlist what you…2In ADT, look ata released RAPservice (e.g. a…3Comparewhat does RAP give forfree (paging, filter…4Decide for oneplanned appwhich model you…2 · KEY IDEAS EXPLAINEDSEGW Code-BasedEntity types modelled or imported (DDIC,RFC/BAPI).Logic in DPC_EXT methods: GET_ENTITYSET,CREATE_ENTITY, etc.SEGW With CDS (Referenced Data Source /…Data Model → Reference → Data Source: a CDS viewbecomes the entity set; read operations aregenerated.Create/update still coded in DPC_EXT.@Odata.publish (Obsolete Shortcut)Annotation on a CDS view that generates a serviceautomatically (activate in /IWFND/MAINT_SERVICE).Read-only unless combined with BOPF; replaced byRAP.RAPData model: CDS view entities (root + child withcomposition).Behavior definition (BDEF): create, update,delete, validations, determinations, actions.3 · REMEMBER · WATCH OUTRememberSEGW (transaction-based Gateway Service Builder): model entity typesand write CRUD logic yourself in DPC_EXT — full control, more code.RAP (ABAP RESTful Application Programming Model): CDS views + behaviordefinition + service definition + service binding generate the OData…SAP's strategic model for new development is RAP (and the only one inABAP Cloud); SEGW remains supported for existing services and older…!Watch out@OData.publish: true on a CDS viewwas a shortcut in S/4 1511–1909-erasystems; it is considered obsolete —do not start new services with it.4 · IN A REAL PROJECTOn an S/4HANA 2021 project, a team started a new approval app in SEGW out of habit. After three weeks they hadwritten filter, paging, draft-like locking and error mapping by hand, and Fiori elements features like thefilter bar needed more custom code. The architect stopped and rebuilt the app in RAP: CDS view entities, a…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 1 built a small SEGW service; before going deeper, it's worth knowing the alternative you'll meet on every S/4HANA project.

SEGW, the transaction-based Gateway Service Builder, has you model entity types and write CRUD logic yourself in DPC_EXT — full control, but more code: you implement filtering, paging, sorting, $expand, and error handling yourself, and it works on any NetWeaver 7.x Gateway system.

RAP, the ABAP RESTful Application Programming Model, takes a different approach: CDS views, a behavior definition, a service definition, and a service binding together generate the OData service, with the framework handling CRUD, $filter, paging, $expand, draft, and ETags for you.

There's also a middle path within SEGW itself: under Data Model → Reference → Data Source, a CDS view can become the entity set directly, which generates the read operations, while create and update logic is still coded in DPC_EXT — a reasonable middle ground on S/4HANA on-premise when RAP isn't an option.

Separately, @OData.publish: true is an annotation that was used as a shortcut in S/4HANA systems around the 1511–1909 era to generate a service automatically from a CDS view (activated the same way, in /IWFND/MAINT_SERVICE); it's read-only unless combined with BOPF, and it's now considered obsolete — new services shouldn't start with it.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.