Lesson 2 of 5
Creating services
10 min
Listen to this lesson
An OData service in SAP S/4HANA comes from one of three places: SAP delivers it as a released API or as the back end of an SAP Fiori app; a developer builds it with the older model-based approach; or a developer builds it with the ABAP RESTful Application Programming Model (RAP). Knowing which kind you are dealing with tells you how it was built, how it is activated and what can break.
- ClassicSAP Gateway Service Builder (SEGW)Model the entities, generate runtime classes, implement read and write methods in ABAP; OData V2
- TransitionalCDS views with the OData publish annotationA CDS view exposed directly as a V2 service; used in the earlier programming model for SAP Fiori
- CurrentRAPCDS data model, behavior definition, service definition and service binding; V2 or V4, recommended for new development
Model-based services with SEGW
In the classic approach a developer creates a project in the SAP Gateway Service Builder (SEGW), defines entity types and entity sets, and generates runtime artifacts: a model provider class that publishes the metadata and a data provider class whose methods read and write data. The developer implements those methods, for example the method that returns the entity set, in ABAP. A converted system like Contoso's carries many such services from ECC, and they still work. They need careful regression testing because their hand-written logic often reads tables whose structure changed in SAP S/4HANA.
RAP: the current model
RAP builds a service in layers, each a separate development object in ABAP Development Tools (ADT) for Eclipse:
The binding type matters. A UI binding (for example OData V4 - UI) carries UI annotations for SAP Fiori elements apps. A Web API binding (for example OData V4 - Web API) is meant for system-to-system consumption without UI metadata. The same service definition can be bound more than once, so one business object can serve a Fiori app and an external API.
SAP's RAP tutorials show a generator in ADT that creates the full stack from a database table: CDS entities, behavior implementation classes, a draft table, a service definition and a service binding of type OData V4 - UI. In the binding editor you publish the local service endpoint and then open a preview of the generated Fiori elements app. In some on-premise and Private Edition setups, the tutorials publish the service group in /IWFND/V4_ADMIN instead; check which applies to your system.
- Define CDS data modelRoot entity ZI_FleetContract with child entity for covered vehicles
- Define behaviorManaged implementation with validation: contract end date after start date
- Project for the use casePortal projection exposes contract number, customer, dates and status only
- Service definitionExposes FleetContract and CoveredVehicle
- Service bindingOData V4 - Web API for FleetLink; publish; test
What would you do?
The portal team asks Kenji to expose a new service for fleet contracts by publishing a CDS view directly with the old publish annotation, "because it is quicker". What should Kenji do?
- Services come from SAP (released APIs, Fiori back ends), SEGW model-based development, or RAP.
- RAP layers: CDS data model, behavior definition, projection, service definition, service binding.
- The binding type decides the protocol (V2 or V4) and purpose (UI or Web API).
- Old custom services carry custom logic into SAP S/4HANA and belong in regression scope.
Check your understanding · not graded
Lesson check
1. Which RAP object turns a service definition into an OData V2 or V4 service?
2. Which binding type suits a system-to-system integration without SAP Fiori UI annotations?
3. Why do custom SEGW services from ECC need regression testing after a conversion?