‎2021 Apr 19 11:39 AM
I have a CDS view which will be exposed as an Odata service. There is one field in the CDS(FIO/LIO) which has a many to one relationship with the key field(object id). Now, there is no direct DB table(s) to select the details of FIO/LIO field. For one object id, we will get multiple number of FIO/LIO entries from a function module. Initially I planned to use CDS virtual elements, But CDS virtual element cannot be used for this scenario as we cannot add records to a calculated column of virtual element. We can recalculate them or replace their value but we cannot add multiple FIO/LIO against one object id in the virtual element method.
I need guidance on how to implement this solution in CDS where we expect multiple entries from FM against a single object id.
‎2021 Aug 24 3:50 PM
Hi Maloy,
it depends how you want to process / use the data.
If you want to get the relevant FIO/LIO details via the mentioned function module, I would recommend you to make use of CDS Custom Entities. By defining a CDS Custom Entity you have the possibility to reference an implementation exit for the data access.
A great tutorial can be found here:
https://developers.sap.com/tutorials/abap-environment-a4c-create-custom-entity.html
As soon as you have defined your CDS Custom Entity, you are able to associate this entity in a CDS Extension of the corresponding standard CDS View.
Simplified Example:
extend view <standard_view_to_be_extended> with <extend_name>
association [0..*] to <custom_entity> as _toCustomEntity
on _toCustomEntity.<key_field> = $projection.<foreign_key_field>
{
_toCustomEntity
}Depending on the service on top of the extended CDS View, the association is now available and can be used for further data selection.
Hope this helps!
Best regards,
Fabian Fellhauer