2024 Jun 27 11:35 AM - edited 2024 Jun 27 11:36 AM
Hello everyone,
I'm working on consuming an existing on-premise OData service using CAP (Cloud Application Programming Model). The original service has an EntitySet called "AssetSet" with elements of type "Asset". The metadata looks something like this:
<EntitySet Name="AssetSet" EntityType="API.Asset"/>
I've imported the external service and defined in CAP as follows:
using { API } from './external/api';
extend service mirror_api {
entity Asset as projection on API.Asset;
}
This produces metadata that looks like:
<EntitySet Name="Asset" EntityType="mirror_api.Asset"/>
My goal is to maintain the original EntitySet name ("AssetSet") instead of the current output ("Asset"). The metadata would look just like it is in the on-premise system, with an “EntitySet” named “AssetSet” and an “EntityType” named “API.Asset”. Is there a way to achieve this within CDS?
I've searched the documentation but haven't found a clear solution. I know that this was not supported back in 2019 (when someone else asked about it here).
Any guidance would be greatly appreciated!
Best regards,
Rafael
Request clarification before answering.
This is the same answer I gave in the SAP Ticket system:
Dear Customer,
the importer will preserve the entity set name, not the type name, your example:
<edmx:DataServices>
<Schema Namespace="Asset" xmlns="...">
<EntityContainer Name="EntityContainer">
<EntitySet Name="AssetSet" EntityType="Asset.Asset"/>
</EntityContainer>
<EntityType Name="Asset">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.Int32" Nullable="false"/>
</EntityType>
</Schema>
</edmx:DataServices>
Recreate the CDL source from the imported API:
cds -2 cdl srv/external/asset.csn
@CDS.external : true
service asset {};
@CDS.external : true
@CDS.persistence.skip : true
entity asset.AssetSet {
key id : Integer not null;
};
you can directly refer to the entity name AssetSet.
However, if you want to expose an entity type that had no entity set in the imported service, you can rename it with your local service projection (like in your example):
extend service mirror_api {
entity AssetSet as projection on API.Asset;
}
CAP in general does not allow alternating names between EntityContainer entries and type definitions. Since in CAP CDS every service entity can become only one entity set, the names are the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @hjb,
Thank you for your reply! Like I mentioned there, I have an specific Fiori legacy application annotation that relies on different "EntityType" and "EntitySet" names. I'll have to work around this issue.
Your assistance is greatly appreciated.
Best regards,
Rafael
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.