1

I am working in SAP HANA Native CDS, where i want to convert a sql query into CDS format.

The current SQL Query looks like this

FIRST_VALUE(STAT) OVER(PARTITION BY OBJNR ORDER BY UDATE desc, UTIME desc) as STAT,
FIRST_VALUE(UDATE) OVER(PARTITION BY OBJNR ORDER BY UDATE desc, UTIME desc)  as CHG_DATE

I now tried to convert this into HANA CDS like this

view V_MYVIEW as select from TABLE
{
OBJNR,
FIRST_VALUE(STAT) OVER(PARTITION BY OBJNR ORDER BY UDATE desc, UTIME desc) as STAT,
FIRST_VALUE(UDATE) OVER(PARTITION BY OBJNR ORDER BY UDATE desc, UTIME desc)  as CHG_DATE
};

Syntax error: unexpected token "(" at line 36, column 12

but the code throws an error at ( and ). Is there any other way to achieve this in the CDS??

Best Regards, Gabriel.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Gabriel
  • 39
  • 10
  • 1
    Are you missing the `DEFINE` command in `DEFINE view V_MYVIEW as select ...` ? Also, could you please provide a minimal working example with a simple table where all columns are known? For example UDATE and UTIME are not defined anywhere yet. – koks der drache Dec 04 '19 at 15:53
  • Hello Konstantin , this is native hana CDS , the view is fine working without the following statements FIRST_VALUE(STAT) OVER(PARTITION BY OBJNR ORDER BY UDATE desc, UTIME desc) as STAT, FIRST_VALUE(UDATE) OVER(PARTITION BY OBJNR ORDER BY UDATE desc, UTIME desc) as CHG_DATE – Gabriel Dec 04 '19 at 16:37
  • The table name i masked here is JCDS – Gabriel Dec 04 '19 at 16:39

1 Answers1

2

These analytical/window-functions are not supported by HANA CDS in HANA 2 SPS 04. If you want to use those, you may have to resort to table functions or SQL views.

Lars Br.
  • 9,949
  • 2
  • 15
  • 29