Show TOC

Adding Fields from Association Locate this document in the navigation structure

This topic demonstrates how you can extend the syntax of the CDS view with view extension to provide some additional custom fields that result from new associations defined in the extension code.

Creating a Second Extension

Create a data definition second as the second development object for extending the original CDS view DEMO_PARTY_ORIG and specify the names of the append view as ZSQL_PARTY_EXT2 and ZDEMO_PARTY_EXT2 for the new view extension. This association _PartyContact associates the original CDS view with the target data source SEPM_I_ContactPerson_E. The target is a predefined CDS view that originates from the EPM demo application you can use to provide contact data for the business partner. For representation of this contact data, we adopt only the field EmailAddress into the list of LineItems.

  @AbapCatalog.sqlViewAppendName: 'ZSQL_PARTY_EXT2'
  @EndUserText.label: 'Party Address Data Extended with Contact'

		association [1..1] to SEPM_I_ContactPerson_E as _PartyContact 
		on Organization.businesspartner = _PartyContact.businesspartner

		@UI.lineItem: { label: 'Contact - Email', position: 50 }


If you open the DDL editor with the original data definition, you will detect that (after a refresh) a new decorator indicates that extensions are available in the current system. If you move the cursor over the decorator, an info screen provides you with links to all existing view extensions. Prerequisites: both extension data definitions has been activated successfully in ABAP Development Tools.

Info screen after a successful activation of both extensions
Figure 1: Info screen after a successful activation of both extensions

If you now open the original database view in the ABAP Dictionary (in our example: SQL_PARTY_ORIG), you will see that all appends are included in the database view

Resulting database view includes all appends from extension
Figure 2: Resulting database view includes all appends from extension
Tip To verify the result set of the extended CDS view, you can utilize the Data Preview. More on this: Verify the Result Set in the Data Preview Tool