Skip to Content

HANA XSA: Using table functions in CDS Views

Dear Experts,

I would like to use a user defined table function in a cds view. But I will get a syntax error in CDS code editor.

Function definition:

FUNCTION "xyz.db.function::getUserClientIdsFromRoles" ( )    
RETURNS TABLE ( "Id"   NVARCHAR(10) )  
   LANGUAGE SQLSCRIPT SQL 
   SECURITY INVOKER               
AS 
BEGIN ..... END

View definition:

DEFINE VIEW UserClientView AS
           SELECT FROM "xyz.db.function::getUserClientIdsFromRoles"() 
           {
                Id AS "Client"
           };        

The WebIDE CDS Editor is showing an error in the view definition:

"CDS: error: Unexpected token "(""

Regards

Achim

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jul 09 at 08:44 AM

    Hi Achim!

    Table functions were not available in Core Data Services view definition since XS and HANA 1.0. I don't know reason why, and it's not clearly stated in SAP official docs. There are workarounds how to overcome this, but they are weird and I gave up and implemented same logic into the view itself.

    Regards, Valery

    Add comment
    10|10000 characters needed characters exceeded

    • It depends on your needs. Sometimes UDF is just a peace of code used in one place and can then can be coded into the online view itself. Sometimes a batch routine procedure has to be implemented.

  • avatar image
    Former Member
    Jun 23, 2017 at 05:26 PM

    Hello Achim:

    I don't know what causes that problem, but I have alerted some colleagues on the WebIDE team to the problem you are seeing.

    Regards,

    Carl Soane

    Add comment
    10|10000 characters needed characters exceeded