Skip to Content

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 25, 2018 at 01:40 PM

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

    Add comment
    10|10000 characters needed 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?