Skip to Content
0
Jan 23, 2020 at 04:39 PM

ABAP in SCP, CDS Views, Generate Navigation Property/Association in Service Binding

1887 Views

Hello Community, Hello Experts.

I am following the ABAP RESTful Programming Model to create a simple relationship between two entities.

I am using the following document (https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/ffef7e02127e442793f24e3dc902c824.html) under the Develop > Managed Transactional Scenario.

In previous technologies, this is capable within SEGW of SAP Gateway or within ABAP CDS on Premise via the @ObjectModel annotations. In ABAP in SCP, I have created two CDS views similarly to how it's done on Premise, but now using Composition of in the Parent CDS view and Association To Parent in the Child CDS View. At the point of Service Definition and Service Binding, I am not seeing the Associations (to_Child) generated - which will be needed for the UX Requirements we have.

I will attach the steps for review:

Parent Table:

@EndUserText.label : 'SDR Entries'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #LIMITED
define table zsdr_entry {
  key client : abap.clnt not null;
  key ricefw : zricefw not null;
  exttype    : abap.char(10) not null;
}

Child Table:

@EndUserText.label : 'SDR Environments'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #LIMITED
define table zsdr_env {
  key client : abap.clnt not null;
  @AbapCatalog.foreignKey.screenCheck : false
  key ricefw : zricefw not null
    with foreign key [0..*,1] zsdr_entry
      where ricefw = zsdr_env.ricefw;
  key envid  : abap.char(3) not null;
  envirn     : abap.char(20);
}
zricefw predefined type CHAR LENGTH 11

Parent Interface CDS View

@AbapCatalog.sqlViewName: 'ZSDRIENTRY'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Interface for SDR Entries'
define root view ZSDR_I_ENTRY 
  as select from zsdr_entry
    composition [0..*] of ZSDR_I_ENV as _Environment {
      key ricefw,
      exttype,
      /* Associations */
      _Environment
}

Child Interface CDS View

@AbapCatalog.sqlViewName: 'ZSDRIENV'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Interface for SDR Environments'
define view ZSDR_I_ENV 
  as select from zsdr_env
    association to parent ZSDR_I_ENTRY as _Entry on  $projection.ricefw = _Entry.ricefw {
      key ricefw,
      key envid,
      envirn,
      /* Associations */
      _Entry
}

Parent Consumption CDS View

@EndUserText.label: 'Consumption for SDR Entries'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define root view entity ZSDR_C_ENTRY
  as projection on ZSDR_I_ENTRY {
    key ricefw as RicefwId,
    exttype    as ExtType,
    /* Associations */
    _Environment
}

Child Consumption CDS View

@EndUserText.label: 'Consumption for SDR Environments'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity ZSDR_C_ENV
  as projection on ZSDR_I_ENV {
    key ricefw as RicefwId,
    key envid  as EnvId,
    envirn     as Environment,
    /* Associations */
    _Entry
}

Service Definition:

@EndUserText.label: 'Service Definition PoC'
define service ZSDR_POC {
  expose ZSDR_C_ENTRY as Entry;
  expose ZSDR_C_ENV as Environment;
}

Service Binding:

Entities from Service Metadata: Some Information removed for brevity.

<edmx:DataServices m:DataServiceVersion="2.0">
  <Schema Namespace="cds_zsdr_poc" xml:lang="en" sap:schema-version="1" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
    <EntityType Name="EntryType" sap:label="Consumption for SDR Entries" sap:content-version="1">
      <Key>
        <PropertyRef Name="RicefwId" />
      </Key>
      <Property Name="RicefwId" Type="Edm.String" Nullable="false" MaxLength="11" sap:label="" sap:quickinfo="RICEFW Data Element" />
      <Property Name="ExtType" Type="Edm.String" MaxLength="10" />
    </EntityType>
    <EntityType Name="EnvironmentType" sap:label="Consumption for SDR Environments" sap:content-version="1">
      <Key>
        <PropertyRef Name="RicefwId" />
        <PropertyRef Name="EnvId" />
      </Key>
      <Property Name="RicefwId" Type="Edm.String" Nullable="false" MaxLength="11" sap:label="" sap:quickinfo="RICEFW Data Element" />
      <Property Name="EnvId" Type="Edm.String" Nullable="false" MaxLength="3" />
      <Property Name="Environment" Type="Edm.String" MaxLength="20" />
    </EntityType>
    <EntityContainer Name="cds_zsdr_poc_Entities" m:IsDefaultEntityContainer="true" sap:message-scope-supported="true" sap:supported-formats="atom json xlsx">
      <EntitySet Name="Entry" EntityType="cds_zsdr_poc.EntryType" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1" />
      <EntitySet Name="Environment" EntityType="cds_zsdr_poc.EnvironmentType" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1" />
    </EntityContainer>
    <atom:link rel="self" href="https://6f32772b-e4e0-492e-848f-7eb7eea6ac9f.abap-web.us10.hana.ondemand.com:443/sap/opu/odata/sap/ZSDR_POC/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />
    <atom:link rel="latest-version" href="https://6f32772b-e4e0-492e-848f-7eb7eea6ac9f.abap-web.us10.hana.ondemand.com:443/sap/opu/odata/sap/ZSDR_POC/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />
  </Schema>
</edmx:DataServices>

Please ask questions in case of further clarity required.

Please note there are no syntax errors at this time and all objects are activated. The part that has not yet started is the behavioral definition / implementation.

I appreciate your assistance! Thank you for your time.

Attachments

capture.png (14.9 kB)