Skip to Content
May 01, 2018 at 02:18 AM

CDS Key is GENERATED_ID instead of key specified


I am using Fiori List Report Template. Many views involved, but the issue is with the top level TOTALS View ZDDL_FI_C_OPEX.

I have defined the KEY to that view as: KEY: GJAHR + MONAT + KOSTL + HKONT

This view has an association to drill down into the docs that make up that Total (KEY: GJAHR+BUKRS+BELNR+BUZEI)

However CDS View below is creating a GENERATED_ID as the KEY to the Totals view, which breaks the drill down into _items.

Anyone have an idea on how to handle this?



CDS Top View

@AbapCatalog.sqlViewName: 'ZSQL_FI_C_OPEX'
@AbapCatalog.compiler.compareFilter: false
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Opex Cost Center Consumption'
@AbapCatalog.preserveKey: true
@Metadata.ignorePropagatedAnnotations: true
@ClientDependent: true

@OData.publish: true

define view ZDDL_FI_C_OPEX
as select from ZDDL_FI_B_OPEX_T                      
          association[0..*] to ZDDL_FI_B_PER    as _line
            on  $projection.gjahr = _line.gjahr
            and $projection.monat = _line.monat
            and $projection.kostl = _line.kostl                           
            and $projection.hkont = _line.hkont       
   @UI.selectionField.position: 10  
  @Semantics.fiscal.year: true  
  key gjahr as gjahr,                        
  @UI.selectionField.position: 20  
  key monat as monat,                         
  @UI.lineItem.position: 30  
  key kostl as kostl,   
  @UI.lineItem.position: 40                          
  key hkont as hkont,                         

  @UI.lineItem.position: 50 
  @Semantics.currencyCode: true
  hwae2 as hwae2,                             
  @UI.lineItem.position: 60 
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'hwae2'  
  tot   as tot,                                
  @UI.lineItem.position: 70
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'hwae2'   
  ytd   as ytd,                                

$Metadata (Generated_ID as the key to ZDDL_FI_C_OPEXTypeis the problem


-<EntityType sap:content-version="1" sap:label="Period Totals" Name="ZDDL_FI_B_PERType">

<PropertyRef Name="bukrs"/>
<PropertyRef Name="belnr"/>
<PropertyRef Name="gjahr"/>
<PropertyRef Name="buzei"/>
-<EntityType sap:content-version="1" sap:label="Opex Cost Center Consumption" Name="ZDDL_FI_C_OPEXType" sap:semantics="aggregate">
<PropertyRef Name="ID"/>
<Property Name="ID" Nullable="false" Type="Edm.String"/>
<Property sap:label="Fiscal Year" Name="gjahr" sap:display-format="NonNegative" MaxLength="4" Type="Edm.String" sap:aggregation-role="dimension"/>
<Property sap:label="Posting period" Name="monat" sap:display-format="NonNegative" MaxLength="2" Type="Edm.String" sap:aggregation-role="dimension"/>
<Property sap:label="Cost Center" Name="kostl" sap:display-format="UpperCase" MaxLength="10" Type="Edm.String" sap:aggregation-role="dimension"/>
<Property sap:label="G/L Account" Name="hkont" sap:display-format="UpperCase" MaxLength="10" Type="Edm.String" sap:aggregation-role="dimension"/>
<Property sap:label="Local currency 2" Name="hwae2" MaxLength="5" Type="Edm.String" sap:semantics="currency-code" sap:aggregation-role="dimension"/>
<Property Name="tot" Type="Edm.Decimal" sap:unit="hwae2" Scale="3" Precision="22" sap:aggregation-role="measure" sap:filterable="false"/>
<Property Name="ytd" Type="Edm.Decimal" sap:unit="hwae2" Scale="3" Precision="19" sap:aggregation-role="measure" sap:filterable="false"/>
<NavigationProperty Name="to_line" ToRole="ToRole_assoc_3F7CDE5901750F45D612B21666430E21" FromRole="FromRole_assoc_3F7CDE5901750F45D612B21666430E21" Relationship="ZDDL_FI_C_OPEX_CDS.assoc_3F7CDE5901750F45D612B21666430E21"/>