Show TOC

Implementing a Service-Specific Consumption View Locate this document in the navigation structure

Based on the Sales Order BO view, we are now going to implement the data model for consumption with the help of the consumption view.

Consumption View

The ObjectModel annotations that are used in the consumption view provide transactional related aspects of the business data model.

The annotations (required) for each root entity are:

Annotation and Values


@ObjectModel.transactionalProcessingDelegated: true

Indicates that transactional access to the consumption view is delegated to the transactional runtime of the underlying view (which is annotated with @ObjectModel.transactionalProcessingEnabled: true).

In addition, the following annotations are required for all editable entities (including the root entity):

Annotation and Values


@ObjectModel.createEnabled: true

Allows the end user to create new business object instances

@ObjectModel.deleteEnabled: true

Allows the end user to delete business object instances

@ObjectModel.updateEnabled: true

Allows the end user to update existing business object instances

More on this: ObjectModel Annotations

Remember CDS rule: Remember to double-maintain the annotations that have the VIEW scope. In CDS views, only the annotations with ELEMENT and ASSIOCIATION scope are inherited from the business object view.
For our Sales Order scenario, we assume that...
  • The DDL-based data definition, as the corresponding development object, is already created. In our case, the DDL data definition and the CDS view are named ZDEMO_C_SALESORDER_TX and ZDEMO_C_SalesOrder_TX respectively.

  • The business object CDS view that you implemented in the previous step serves as the data source for the consumption view.

  • The key in the data model in the consumption view corresponds to the primary key of the underlying database table.

Implementing the Data Model for Consumption

In this implementation, the business object view is the data source of the consumption view ZDEMO_C_SalesOrder_TX. The @ObjectModel.transactionalProcessingDelegated: true annotation indicates that transaction requests to the consumption view are delegated to the underlying business object view.

To expose the data model and its metadata to the OData service, the consumption view is annotated with @OData.publish: true.

The SELECT list includes a set of fields that are relevant for consumption in a user interface (UI). The key is specified as a semantic key SalesOrder. This is implemented by the annotation @ObjectModel.semanticKey: 'SalesOrder'.

  @AbapCatalog.sqlViewName: 'ZDEMO_C_SO'
  @AccessControl.authorizationCheck: #NOT_REQUIRED
  @EndUserText.label: 'Sales Order for transactional app'
  @ObjectModel.semanticKey: 'SalesOrder'
  @ObjectModel.transactionalProcessingDelegated: true
  @ObjectModel.createEnabled: true
  @ObjectModel.deleteEnabled: true
  @ObjectModel.updateEnabled: true
  @UI.headerInfo: { typeName: 'Sales Order', typeNamePlural: 'Sales Orders' }
  @OData.publish: true
  define view ZDEMO_C_SalesOrder_TX
		as select from ZDEMO_I_SalesOrder_TX as Document
		@UI.lineItem.position: 10
		@UI.identification.position: 10
		key Document.SalesOrder,
		@UI.lineItem.position: 20
		@UI.identification.position: 20
		@UI.lineItem.position: 50
		@UI.identification.position: 50
		@UI.lineItem.position: 60
		@UI.identification.position: 60
		@UI.lineItem.position: 30
		@UI.selectionField.position: 30
		@UI.identification.position: 30
		@UI.lineItem.position: 40
		@UI.selectionField.position: 40
		@UI.identification.position: 40
		/* Exposing value via associations */ 
		@UI.lineItem:  { value: '.CompanyName', position: 15 }
Activating the Data Definition of Consumption View

After successful activation of the corresponding data definition development object, the ABAP Development Tools generates several SAP Gateway artifacts that are stored in the back end of the application server AS ABAP and are required for OData service activation in the SAP Gateway hub. These artifacts include:

  • The actual service artifact with the technical name <CDS_VIEW>_CDS. You can find it at SAP Gateway Business Suite Enablement - Service object (object type: R3TR IWSV).
  • An SAP Gateway model (object type: R3TR IWMO) with the name <CDS_VIEW>_CDS.
  • An ABAP class ZCL_<CDS_VIEW> (in case of local objects) or <Namespace>CL_<CDS_VIEW> (other objects) that is used to provide model metadata to the SAP Gateway service.

All generated service artifacts are automatically added to the same ABAP package (and also to the same transport request) as the underlying consumption CDS view.

Activating the OData Service

To make your data model ready for consumption, you only have to activate the resulting OData service in the SAP Gateway hub.

More on this: Expose CDS View as an OData Service

Activated OData service is listed in the Service Catalog of the SAP Gateway
Figure 1: Activated OData service is listed in the Service Catalog of the SAP Gateway
Tip To verify that the activated OData service works correctly, you can test the service.

More on this: Test the Activated OData Service