ABAP RAP

Read-Only Scenarios

Scope

This slide set covers read-only database access: apps intended for display only.

You will learn core concepts and workflows here:

  • Creating CDS views
  • Creating service definitions and bindings
  • Testing the app as a local service
  • Presentation as:
    • List
    • Details
    • With child / associated objects
  • Search fields
  • Value helps (value lists)

Steps for Read-Only applications

  • Create CDS view
  • Create Service Definition
  • Create Service Binding

Nothing else — simple but effective.

Annotations (CDS Views)

Annotation overview

Annotation

Annotations control UI rendering and some behaviors. They can be in CDS views or separate annotation files.

List display (List Report Annotations)

Use @UI.lineItem on fields to show them as table columns.

@UI.lineItem:       [ { position: 30, label: 'Lastname' } ]

Object Page Annotations

Use @UI.facet to define sections and @UI.identification / @UI.lineItem for field placement.

Use two annotations to provide content for the details view:

UI.FACET - define areas for fields


      @UI.facet: [  { id: 'User',
                      purpose:  #STANDARD,
                      type:     #IDENTIFICATION_REFERENCE,
                      label:    'User',
                      position: 10 }  ]

Field level - assign field to a facet


      @UI.lineItem:      [ { position: 10 } ] 
      @UI.identification:[ { position: 10, 
                             label: 'User ID' } ] 
  key user_id       as UserId,

Object Page

Demo and Exercise

Exercise 1

If the UI doesn't update...

Sometimes the UI does not reflect your annotations even though they are correct. This is usually caused by caching or missing activation.

Steps to troubleshoot

  • Check that all objects are activated
  • Verify that references between objects are correct
  • Are all required views exposed in the service definition?
  • Reload the browser with Ctrl+F5
  • Clear backend caches using the following transactions:
    • /n/IWFND/CACHE_CLEANUP
    • /n/IWBEP/CACHE_CLEANUP
  • Unpublish and re-publish the Service Binding
  • As a fallback, create a local binding in $tmp and test there

Search fields

In the List Report you can define filter/search fields. Add the annotation on the CDS field. Additional annotations such as label are optional.

Search fields

required annotation

@UI.selectionField: [{ position: 10 }]

Fuzzy search / global search field (1/3)

You can implement a general fuzzy search (aka Google search field) that searches all annotated columns. This is often more convenient because:

  • Only one input field is needed
  • Several columns are searched at once
  • Different fuzziness per column is possible

Preview Search-Field

Fuzzy search (2/3)

How to enable

On the view level add:
@Search.searchable: true

For each searchable field add a field-level annotation like:

      @Search: { defaultSearchElement: true,
                 fuzzinessThreshold: 0.7,
                 ranking: #LOW }

SAP recommends starting with a threshold of 0.7.

Result relevance

Use @Search.ranking: #LOW //#MEDIUM #HIGH to influence relevance ranking of matches.

SAP documentation

Fuzzy search (3/3)

Associated fields

Fuzzy search can include fields from associated views. To do that:

  • Mark the association in the projection
  • Mark fields in the associated view using the search annotation

Example association marker:
@Search.defaultSearchElement: true

General field annotations

These annotations can be used in several places (e.g. @UI.lineItem, @UI.fieldGroup, @UI.identification):

  • hidden - field is not shown and cannot be added by personalization
  • position - determines order of fields in a facet/table
  • label - field label
  • qualifier - links to a targetQualifier of a facet for different presentations

Metadata Extension (MDE)

  • Definition: Metadata Extensions are artifacts used to attach additional annotations to existing CDS views. They let you separate standard definitions from customer-specific UI annotations and adjustments.
    • Support modular and flexible development.
  • Use cases:
    • Add UI, OData or behavior annotations to CDS views
    • Customer-specific customizations without modifying the base CDS

Prerequisites

  • The annotation @Metadata.layer: #CUSTOMER should be present in the MDE
  • The annotation @Metadata.allowExtensions: true must be set in the CDS view
@Metadata.allowExtensions: true
define view entity zi_jb1_users
  as select from zbc_users

UI features - lists of child objects

Prerequisites:

  • View defined
  • Fields configured for the list view
  • View exposed in the service definition
  • Behaviour configured accordingly