ERPClimb logoERPClimb
Service Definitions
RAP / CDS / ODataintermediate 6 min read

Service Definitions Part 2: Exposing Projection Entities as a Business Service

Preview · a free account unlocks the full lesson

Key takeaway

Decide which projection entities form one business service, write the service definition with meaningful aliases, and verify the result in the binding's entity list and $metadata.

In this lessonShow sections

Visual overview

Service Definitions Part 2: Exposing Projection Entities as a Business Service — learning sheetIn one line: Decide which projection entities form one business service, write the service definition with meaningful aliases, and verify the result in the binding's entity list and $metadata.ERPClimb.com / RAP / LESSON 2/6 / LEARNING SHEETService Definitions Part 2: Exposing Projection Entitiesas a Business Service1 · IN ONE LINEDecide which projection entities form one business service, write the service definitionwith meaningful aliases, and verify the result in the binding's entity list and $metadata.2 · KEY IDEAS EXPLAINEDThink In CapabilitiesZUI_PURCHREQ — buyers maintain purchase requestsin a Fiori app.ZUI_PURCHREQ_APPROVE — approvers review andapprove.What To Expose For A Transactional AppThe root projection (ZC_PurchReq).All composition children the app shows or edits(ZC_PurchReqItem).AliasesThe alias becomes the entity set name:/PurchaseRequest, /PurchaseRequestItem.Use singular business nouns in CamelCase; avoidprefixes like ZC_.VerifyThe binding editor lists the entity sets and theirnavigation.$metadata shows EntityTypes, EntitySets,NavigationProperties and actions.3 · DO · AVOIDBest practice!Common mistakeOne service per capability and consumer type.Expose root, children and requirednavigation/value-help targets.Use stable business aliases.✕One huge service for many apps.✕Forgetting composition children, so objectpages cannot show items.✕Exposing entities "just in case".4 · IN A REAL PROJECTA project had one large service exposing purchase requests, orders, suppliers, approvals and reports for fiveapps. Every change to one app required regression tests of all five, and the $metadata was so large that appsstarted slowly. The team split it by capability: a buyer service, an approver service and a reporting service…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

A service represents a business capability — "maintain purchase requests" — and should expose everything that capability needs and nothing more. That generally means exposing the root plus all composition children used by the app. The aliases chosen in the service definition become entity set names, both in OData and in client code, so after activation it's worth checking the binding's entity list and the resulting $metadata.

Part 1 introduced the business object itself; this part is about deciding what actually goes into one service.

The right way to think about this is in terms of capabilities, where a service supports one business capability for one type of consumer. ZUI_PURCHREQ might let buyers maintain purchase requests in a Fiori app, ZUI_PURCHREQ_APPROVE might let approvers review and approve them, and ZAPI_PURCHREQ might let external systems create and read requests. Each of these gets its own projections and its own service definition. Trying to build "one service for everything" instead makes every change risky for every consumer at once.

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

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.