Register Login

Enhancing ABAP CDS View in a modification-free Manner on HANA

Updated May 18, 2018

This tutorial explains how to enhance ABAP Core Data Service View in a modification-free Manner and how to call the enhanced CDS view in open SQL using CDS view enhancements with SAP NetWeaver AS ABAP 7.4 SP08

The enhancement of ABAP CDS view has been provided by the ABAP Application Server 7.4  SP8. For example new building functions such as replace & division and special function for currency and unit conversions.

Modification-free enhancement of CDS views

The modification-free enhancement is necessary in order to avoid conflicts when an object is to be imported or a new release application.Now the develops can enhance the ABAP CDS view in a modification-free manner by using Core Data Service view
enhancement.

Creating CDS view enhancement to enhance existing CDS view

In this tutorial, we will Enhance already existing CDS view seen in the image

See How to build Core Data Services Views in ABAP

In order to enhance the CDS view we first have to create new DDL source object. You can also select extent view template in the new DDL source creation dialog box.

Now run the below program in order to create new CDS view enhancement

@AbapCatalog.sqlViewAppendName: 'ZV_EPM_OP_INV'
@EndUserText.label: 'CDS View Extension 01'
extend view demo_epm_openinv_v with zepm_ext_01_v
{
snwd_so_inv_head.gross_amount - snwd_so_inv_head.tax_amount as pre_tax_mount,
substring(snwd_bpa.company_name, 1, 5) as company,
1 + 1 as two,
snwd_so.so_id as order_id
}

Checking Enhanced CDS view Details

Now after activating the CDS enhancement a spiral icon will be see on CDS view which will indicate the number of enhancement exist for the CDS view.

We can display the element information popup of the enhanced view entity using the short-cut tool and see that the fields of view enhancement also listed as  a column.

Now switch to the detail view we will see result of the extension in view append

We can also see the field of CDS view extension displayed in data preview

Calling Enhanced CDS view in Open SQL

REPORT zr_display_data.

SELECT * FROM demo_epm_openinv_v //cds entity name required//
INTO TABLE @DATA (It_data).

cl_demo_output=>display_data(
EXPORTING
value = it_data
name = 'Demo: CDS View Enhancement' ).

Now activate and the run the report to see the result. All the column including those of the view enhancement can be seen

Note: Current view with explicit name list or the group for union clause with union sets cannot be enhanced.


×