ERPClimb logoERPClimb
Managed RAP
RAP / CDS / ODataadvanced 14 min read

Managed RAP Part 5: Projection Layer, Testing, Performance and Clean Core

Preview · a free account unlocks the full lesson

Key takeaway

Take the Purchase Request object to production: build the projection layer that services consume, write ABAP Unit tests with EML, avoid the common performance traps in handlers, and keep the design clean-core compliant.

In this lessonShow sections

Visual overview

Managed RAP Part 5: Projection Layer, Testing, Performance and Clean Core — learning sheetIn one line: Take the Purchase Request object to production: build the projection layer that services consume, write ABAP Unit tests with EML, avoid the common performance traps in handlers, and keep the design clean-core compliant.ERPClimb.com / RAP / LESSON 5/5 / LEARNING SHEETManaged RAP Part 5: Projection Layer, Testing, Performanceand Clean Core1 · IN ONE LINETake the Purchase Request object to production: build the projection layer that servicesconsume, write ABAP Unit tests with EML, avoid the common performance traps in handlers, andkeep the design clean-core compliant.2 · KEY IDEAS EXPLAINEDThe Projection Layer — Why It ExistsBase BO (ZR_) — all fields and all behavior.Reused by every consumer.Projection (ZC_) — what one specific app or APIneeds: a subset of fields, a subset of operationsand actions, UI annotations, value helps, and…Build The Projection — Step By Step1. Projection root view: "define root viewentity ZC_PurchReq provider contracttransactional_query as projection on…Testing With EML And ABAP UnitArrange: build input with %cid.Act: MODIFY ENTITIES, and COMMIT ENTITIES RESPONSEOF zr_purchreq when you need the save sequence(validations, on-save determinations).Performance Rules For HandlersOne READ ENTITIES for all keys, never one per keyin a loop.One MODIFY ENTITIES with a table, never one perkey.3 · DO · AVOIDBest practice!Common mistakeOne base BO (ZR_), one projection per consumer(ZC_ for UI, a separate one for APIs).Keep UI annotations in metadata extensions onthe projection, never on the base BO.Write EML-based ABAP Unit tests for everyvalidation, action and feature-control rule…✕Exposing ZR_ base views directly in a service,so every UI change touches the core business…✕Forgetting "redirected to compositionchild / parent" in the projection, which…✕Listing every base operation with"use" in every projection, instead…4 · IN A REAL PROJECTA managed RAP object worked well in testing with one request at a time. After go-live, an integration pushed2,000 approvals in one OData batch, and the call timed out. The cause was a helper method in the approveaction that selected the approver's cost-center data with SELECT SINGLE inside a loop over keys, plus a…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

You now have a complete business object, ZR_PurchReq, with items, numbering, locking, authorization, workflow and draft. This last part covers what separates a working demo from a production object: a stable projection layer for consumers, automated tests, performance, and clean-core rules.

Never expose the ZR_ views directly in a service. Instead put a projection layer, built from ZC_ views, between the business object and its consumers. The base BO (ZR_) holds all fields and all behavior and is reused by every consumer.

A projection (ZC_) exposes only what one specific app or API needs: a subset of fields, a subset of operations and actions, UI annotations, value helps, and search.

Several projections can sit on one BO — for example ZC_PurchReq for the Fiori app and ZA_PurchReq for an API that only allows reads and approvals — and each projection can change without touching the core behavior.

Building the projection follows a fixed sequence. First comes the projection root view: "define root view entity ZC_PurchReq provider contract transactional_query as projection on ZR_PurchReq", where the provider contract transactional_query marks it as a projection for transactional services.

Next, compositions need to be redirected: in the root, "_Item : redirected to composition child ZC_PurchReqItem", and in the child, "_Request : redirected to parent ZC_PurchReq" — without this redirection the projection would still point back to the base views.

Adding @Metadata.allowExtensions: true lets UI annotations live in a separate metadata extension, as covered in the Service Bindings Part 6 lesson.

The projection also needs its own behavior definition — right-click ZC_PurchReq and choose New Behavior Definition — which starts with "projection;" and "use draft;" and then lists only the operations this app may use, such as "use create; use update; use action approve;". Anything not listed stays unavailable to this consumer even though the base BO supports it.

Finally, the service layer takes over: a service definition exposes ZC_PurchReq and ZC_PurchReqItem, and a service binding publishes it as OData V4, exactly as walked through step by step in the Service Bindings series using these same objects.

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.