cancel
Showing results for 
Search instead for 
Did you mean: 

Define bound actions as an aspect?

gregorw
Active Contributor

Hello CAP Team,

when looking at the documentation regarding Aspects:

https://cap.cloud.sap/docs/guides/domain-models#aspects
https://cap.cloud.sap/docs/cds/cdl#aspects

I don't find any information how I could define a bound action in an aspect. Is it correct to say that aspects are only intended for the data model but not for the service layer? What option do I have to define a reusable action?

Best Regards
Gregor

View Entire Topic
andre96
Advisor
Advisor

Hi,

you can use actions on aspects similar to entities, e.g.:

aspect A {} actions { action A(); }

You can then re-use this aspect via the include-mechanism. Though its main use may be to have re-usable elements, you can define aspects that only have actions or annotations as well. Aspects without elements can even be use to extend projections (in more recent cds-compiler versions), e.g.

aspect A {} actions { action A(); }

entity E { key id : String; };
entity P as projection on E;
extend P with A;

Kind regards,

Andre

gregorw
Active Contributor
0 Kudos

Hi Andre,

thank you for the quick and helpful response. Maybe this can be added to capire by rene.jeglinsky?

Best Regards
Gregor

andre96
Advisor
Advisor
0 Kudos

Hi Gregor, I've added an internal backlog item to keep track of it. 🙂