CDS

Extending CDS View

Extending a CDS View is a tool that can be utilized when editing the original CDS view is not possible – either because of dependency or if it is SAP standard one. Either way, it is quite simple. Here is an example.

Original CDS View

@AbapCatalog.sqlViewName: 'ZFIRSTCDS'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Material Data'

define view zfirstcds_mara as select from mara {
        key matnr as Material,
            
            mtart as MaterialType,
            meins as Uom
        
}

CDS Extension

@AbapCatalog.sqlViewAppendName: 'ZFIRSTCDSE'
@EndUserText.label: 'Extending a CDS View'
extend view zfirstcds_mara with z000_Extend_zfirstcds_mara {
    ersda as creationdate,
    ernam as createdby
}

Note: You need to provide the SQL view append structure in the annotation and instead of “define” you use the syntax “extend”.

Now if you run the original CDS view, you can see the additional columns.

The cool thing about extensions is that you can add as many extensions as you like. Just like append structure.

When a CDS is run, all its extension triggers so be careful – how you use it.

If you like our content, hit us a like on our Linkedin page and bookmark our blog.

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share