cancel
Showing results for 
Search instead for 
Did you mean: 

Computed fields in CAP

sergei-u-niq
Active Contributor

I think, I have seen this question before, but just cant find the answer.

What I'd like is an after-read method that computes a value for a field. I can easily place it in after-read of that entity in the service implementation. that works for service calls like

/EntityWithComputedProp

What I would like, though, is a method that will be executed regardless of how the service was called, e.g.

/SomeOtherEntity?$expand=EntityWithComputedProp

If I recall correctly, there is a way to do that. (except placing similar code in after-read of SomeOtherEntity)

Thanks, Sergei

Accepted Solutions (0)

Answers (2)

Answers (2)

vobu
Active Contributor
0 Kudos
gregorw
Active Contributor
0 Kudos

Please check if this approach helps: https://answers.sap.com/comments/13324496/view.html

sergei-u-niq
Active Contributor
0 Kudos

Actually, I was hoping to avoid exactly that. Sure I would extract the actual code to a method, but having a lot of associations to that entity from various places, I would need to call that everywhere.

I think, there was a post (cant find it) pointing out how to add an after-read handler of the DB entity rather than an after-read of the Service-Entity...