Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Association in CDS View Extension is not exposed in the OData of main CDS View

ji-cepeda
Member
0 Kudos
3,839
  • SAP Managed Tags:

Hi over there.

I've created, via Eclipse ADT, a CDS extension view for the standard CDS C_SALESORDERITEMFS. I've put two associations; I've used individual fields in the selection list from one of those associations, and I've added the second association directly in the selection list. As below:

Well then, the C_SALESORDERITEMFS standard CDS View is exposed as an EntitySet of the standard OData service SD_F1814_SO_FS_SRV. And while the individual fields from _ZV01 association that I've added are visible in each individual record from C_SALESORDERITEMFS EntitySet...

...the _zv01Tabla association is not, and is neither on the Metadata of the OData (in the first screenshot the new association should appear after the to_TransactionCurrency one):

However, if I run the C_SALESORDERITEMFS View in Eclipse and use the Follow Association Command, I can see the original standard association as well as the new one added by me:

Why is this happening? Is it possible to expose/use the association as itself in the standard CDS OData?

6 REPLIES 6

2,718
  • SAP Managed Tags:

Hi,

I had the same question before.

I could solve the issue by exposing the association target (in your case zv01) in the Service Definition. OData will only expose the association in its metadata, if the target is also exposed. Otherwise, the target cannot be accessed and thus the association would be useless. Consequently, the association is not shown in OData.

In your case, zv01 seems to be a table, but tables cannot be exposed in Service Definitions. So you would need to introduce a Data Definition as a layer between the database table and the Service Definition. Additionally, it seems you are working with an SAP Service Definition. Consequently, you would need to extend the service:

https://help.sap.com/docs/btp/sap-abap-restful-application-programming-model/including-extension-nod...

Alternatively, if you just want to expose one simple field (without exposing an entity), try to include the field explicitly.
In your case
_zv01.posnr as YourAliasForThisField

This should directly include the field via OData with no need to modify (extend) the Service Definition.

All in all, it depends on your requirement. If you really need to full association for navigation in OData, you will need to include the target in the Service Definition. Otherwise, you may try to include individual fields directly.

I hope I could help you with this suggestion.

Best,
Nikolas

0 Kudos
2,718
  • SAP Managed Tags:

Hi Nikolas, what would you suggest when we are not in Service Definition case, but in old SEGW world? How one can extend standard oData service with association target? Appreciate any hints.

0 Kudos
2,718
  • SAP Managed Tags:

Hi Pavel,

sorry, I do not know an answer for your question regarding the SEGW use case. Maybe you can post your question as an independent question to reach more experts.

Best, Nikolas

0 Kudos
2,718
  • SAP Managed Tags:

nikolas.dimitriadis / pavel.veremenyuk - Have you found any solution for SEGW case?

2,718
  • SAP Managed Tags:

The described solution helped me to access association targets exposed in the OData service via Service Definition and Service Binding (and not via SEGW).

0 Kudos
165
  • SAP Managed Tags:

Hi Nikolas,

Can you explain how you have exposed association targets  in the OData service. I have a similar case where I extended a Standard CDS view to add new Virtual column that is calculated in frontend. But here I need to implement filteration for that field. 

To implement filter I followed the way described in below blog but I am getting that association not defined error. 

https://community.sap.com/t5/technology-blogs-by-members/filtering-on-association-property-in-fiori-...