Show TOC

Creating an Appropriate CDS View ExtensionLocate this document in the navigation structure

Prerequisites

  • You need the standard developer authorization profile to create ABAP development objects with ABAP Development Tools.
  • You identified the data definition that implements the original CDS-based data model you are going to extend.

Context

Starting Point

Let us assume you - as an SAP customer – are accessing our own Fiori Launchpad where you open a list reporting app displaying all parties that are relevant for your business activities.

However, in your business context you may require some further details that were not foreseen by the application’s UI delivered by SAP. For example, you would like to display the role (supplier, customer, partner, and so on) or the contact details for each organization displayed in the list. In other words: You would like to provide additional fields in the given business application context that is represented by the UI actually used.

Actually used UI – an example
Figure 1: Actually used UI – an example

Let us also assume you have identified the development object (data definition) that implements the original data model for Party Address Data - as shown in the listing below.


  @AbapCatalog.sqlViewName: 'SQL_PARTY_ORIG'
  @AbapCatalog.compiler.compareFilter: true
  @AccessControl.authorizationCheck: #NOT_REQUIRED
  @EndUserText.label: 'Party Address Data'
					
  @Search.searchable: true
					
  @OData.publish: true
					
  define view DEMO_PARTY_ORIG
		as select from SEPM_I_Party_E as Organization
  {
		@UI.lineItem: { importance: #HIGH, label: 'Org ID', position: 10 }
		key   Organization.Party                as OrgID,
					
		@Search.defaultSearchElement: true
		@UI.lineItem: { importance: #HIGH, label: 'Organization', position: 20 }
		Organization.PartyName            as OrgName,
					
		@UI.selectionField.position: 10
		@Search.defaultSearchElement: true
		@Search.fuzzinessThreshold: 0.5     
					
		@UI.lineItem: { label: 'Location', position: 30 }
		Organization.CityName             as City
  }
					
				

The original source code defines quite a simple data model based on the CDS view called DEMO_PARTY_ORIG. This view is implemented by means of a query for performing a SELECT statement, where the predefined CDS view (that originates from the EPM demo application) SEPM_I_Party_E is used as the data source. The select list includes a rather small set of fields for the ID, name, and location of the parties. In addition to the original CDS view, the SQL view (database view) SQL_PARTY_ORIG has also been created in the ABAP Dictionary.

Procedure

To create a data definition for extending a CDS view, proceed as follows:

  1. Launch the ABAP Development Tools.
  2. In your ABAP project, select the relevant package node in the Project Explorer.
  3. Open the context menu and choose Start of the navigation path New Next navigation step Other ABAP Repository Object Next navigation step Core Data Services Next navigation step Data Definition End of the navigation path to launch the creation wizard.
  4. In addition to the Project and Package, enter the Name (with due regard to your namespace) and the Description for the extension to be implemented. Choose Next.
  5. Assign a transport request and choose Next.
  6. Select the Extend View template to speed up the extension definition.
    Selecting a suited template for extending a view
    Figure 2: Selecting a suited template for extending a view
  7. Choose Finish.

Results

In the selected package, the ABAP back-end system creates an inactive version of a data definition for the extension and stores it in the ABAP Repository. The generated source code is automatically displayed in the DDL editor and already provides you with the necessary view annotations and adds placeholders for names of the append view, the original CDS view, and for the actual view extension.
The generated template code in the DDL editor
Figure 3: The generated template code in the DDL editor

Next Steps

If you have not yet already done so, open the newly created data definition and specify the names of the...

  • Append view to be generated in the ABAP Dictionary, for example: ZSQL_PARTY_EXT
  • Original CDS view: DEMO_PARTY_ORIG (in our example)
  • Actual view extension, for example: ZDEMO_PARTY_EXT.