2

I'm using @sap/cloud-sdk-generator 1.6.1 to generate a VDM (YY1_SALESDOCUMENT_CDS), translating it to CSN using edmx2csn to then use it in a .CDS file to exposed as OData service (named CustomSales).

The goal is to enhance the original YY1_SALESDOCUMENT_CDS with an extra field 'foobar', which works as expected. But it has a draw back: CustomSales does not contains the metadata's sap:* attributes, like 'sap:label', that YY1_SALESDOCUMENT_CDS has.

My custom-sales.CDS service file:

using YY1_SALESDOCUMENT_CDS as sales from '../src/external/csn/YY1_SalesDocument.json';

service CustomSales {

    @cds.persistence.skip
    entity SalesDocument as projection on sales.YY1_SalesDocumentType {
        *
    } excluding {to_Item}

    extend entity sales.YY1_SalesDocumentType with {
        foobar: String(25) ;

        toItem : Association to many SalesDocumentItem
            on toItem.SalesDocument = SalesDocument ;
    }
}

YY1_SALESDOCUMENT_CDS Service's metadata:

 <EntityType Name="YY1_SalesDocumentType" sap:label="Sales Document" sap:content-version="1">
                <Key>
                    <PropertyRef Name="SalesDocument"/>
                </Key>
                <Property Name="SalesDocument" Type="Edm.String" Nullable="false" MaxLength="10" sap:display-format="UpperCase" sap:required-in-filter="false" sap:label="Sales Document"/>
                <NavigationProperty Name="to_Item"/>
</EntityType>

CustomSales Service's metadata:

<EntityType Name="SalesDocument">
                <Key>
                    <PropertyRef Name="SalesDocument"/>
                </Key>
                <Property Name="SalesDocument" Type="Edm.String" MaxLength="10" Nullable="false"/>
                <Property Name="foobar" Type="Edm.String" MaxLength="25"/>
                <NavigationProperty Name="toItem" Type="Collection(CustomSales.SalesDocumentItem)"/>
</EntityType>

I expected all attributes from YY1_SALESDOCUMENT_CDS service to be copied over CustomSales, but that's not the case.

Is there a way to generate OData service from an existing service and also copy it's metadata attributes ?

It's worth mentioning that I'm using JS/TS as handler to custom logic, using the Cloud SDK for JS to call the original backend service.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
  • Hi Ulysses! Just for my understanding, do you get the CustomSales service's metadata from `host/path/CustomSales/$metadata`? If not, where does the metadata for CustomSales come from? – Dennis H Jul 26 '19 at 09:28
  • Hi Dennis, yes, it does come from host/CustomSales/$metadata – Ulysses Bonfim Jul 28 '19 at 05:51
  • Hi Ulysses, totally forgot to get back to you, super sorry for that. The issue your facing is not related to the SAP Cloud SDK but to CAP/CDS, so I cannot help you myself, but I have forwarded it to the corresponding colleagues. – Dennis H Aug 05 '19 at 07:09
  • Thanks Dennis. Is any other tag that I could have use to directly post them? – Ulysses Bonfim Aug 06 '19 at 08:12
  • I think there's no explicit tag for the Cloud Application Programming Model (CAP)... You could try using the tags `sap` and `cds`, but CDS is quite the overloaded term, so I'm not sure who's monitoring that tag. – Dennis H Aug 06 '19 at 10:51

0 Answers0