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: 

CDS annotation to calculate projection view virtual element

0 Kudos

hi,

can you help me with the annotations on my projection view, as i would like to calculate the flight date via IF_SADL_EXIT_CALC_ELEMENT_READ (Class name is ZAMDP_FLIGHT)

i'm just trying with this exercise but can't seem to activate it due to an error - "Basis entity must have a ROOT property or a TO PARENT association"

https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/df0ef4aac2d34fdd948b8a8883d...

4 REPLIES 4

maheshpalavalli
Active Contributor
0 Kudos

Are you trying to do it using restful abap programming model or abap programming for fiori?

geert-janklaps
Active Contributor
0 Kudos

Hi,

I'm not really sure if you can use the @ObjectModel.CompositionRoot as you are doing in zddl_next_flight. Looking at the documentation I would expect only true or false is possible.

You can also have a look at following example, which uses a root and child entity.

https://blogs.sap.com/2019/03/11/creating-a-draft-enabled-sales-order-fiori-app-using-the-new-abap-p...

Best regards,

Geert-Jan Klaps

The example shows the correct modelling with the associations towards child, parent and root and the usage of annotation @ObjectModel.association type. However these are important for transactional processing... virtual elements are quite independent of it, for them you do not necessarily need these annotations.

gasparerdelyi
Active Participant
0 Kudos

With respect to filter transformation, there is an example on the blog post https://blogs.sap.com/2020/01/16/filtering-on-association-property-in-fiori-element-app-via-abap-cds...

With respect to the calculation exit, there are two ways to code:

  • either you need to take care of reading the data in the CALCULATE method itself. In that case you even need no association for the sake of virtual element calculation
  • or you need to take out the necessary fields from the association into your projection list as in IF_SADL_EXIT_CALC_ELEMENT_READ~GET_CALCULATION_INFO you can only specify fields of your CDS view, not a field of an association. SADL can only warrant to read the input for your calculation as long as they are coming from an element from your CDS view directly.