Beyond ABAPdesigned by@Tejoram97
Beyond ABAP / RAP / Projection, UI, Access Control & Service

Projection, UI, Access Control & Service

RAP · ABAP Development ·

Open the interactive lesson →
  1. Requirements and the projection views (R2)
  2. Metadata extensions: list report and object page (R2)
  3. Value help, text and search (R2)
  4. Processor and approver apps on one BO (R11)
  5. Access control (DCL) and authorization objects (R3)
  6. Service definition, service binding and preview
  7. OData requests and the deployed Fiori app
  8. Interview questions

This page turns the base BO into apps people can use: projection views, metadata extensions, value help and search for the reps' list report and object page (R2), a second, simpler projection and service for the managers' approval app (R11, UI side), access control by sales organisation with the authorization object and PFCG / IAM roles (R3), and finally the service definition, binding, preview and the deployed Fiori app.

Part 1 – Requirements and the projection views (R2)

The base BO from 02 · Data Model & CDS is reusable and knows nothing about screens. The projection is the shop window for one app: it picks fields, adds search and value help, and the metadata extension arranges them on the screen. Fiori elements then draws the whole app from these annotations – no UI5 code. Access control decides which rows reach the window at all, and the service opens it to the outside.

1.1 Requirements on this page

R-ID

Requirement

Where on this page

R2

Users find orders by customer, status or date; see the amount and status colour

Part 1 (projection), Part 2 (list report, object page), Part 3 (value help, search)

R3

A rep sees only orders of their sales organisation

Part 5 (access control, authorization object, PFCG / IAM). Behavior authorization → 06 · Feature Control, Authorization & Numbering

R11

Approver uses a separate, simpler app (approve / reject only)

Part 4 (UI side: approver projection, metadata extension, service). Projection BDEF → 04 · Behavior Definition & Behavior Pool

R1, R7

Create, edit, delete; Approve / Reject buttons

Part 2 (buttons), Part 6 (preview)

1.2 Projection views

One base BO can have several projections (the processor app here, the approver app in Part 4), each exposing a different subset. ADT: right-click ZR_SalesOrder → New Data Definition → template *Define Projection View*.

@EndUserText.label: 'Sales order - projection'
@AccessControl.authorizationCheck: #CHECK
@Metadata.allowExtensions: true
@Search.searchable: true
@ObjectModel.semanticKey: [ 'SalesOrderID' ]
define root view entity ZC_SalesOrder
provider contract transactional_query
as projection on ZR_SalesOrder
{
key OrderUUID,
@Search.defaultSearchElement: true
SalesOrderID,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@ObjectModel.text.element: [ 'CustomerName' ]
@Consumption.valueHelpDefinition: [{ entity: { name:    'ZI_CustomerVH',
element: 'Customer' } }]
CustomerID,
_Customer.CustomerName as CustomerName,
SalesOrganization,
OrderDate,
@Consumption.valueHelpDefinition: [{ entity: { name:    'ZI_SO_StatusVH',
element: 'Status' } }]
Status,
StatusCriticality,
NetAmount,
@Consumption.valueHelpDefinition: [{ entity: { name:    'I_CurrencyStdVH',
element: 'Currency' } }]
Currency,
CreatedBy,
CreatedAt,
LocalLastChangedAt,
LastChangedAt,
_Item : redirected to composition child ZC_SalesOrderItem
}
@EndUserText.label: 'Sales order item - projection'
@AccessControl.authorizationCheck: #CHECK
@Metadata.allowExtensions: true
define view entity ZC_SalesOrderItem
as projection on ZR_SalesOrderItem
{
key ItemUUID,
ParentUUID,
ItemNo,
MaterialID,
Quantity,
@Consumption.valueHelpDefinition: [{ entity: { name:    'I_UnitOfMeasureStdVH',
element: 'UnitOfMeasure' } }]
Unit,
NetPrice,
Currency,
LocalLastChangedAt,
_SalesOrder : redirected to parent ZC_SalesOrder
}

Provider contract

Use

transactional_query

Projection for a transactional OData service (UI or Web API) – this page

transactional_interface

BO interface (ZI_SalesOrderTP) for stable reuse and release (→ 04)

analytical_query

Analytical queries (InA)

  • redirected to composition child / parent – the projection tree must point to projection entities. Common mistake: forgetting the redirect – the service would expose the ZR_ child and activation fails.
  • _Customer.CustomerName is a path expression: the name is read from I_Customer without exposing the association in the service. Such fields are read-only.
  • Common mistake: putting logic in the projection. All behavior lives in the base BO; the projection only exposes it (use … in the projection BDEF, → 04) and adds UI metadata.
  • Check the element names of a released value-help view in ADT before using it (e.g. the unit element of I_UnitOfMeasureStdVH).

Part 2 – Metadata extensions: list report and object page (R2)

A metadata extension keeps the long @UI annotations out of the view. ADT: right-click the projection → New Metadata Extension (same name as the entity). @Metadata.layer: #CUSTOMER is the layer for customer objects. R2 in screen terms: filter fields for customer, status and date, an amount column and a coloured status.

Annotated list report: typeNamePlural title, search field, selection fields with value help, Create and Delete from the BDEF, action buttons from #FOR_ACTION, columns from lineItem, text arrangement, status criticality colours, semantic key in bold
Annotated object page: headerInfo title and description, header data points, Edit Delete Approve Reject buttons, one tab per facet, identification section, Admin Data field group, Items table from LINEITEM_REFERENCE, hidden technical key

2.1 Header metadata extension

@Metadata.layer: #CUSTOMER
@UI.headerInfo: { typeName: 'Sales Order', typeNamePlural: 'Sales Orders',
title:       { type: #STANDARD, value: 'SalesOrderID' },
description: { type: #STANDARD, value: 'CustomerName' } }
@UI.presentationVariant: [{ sortOrder: [{ by: 'SalesOrderID', direction: #DESC }],
visualizations: [{ type: #AS_LINEITEM }] }]
annotate entity ZC_SalesOrder with
{
@UI.facet: [
{ id: 'HdrAmount', purpose: #HEADER,   type: #DATAPOINT_REFERENCE,
targetQualifier: 'NetAmount', position: 10 },
{ id: 'HdrStatus', purpose: #HEADER,   type: #DATAPOINT_REFERENCE,
targetQualifier: 'Status',    position: 20 },
{ id: 'General',   purpose: #STANDARD, type: #IDENTIFICATION_REFERENCE,
label: 'General Information', position: 10 },
{ id: 'Admin',     purpose: #STANDARD, type: #FIELDGROUP_REFERENCE,
targetQualifier: 'Admin', label: 'Admin Data', position: 20 },
{ id: 'Items',     purpose: #STANDARD, type: #LINEITEM_REFERENCE,
targetElement: '_Item', label: 'Items', position: 30 } ]

@UI.hidden: true
OrderUUID;

@UI: { lineItem:       [ { position: 10 },
{ type: #FOR_ACTION, dataAction: 'copyOrder', label: 'Copy' } ],
identification: [ { position: 10 } ],
selectionField: [ { position: 10 } ] }
SalesOrderID;

@UI: { lineItem:       [ { position: 20 } ],
identification: [ { position: 20 } ],
selectionField: [ { position: 20 } ],
textArrangement: #TEXT_FIRST }
CustomerID;

@UI: { identification: [ { position: 25 } ] }
SalesOrganization;

@UI: { lineItem:       [ { position: 30 } ],
identification: [ { position: 30 } ],
selectionField: [ { position: 30 } ] }
OrderDate;

@UI: { lineItem:       [ { position: 40, criticality: 'StatusCriticality' },
{ type: #FOR_ACTION, dataAction: 'approve', label: 'Approve' },
{ type: #FOR_ACTION, dataAction: 'reject',  label: 'Reject' } ],
identification: [ { position: 40, criticality: 'StatusCriticality' },
{ type: #FOR_ACTION, dataAction: 'approve', label: 'Approve' },
{ type: #FOR_ACTION, dataAction: 'reject',  label: 'Reject' } ],
selectionField: [ { position: 40 } ],
dataPoint:      { qualifier: 'Status', title: 'Status',
criticality: 'StatusCriticality' } }
Status;

@UI.hidden: true
StatusCriticality;

@UI: { lineItem:       [ { position: 50 } ],
identification: [ { position: 50 } ],
dataPoint:      { qualifier: 'NetAmount', title: 'Net Amount' } }
NetAmount;

@UI.fieldGroup: [ { qualifier: 'Admin', position: 10 } ]
CreatedBy;
@UI.fieldGroup: [ { qualifier: 'Admin', position: 20 } ]
CreatedAt;
@UI.fieldGroup: [ { qualifier: 'Admin', position: 30 } ]
LocalLastChangedAt;
}

2.2 Item metadata extension

A second metadata extension ZC_SalesOrderItem gives the item table its columns and the item object page:

@Metadata.layer: #CUSTOMER
@UI.headerInfo: { typeName: 'Item', typeNamePlural: 'Items',
title: { type: #STANDARD, value: 'ItemNo' } }
annotate entity ZC_SalesOrderItem with
{
@UI.facet: [ { id: 'Item', purpose: #STANDARD, type: #IDENTIFICATION_REFERENCE,
label: 'Item', position: 10 } ]
@UI.hidden: true
ItemUUID;
@UI.hidden: true
ParentUUID;
@UI: { lineItem: [ { position: 10 } ], identification: [ { position: 10 } ] }
ItemNo;
@UI: { lineItem: [ { position: 20 } ], identification: [ { position: 20 } ] }
MaterialID;
@UI: { lineItem: [ { position: 30 } ], identification: [ { position: 30 } ] }
Quantity;
@UI: { lineItem: [ { position: 40 } ], identification: [ { position: 40 } ] }
NetPrice;
}

2.3 Which annotation draws what

Annotation

Screen area

@UI.headerInfo

Title of list (typeNamePlural) and object page (typeName, title, description)

@UI.selectionField

Filter fields in the list report's filter bar (R2: customer, status, date)

@UI.lineItem

Table columns (list report, or item table in the object page); #FOR_ACTION = toolbar button

@UI.identification

Fields of the #IDENTIFICATION_REFERENCE section; #FOR_ACTION = header button

@UI.facet

Sections / tabs of the object page; #HEADER facets go in the header

@UI.fieldGroup

Named group of fields for a #FIELDGROUP_REFERENCE section

@UI.dataPoint

A highlighted value (KPI) in the header

criticality

Colour + icon: 0 neutral, 1 red (negative), 2 orange (critical), 3 green (positive)

@UI.hidden

Field is transported but never shown

@UI.presentationVariant

Default sort order (and more) of the list

@UI.textArrangement

#TEXT_FIRST, #TEXT_LAST, #TEXT_ONLY, #TEXT_SEPARATE

  • A #FOR_ACTION button appears only if the action also exists in the base BDEF and is exposed with use action in the projection BDEF (→ 04 · Behavior Definition & Behavior Pool). Whether it is enabled for this order and this user is feature control and authorization (R7 → 06 · Feature Control, Authorization & Numbering): reps see Approve greyed out.
  • Read-only (grey) fields come from the BDEF (field ( readonly )), not from annotations.
  • Common mistake: @Metadata.allowExtensions: true missing on the projection – the metadata extension activates with an error and the app shows only key fields.

Part 3 – Value help, text and search (R2)

"Find orders by customer" (R2) means the user must not type customer numbers from memory: a value help offers them, the name is shown next to the number, and the search box finds orders by number or customer, even with typos.

Value help flow: user presses the value help icon, Fiori reads the ValueList annotation from $metadata, queries ZI_CustomerVH in a dialog, copies the chosen Customer into CustomerID and shows the name via the text element; additionalBinding, dropdown with sizeCategory XS, standard SAP value-help views

3.1 Value-help views

A value help is just another CDS view. Wrap the released view so you control the columns and the search:

@EndUserText.label: 'Customer value help'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Search.searchable: true
define view entity ZI_CustomerVH
as select from I_Customer
{
@Search.defaultSearchElement: true
key Customer,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Semantics.text: true
CustomerName,
Country,
CityName
}
@EndUserText.label: 'Sales order status value help'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.resultSet.sizeCategory: #XS                  // dropdown instead of a dialog
define view entity ZI_SO_StatusVH
as select from DDCDS_CUSTOMER_DOMAIN_VALUE_T( p_domain_name: 'ZDO_SO_STATUS' )
{
key value_low as Status,
@Semantics.text: true
text      as StatusText
}
where language = $session.system_language
  • DDCDS_CUSTOMER_DOMAIN_VALUE_T is a released table function that reads the fixed values and texts of your own domains (only domains in ABAP Cloud software components – check your release). Alternative: a small own table with the status texts.
  • @ObjectModel.resultSet.sizeCategory: #XS turns the value help into a dropdown – good for 2–20 values.
  • ZI_CustomerVH has no access control of its own (#NOT_REQUIRED): the access control of I_Customer does not carry over to a view that selects from it. If customers must be restricted too, give the value help its own role.
  • additionalBinding passes or returns further fields: additionalBinding: [{ localElement: 'Country', element: 'Country', usage: #FILTER }] would pre-filter the customer dialog by a Country field of the order. #RESULT copies a value back, #FILTER_AND_RESULT does both.
  • Value-help views used in the projection are exposed in the service automatically – no expose line.
  • Newer releases support useForValidation: true inside @Consumption.valueHelpDefinition, so typed values are checked against the value help – check your release. The business check "customer exists and is not blocked" (R6) still belongs in a validation (→ 05 · Business Logic & Messages).

3.2 Text and search

  • Text next to a code: @ObjectModel.text.element: [ 'CustomerName' ] + @UI.textArrangement. The text element must be in the projection (_Customer.CustomerName as CustomerName).
  • Search: @Search.searchable: true on the view, @Search.defaultSearchElement: true on the fields the search box looks in, @Search.fuzzinessThreshold (0–1) for typo-tolerant search.

3.3 More useful elements

Need

How

Simple calculated field

CASE / arithmetic in the base view, e.g. StatusCriticality (→ 02)

Field calculated in ABAP

Virtual element in the projection (→ 11 · Files, Custom Entities & Integration)

Fields of another entity

Path expression _Customer.CustomerName

Default sort

@UI.presentationVariant

Default filter value

@Consumption.filter.defaultValue: 'N' on the projection element (used in Part 4)

Edit many rows in one table

Multi-inline edit via a singleton root entity that composes the real table (newer releases; see the ABAP cheat sheets – check your release)

Read-only list with totals

Projection with transactional_query + @OData.applySupportedForAggregation for an analytical table in Fiori elements (check your release)

Part 4 – Processor and approver apps on one BO (R11)

R11: the sales manager wants a separate, simpler app that only approves or rejects. Instead of a second BO you build a second projection, metadata extension and service on the same base BO. All logic (validations, approve, reject) stays written once in ZR_SalesOrder.

Processor and approver pattern: Manage Sales Orders app for reps with Create Edit Delete Copy (Approve and Reject disabled for reps) on ZC_SalesOrder and service ZUI_SalesOrder; Approve Sales Orders app with only Approve and Reject on ZC_SalesOrderApv and service ZUI_SalesOrderApv; both projections sit on ZR_SalesOrder; R3 DCL per projection, R7 authorization in the base BO

4.1 Approver projection view

@EndUserText.label: 'Sales order - approver projection'
@AccessControl.authorizationCheck: #CHECK
@Metadata.allowExtensions: true
@Search.searchable: true
define root view entity ZC_SalesOrderApv
provider contract transactional_query
as projection on ZR_SalesOrder
{
key OrderUUID,
@Search.defaultSearchElement: true
SalesOrderID,
@ObjectModel.text.element: [ 'CustomerName' ]
CustomerID,
_Customer.CustomerName as CustomerName,
SalesOrganization,
OrderDate,
@Consumption.filter.defaultValue: 'N'           // open the list on orders waiting for approval
Status,
StatusCriticality,
NetAmount,
Currency,
LocalLastChangedAt,
LastChangedAt,
_Item : redirected to composition child ZC_SalesOrderItemApv
}
@EndUserText.label: 'Sales order item - approver projection'
@AccessControl.authorizationCheck: #CHECK
@Metadata.allowExtensions: true
define view entity ZC_SalesOrderItemApv
as projection on ZR_SalesOrderItem
{
key ItemUUID,
ParentUUID,
ItemNo,
MaterialID,
Quantity,
Unit,
NetPrice,
Currency,
LocalLastChangedAt,
_SalesOrder : redirected to parent ZC_SalesOrderApv
}
  • The approver tree needs its own item projection: ZC_SalesOrderItem already redirects _SalesOrder to the processor root, and a composition child belongs to exactly one projection tree.
  • Fewer fields, no value helps: the manager decides on customer, amount and items, but edits nothing.
  • The projection BDEF exposes only use action approve; use action reject; plus the items for display – no create, update or delete (→ 04 · Behavior Definition & Behavior Pool).

4.2 Approver metadata extension and service

@Metadata.layer: #CUSTOMER
@UI.headerInfo: { typeName: 'Order to Approve', typeNamePlural: 'Orders to Approve',
title: { type: #STANDARD, value: 'SalesOrderID' } }
annotate entity ZC_SalesOrderApv with
{
@UI.facet: [ { id: 'General', purpose: #STANDARD, type: #IDENTIFICATION_REFERENCE,
label: 'Order', position: 10 },
{ id: 'Items',   purpose: #STANDARD, type: #LINEITEM_REFERENCE,
targetElement: '_Item', label: 'Items', position: 20 } ]
@UI.hidden: true
OrderUUID;
@UI: { lineItem: [ { position: 10 } ], identification: [ { position: 10 } ],
selectionField: [ { position: 10 } ] }
SalesOrderID;
@UI: { lineItem: [ { position: 20 } ], identification: [ { position: 20 } ],
textArrangement: #TEXT_FIRST }
CustomerID;
@UI: { lineItem: [ { position: 30 } ], identification: [ { position: 30 } ] }
NetAmount;
@UI: { lineItem:       [ { position: 40, criticality: 'StatusCriticality' },
{ type: #FOR_ACTION, dataAction: 'approve', label: 'Approve' },
{ type: #FOR_ACTION, dataAction: 'reject',  label: 'Reject' } ],
identification: [ { position: 40, criticality: 'StatusCriticality' },
{ type: #FOR_ACTION, dataAction: 'approve', label: 'Approve' },
{ type: #FOR_ACTION, dataAction: 'reject',  label: 'Reject' } ],
selectionField: [ { position: 20 } ] }
Status;
@UI.hidden: true
StatusCriticality;
}
@EndUserText.label: 'Sales order approval service'
define service ZUI_SalesOrderApv {
expose ZC_SalesOrderApv     as SalesOrder;
expose ZC_SalesOrderItemApv as Item;
}
  • The item columns come from a small metadata extension ZC_SalesOrderItemApv with @UI.lineItem on ItemNo, MaterialID, Quantity and NetPrice, as in Part 2.2.
  • Binding ZUI_SalesOrderApv_O4 (OData V4 – UI), its own IAM app / PFCG start authorization and its own access control ZC_SALESORDERAPV (Part 5), so only managers get the approver tile.
  • Interview tip: "The projection only decides which buttons a role sees. Who may really approve is checked in the base BO, so the rule also holds for EML callers and the Web API."

Part 5 – Access control (DCL) and authorization objects (R3)

Two questions: may the user open the app at all, and which orders may they see? R3 answers the second one: a rep sees only orders of their sales organisation. The authorization object and the access control are the same everywhere; only the way the values reach the user differs – a PFCG role on-premise, an IAM app → business catalog → business role in ABAP Cloud.

Authorization chain for R3: on-premise authorization object ZAO_SO with ACTVT and ZSO_VKORG, PFCG menu with launchpad catalog and S_SERVICE, PFCG authorization values, user; ABAP Cloud authorization object, IAM app with service and authorizations, business catalog published locally, business role with access categories and restrictions; at runtime the DCL filters reads by SalesOrganization and BDEF authorization protects changes

5.1 Authorization object

Create authorization field ZSO_VKORG (data element ZDE_SALES_ORG) and authorization object ZAO_SO with fields ACTVT and ZSO_VKORG – in ADT (*New → Authorization Field / Authorization Object*), or SU20 / SU21 on-premise. Activities: 01 create, 02 change, 03 display, 06 delete. The same object is checked for changes in the behavior pool (→ 06 · Feature Control, Authorization & Numbering).

5.2 Access control – which rows a user may read

ADT: right-click the view → New Access Control. The role adds a WHERE condition to every read: list report, object page, OData and EML reads.

@EndUserText.label: 'Sales orders: by sales organisation'
@MappingRole: true
define role ZR_SALESORDER {
grant select on ZR_SalesOrder
where ( SalesOrganization ) = aspect pfcg_auth( ZAO_SO, ZSO_VKORG, ACTVT = '03' );
}
@EndUserText.label: 'Sales order projections: same rules as the base view'
@MappingRole: true
define role ZC_SALESORDER {
grant select on ZC_SalesOrder
where inheriting conditions from entity ZR_SalesOrder;
}

@EndUserText.label: 'Approver projection: same rules as the base view'
@MappingRole: true
define role ZC_SALESORDERAPV {
grant select on ZC_SalesOrderApv
where inheriting conditions from entity ZR_SalesOrder;
}
  • Each access control is its own repository object; the two roles above are shown together only to save space.
  • Each CDS level needs its own access control – a projection does not inherit it automatically; inheriting conditions from entity reuses the rules. The item view is protected the same way, or reached only through its order.
  • Simple variant without an authorization object: where CreatedBy = aspect user (users see only their own orders).
  • The access control protects reading. Create, update, delete and actions – e.g. a rep creating an order for another sales organisation, or approving (R7) – are protected by authorization in the BDEF (→ 06 · Feature Control, Authorization & Numbering).
  • Common mistake: #CHECK on the view but no role → only a warning, everyone sees everything. Or a role with a wrong condition → the list is empty and nobody knows why (check with the access control test in ADT).

5.3 Getting the values to the user

Step

On-premise (PFCG)

ABAP Cloud (IAM)

Start the app

PFCG role menu: launchpad catalog + the OData service (start authorization S_SERVICE)

IAM app (type External App) lists the service ZUI_SalesOrder_O4

Values

PFCG Authorizations tab: ZAO_SO with ACTVT 02/03, ZSO_VKORG 1010; SU24 can propose default values for the service

IAM app Authorizations tab: ZAO_SO values; values that an admin maintains later use restriction fields / types

Bundle

The role itself

Business catalog (ADT) containing the IAM app → Publish Locally

Assign

SU01 / PFCG user tab, user comparison

Fiori app Maintain Business Roles: add the catalog, set access categories (Read, Write, Value Help) and restrictions, add business users

  • For R11 the manager gets a second role or catalog with the approver service ZUI_SalesOrderApv_O4; the rep's role does not contain it, so the rep never sees that tile.
  • Interview tip: "The access control filters what I can read; BDEF authorization checks what I can change; PFCG or IAM only delivers the values to the user."

Part 6 – Service definition, service binding and preview

The BO is finished, but nobody outside ABAP can reach it yet. The service definition says *what* to expose (which entities), the service binding says *how* (OData V2 or V4, UI or Web API). Think of a menu (definition) and the delivery channel (binding: dine-in or takeaway).

Service definition ZUI_SalesOrder exposes SalesOrder and Item; binding ZUI_SalesOrder_O4 (OData V4 UI) feeds the Fiori app, ZAPI_SalesOrder_O4 (OData V4 Web API) feeds other systems; binding editor steps and binding types

6.1 Service definition – what to expose

@EndUserText.label: 'Sales order service'
define service ZUI_SalesOrder {
expose ZC_SalesOrder     as SalesOrder;
expose ZC_SalesOrderItem as Item;
}
  • Repository object type SRVD (service binding = SRVB) – transported, syntax-checked and activated like any ABAP object. ADT: right-click ZC_SalesOrder → New Service Definition.
  • The alias (as SalesOrder) becomes the OData entity set name. Value-help views used in the projection are exposed automatically.
  • A service definition can expose entities of several BOs. Newer releases can also expose an AMDP method (since BTP 2502 – check your release).
  • A UI service can even be built on an SAP-released BO interface whose view allows it (@ObjectModel.supportedCapabilities: [#UI_PROVIDER_PROJECTION_SOURCE]) – check your release.

6.2 Service binding – how to expose

Binding type

Use

OData V4 – UI

Fiori elements apps – recommended for new transactional apps (draft, side effects)

OData V2 – UI

Existing or older Fiori apps

OData V4 / V2 – Web API

API for other systems – no UI annotations (R18 → 11 · Files, Custom Entities & Integration)

InA – UI

Analytical queries (live access from analytics clients)

SQL – Web API

SQL access to published CDS objects (SAP Business AI Platform, ABAP environment)

OData V2

OData V4

Status

Mature, still supported

SAP's recommendation for new RAP apps

Draft, side effects, newer Fiori features

Partly (some features V4-only, e.g. side-effect messages)

Full support

Batch / payload

Verbose JSON

Leaner JSON, better $batch, $apply

Choose when

The consumer only speaks V2

Always, unless a consumer forces V2

  • The service name equals the binding name and must be unique in the system: ZUI_SalesOrder_O4 (UI), ZUI_SalesOrderApv_O4 (approver UI), ZAPI_SalesOrder_O4 (Web API). Suffixes _O4 / _O2 show the protocol.
  • After creating the binding: Activate → Publish → select SalesOrder → Preview (Fiori elements preview in the browser). Publishing creates the local service endpoint; on-premise V4 services can also be managed in /IWFND/V4_ADMIN.
  • Common mistake: changing the service definition (new entity, new alias) without re-publishing the binding – the app still sees the old $metadata. Re-publish, then clear the browser / app cache.

6.3 What you see in the preview

Screen

Comes from

List report with search and filter bar (Sales Order, Customer, Date, Status) and columns (R2)

@UI.selectionField, @UI.lineItem, @Search annotations (Part 2, 3)

Only orders of my sales organisation (R3)

Access control ZC_SALESORDER (Part 5)

Buttons Create, Delete, Copy, Approve, Reject (R1, R7, R8)

BDEF operations and actions + use in the projection BDEF (→ 04) + #FOR_ACTION annotations

Object page with header, General Information, Admin Data and Items

@UI.headerInfo, @UI.facet, @UI.identification, @UI.fieldGroup

Edit → fields editable, Save / Discard Draft (R10)

with draft and the draft actions (→ 07)

Grey (read-only) fields: Sales Order, Status, Net Amount

field ( readonly ) (→ 04)

Coloured status (R2)

criticality: 'StatusCriticality'

6.4 Preview problems

  • 403 Forbidden: most often missing authorization for the service (on-premise: no start authorization S_SERVICE in the user's role; cloud: the service is not in an IAM app / business role). Less often a blocked HTTP service (UCON allowlist). On-premise, /IWFND/ERROR_LOG shows the reason.
  • Empty list: no data in the tables (demo class on 02 · Data Model & CDS) or the access control filters every row – e.g. the user has no ZAO_SO value for the sales organisation of the demo orders.

Part 7 – OData requests and the deployed Fiori app

7.1 What an OData request looks like

The preview and the real app send plain HTTP requests, bundled in $batch. Knowing them makes debugging much easier (browser F12 → Network).

OData V4 requests of the sales order app: GET list with filter, select, orderby, top and count; GET object with expand _Item; POST Edit; PATCH draft; POST Activate; POST approve – each mapped to what RAP does
GET   .../$metadata                                                          " service + annotations
GET   .../SalesOrder?$filter=Status eq 'N'&$top=30&$count=true               " list report
GET   .../SalesOrder(OrderUUID=<uuid>,IsActiveEntity=true)?$expand=_Item     " object page
POST  .../SalesOrder(OrderUUID=<uuid>,IsActiveEntity=true)/<NS>.Edit
PATCH .../SalesOrder(OrderUUID=<uuid>,IsActiveEntity=false)  { "CustomerID": "0010100002" }
POST  .../SalesOrder(OrderUUID=<uuid>,IsActiveEntity=false)/<NS>.Activate
  • Base URL ... of the V4 UI binding: /sap/opu/odata4/sap/zui_salesorder_o4/srvd/sap/zui_salesorder/0001/ – the binding name, then the service definition name and version. <NS> is the namespace com.sap.gateway.srvd.zui_salesorder.v0001.
  • IsActiveEntity is the extra key every draft-enabled entity gets – the OData view of %is_draft (→ 07 · Locking, Draft & Side Effects).
  • Reads are queries (SQL on the projection, filtered by the access control) with no handler code; changes and actions go through the transactional runtime and the behavior pool.

7.2 Building and deploying the Fiori elements app

The preview is for developers. Users get a deployed app with a launchpad tile – one for the reps, one for the managers (R11).

From preview to launchpad app: generate in Business Application Studio or VS Code with Fiori tools, connect to service ZUI_SALESORDER_O4, adjust and test locally, deploy as BSP application; then launchpad content and PFCG role on-premise, or IAM app, business catalog and business role in ABAP Cloud
  • Generate: SAP Business Application Studio (BTP) or VS Code with SAP Fiori tools → *Fiori generator* → *List Report Page* → data source: the ABAP system → service ZUI_SALESORDER_O4 → main entity SalesOrder, navigation entity _Item. The approver app is generated the same way from ZUI_SALESORDERAPV_O4.
  • Test: npm start runs the app locally against the real service; the layout still comes from the backend annotations, so most changes are made in the metadata extension, not in the app.
  • Deploy: npm run deploy stores the app as a BSP application in the ABAP repository (package + transport request).
  • Tile on-premise: launchpad content (catalog, target mapping with semantic object and action, tile) + PFCG role with the catalog and the OData service.
  • Tile in ABAP Cloud: deploying with launchpad configuration creates an IAM app for the UI (check your release); add it with the service's IAM app to the business catalog and assign the business role (Part 5).
  • Typical RAP apps: simple data maintenance (the modern replacement for SM30 table maintenance), work lists (list report) and master-detail apps (list report + object page with a child table, like this one).

Part 8 – Interview questions

Q1. Why projection views, and why several projections on one BO?

A projection gives one service its subset of fields plus UI semantics (value help, search, metadata extension); provider contract transactional_query marks it for a transactional service. The base BO stays reusable. Different roles get different projections: ZC_SalesOrder for reps with create, edit and copy, ZC_SalesOrderApv for managers with only approve and reject – each with its own projection BDEF, metadata extension and service.

Q2. Access control (DCL) vs behavior authorization?

An access control filters which rows a user may read – it adds a WHERE condition to every select on the view, e.g. only the user's sales organisation. Behavior authorization (global / instance in the BDEF) decides whether a user may change data or execute an action such as Approve. A complete app needs both.

Q3. Service definition vs service binding?

The service definition says which entities are exposed and is protocol-agnostic. The service binding adds the protocol and scenario – OData V2 or V4, UI or Web API – and is published and previewed in ADT. One definition can have several bindings, e.g. ZUI_SalesOrder_O4 for the app and a Web API binding.

Q4. Why put UI annotations in a metadata extension?

It keeps the projection readable and separates layout from data: @UI annotations for list report and object page live in their own object, layered (#CUSTOMER and others) and changeable without touching the view. The projection must allow it with @Metadata.allowExtensions: true.

Q5. How do you build a value help for the customer field?

Create a small CDS view on the released I_Customer with search annotations and a text element, then point the projection field to it with @Consumption.valueHelpDefinition. The service exposes the value-help view automatically. For few fixed values I use a dropdown (@ObjectModel.resultSet.sizeCategory: #XS).

Q6. Does a projection inherit the access control of its base view?

No. Every CDS view entity with #CHECK needs its own role. For a projection I write grant select on ZC_SalesOrder where inheriting conditions from entity ZR_SalesOrder, so the rules are maintained once in the base role.

Q7. OData V2 or V4 for a new RAP app?

V4 – it is SAP's recommendation for new transactional apps and supports draft, side effects and newer Fiori elements features fully. V2 only when a consumer cannot speak V4.

Q8. The preview returns 403 or an empty list. What do you check?

403: the user's role lacks the service – S_SERVICE in PFCG on-premise, or the service is not in an IAM app / business role in the cloud; /IWFND/ERROR_LOG helps on-premise. Empty list: first whether the tables contain data, then the access control – the user may have no authorization value for the orders' sales organisation.

Q9. How do you get from the ADT preview to a launchpad tile?

Generate a Fiori elements List Report in Business Application Studio or VS Code from the published UI service, test it with npm start, deploy it as a BSP application, then add launchpad content and a PFCG role on-premise, or an IAM app in a business catalog and business role in ABAP Cloud.

🏠 Start Here · ◀ 02 · Data Model & CDS · 04 · BDEF & Behavior Pool ▶ · Sections: CORE ABAP | OOPS ABAP | ABAP on HANA | Clean Core | RAP | ABAP Points | SAP Fiori | SAPUI5 | Mobile Development (MDK) | BTP Foundations | BTP Development | CAP | SAP Build | ABAP on BTP | Integration Suite | SAP Business AI | SAP BASIS | Security | SAP SDLC

Functional: FICO ABAP | TRM ABAP | VIM | SAP BIS | SD ABAP | MM ABAP | PP ABAP | QM ABAP | PM ABAP | PS ABAP | EWM | TM ABAP | EHS ABAP | HR ABAP | BW | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP