Rule Definition
Defines the name _assoc of an association defined using ASSOCIATION of a CDS view. If no name is defined explicitly using AS, _assoc is set implicitly to the name of the target data source.
Association names should start with _.
Remediation
Association name should start with _.
Violation Code Sample
buyer name does not start with "_"
----------------------------------
define view sales_order_invoice_header as
select from snwd_so_inv_head
association [1..1] to snwd_bpa as buyer
on $projection.buyer_guid = buyer.node_key
{ key snwd_so_inv_head.node_key, //used in assoc _invoice_items
snwd_so_inv_head.buyer_guid, //used in assoc _buyer
buyer.bp_id as buyer_id, //from assoc _buyer
snwd_so_inv_head.payment_status,
@Semantics.currencyCode
snwd_so_inv_head.currency_code,
@Semantics.amount.currencyCode: 'currency_code'
snwd_so_inv_head.gross_amount
}
where buyer.bp_role = '001';buyer name does not start with "_"
----------------------------------
Association has no name
----------------------------------
define view sales_order_invoice_header as
select from snwd_so_inv_head
association [1..1] to snwd_bpa
on $projection.buyer_guid = buyer.node_key
{ key snwd_so_inv_head.node_key, //used in assoc _invoice_items
snwd_so_inv_head.buyer_guid, //used in assoc _buyer
buyer.bp_id as buyer_id, //from assoc _buyer
snwd_so_inv_head.payment_status,
@Semantics.currencyCode
snwd_so_inv_head.currency_code,
@Semantics.amount.currencyCode: 'currency_code'
snwd_so_inv_head.gross_amount
}
Fixed Code Sample
define view sales_order_invoice_header as
select from snwd_so_inv_head
association [1..1] to snwd_bpa as _buyer
on $projection.buyer_guid = _buyer.node_key
association [1..*] to snwd_so_inv_item as _invoice_items
on $projection.node_key = _invoice_items.parent_key
{ key snwd_so_inv_head.node_key, //used in assoc _invoice_items
snwd_so_inv_head.buyer_guid, //used in assoc _buyer
_buyer.bp_id as buyer_id, //from assoc _buyer
snwd_so_inv_head.payment_status,
@Semantics.currencyCode
snwd_so_inv_head.currency_code,
@Semantics.amount.currencyCode: 'currency_code'
snwd_so_inv_head.gross_amount,
_invoice_items //publish assoc _invoice_items
}
where _buyer.bp_role = '001'; //usage of assoc buyer
Reference
https://blogs.sap.com/2019/10/09/abap-cds-views-development-guidelines-and-naming-conventions/
https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_association.htm
Related Technologies
Technical Criterion
Documentation - Naming Convention Conformity
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.