cancel
Showing results for 
Search instead for 
Did you mean: 

HANA XSA: Using table functions in CDS Views

achim_vogel2
Explorer

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

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member540015
Participant

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

former_member585658
Participant
0 Kudos

How did u manage it in XS Valery Semichev?

former_member540015
Participant
0 Kudos

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.

carlsoane
Participant
0 Kudos

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