Skip to Content

CDS View select statement to fetch and use Alias name for Calculation

Feb 25 at 05:11 AM


avatar image

Dear All,

I would like to know a possibility to fetch the calculated value(Alias Name - Ex: Proj_quan) in CDS view and use the value in the subsequent scenario.

{ ..... 
//Calculate Proj_quan 
_planned.menge1 + _planned.menge2 + _poquan.Menge as Proj_quan, 

//Calculate Difference Quantity 
(_planned.menge1 + _planned.menge2 + _poquan.Menge) - _delquan.Quantity as Diff_Quan, 

Instead of the above line calculation(Difference Quantity), would like to know the way to use the Proj_Quan(Alias name) variable in the next calculation as shown below

//Calculate Difference Quantity 
Proj_Quan - _delquan.Quantity as Diff_Quan, 

$PROJECTION is not working inside select statement calculation, is there any way to fetch the alias field value.


Rajkumar Narasimman

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Horst Keller
Feb 25 at 01:40 PM

I think, this is not possible in SQL. Prove me wrong, anyone?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you for responding. Above CDS view also contains 20 different calculations fields, all are based on Alias name of the Previous field(as shown above), few fields are retrieved based on conditions(of previous alias name) too, so the length and complexity of the code are increased.

Actually, CDS is created for OData service, we thought of creating service directly without creating the project. Is this only option to change those values by creating Project in SEGW?