CDS View Day01
CDS View Day01
@AbapCatalog.sqlViewName: 'ZNOV_BASIC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'First CDS View'
define view ZNOV_BASIC_CDS as select from snwd_bpa {
node_key,
bp_role,
bp_id,
company_name
}
*&---------------------------------------------------------------------*
*& Report znov_consume_cds_abap
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT znov_consume_cds_abap.
cl_demo_output=>display_data(
EXPORTING
value = itab
* name = " Name
).
@AbapCatalog.sqlViewAppendName: 'ZNOV_EXTENDSQL'
@EndUserText.label: 'Extension of an CDS'
extend view ZNOV_BASIC_CDS with ZNOV_EXTEND {
email_address
}
@AbapCatalog.sqlViewName: 'ZNOV_CDS_INV'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Invoice header'
define view ZNOV_CDS_INV_DATA as select from snwd_so_inv_head as inv
inner join snwd_bpa as bpa on inv.buyer_guid = bpa.node_key
{
//snwd_so_inv_head
bpa.company_name,
sum(gross_amount) as total_inv_amount,
inv.currency_code
@AbapCatalog.sqlViewName: 'ZNOV_INV_ASSOC'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Association Example'
define view ZNOV_CDS_ASSOCIATION_INVOICE as select from snwd_so_inv_head as inv
association[1..1] to snwd_bpa as _Supplier
on inv.buyer_guid = _Supplier.node_key
{
key node_key,
buyer_guid,
gross_amount,
net_amount,
tax_amount,
--exposed association: when we directly assign the association name as column
in view
_Supplier,
--Adhoc association: Behaves like actual inner join
_Supplier.company_name
}