cancel
Showing results for 
Search instead for 
Did you mean: 

CDS View Table functions Abap Class consume with parameters

TrattnigS
Discoverer
0 Kudos

Hello please can someone assist me. I want to select data through a class method implemented in ABAP class. This method takes parameters from the defined table function to filter on POnumber and POitem. Goal is to call this table function in my main CDS View, but i have already something in the from clause and several joins. So i can only join the table function i guess.

This works but only with static parametric-al data but i want to have it dynamic.

hard-coded:

left outer join Z_WH_EDDATE_TABLE_FUNCTION(clnt: $session.client, ebeln_param: '4500000020', ebelp_param: '00010') on ekpo.ebeln = Z_WH_EDDATE_TABLE_FUNCTION.ebeln_1

Goal:

left outer join Z_WH_EDDATE_TABLE_FUNCTION(clnt: $session.client, ebeln_param: ekko.ebeln, ebelp_param: '00010') on ekpo.ebeln = Z_WH_EDDATE_TABLE_FUNCTION.ebeln_1

Error: Unexpected word "ekko"

Next try, execute directly in the fields block:

Z_WH_EDDATE_TABLE_FUNCTION(clnt: $session.client, ebeln_param: '4500000123', ebelp_param: '00010').ed_date as exc,

Error: It is not possible to expand path element Z_WH_EDDATE_TABLE_FUNCTION

I want to select data through a class method implemented in ABAP class. This method takes parameters from the defined table function to filter on POnumber and POitem. Goal is to call this table function in my main CDS View, but i have already something in the from clause and several joins. So i can only join the table function i guess.

This works but only with static parametric-al data but i want to have it dynamic.

hard-coded:

left outer join Z_WH_EDDATE_TABLE_FUNCTION(clnt: $session.client, ebeln_param: '4500000020', ebelp_param: '00010') on ekpo.ebeln = Z_WH_EDDATE_TABLE_FUNCTION.ebeln_1

Goal:

left outer join Z_WH_EDDATE_TABLE_FUNCTION(clnt: $session.client, ebeln_param: ekko.ebeln, ebelp_param: '00010') on ekpo.ebeln = Z_WH_EDDATE_TABLE_FUNCTION.ebeln_1

Error: Unexpected word "ekko"

Next try, execute directly in the fields block:

Z_WH_EDDATE_TABLE_FUNCTION(clnt: $session.client, ebeln_param: '4500000123', ebelp_param: '00010').ed_date as exc,

Error: It is not possible to expand path element Z_WH_EDDATE_TABLE_FUNCTION

So i guess it is not possible have a dynamic calling of table functions with parameters from an CDS view. How would you handle this?

Table function:

> define table function Z_WH_EDDATE_TABLE_FUNCTION with parameters
>     @Environment.systemField: #CLIENT
>     clnt   :abap.clnt,
>     ebeln_param :abap.char( 10 ),
>     ebelp_param :abap.numc( 5 ) 
> returns {   client : abap.clnt;   ebeln_1 : abap.char( 10 );   ed_date : abap.dats( 8 ); } implemented
> by method ZCL_FLIGHTS_DEMO_CDS=>ED_DATE_RETRIEVAL;

ABAP method:

> METHOD ED_DATE_RETRIEVAL
>         BY DATABASE FUNCTION
>         FOR HDB
>         LANGUAGE SQLSCRIPT
>         OPTIONS READ-ONLY
>         USING ekes.
> 
>             itab_ed =
>                 SELECT
>                     ekes.mandt as client,
>                     ekes.ebeln as ebeln_1,
>                     ekes.eindt as expDate
>                 FROM ekes
>                  WHERE  ekes.ebtyp = 'ED'
>                  and ekes.ebeln = :ebeln_param and ekes.ebelp = :ebelp_param;
>            RETURN
>                 SELECT client,
>                         ebeln_1,
>                         MIN(expDate) as ed_date
>                  FROM :itab_ed
>                  GROUP BY client,ebeln_1;
>     ENDMETHOD.

The problem is only calling ekes without where conditions leads to out of memory allocation sometimes.
For me it is curious why we cant give dynmaic parameters but hard coded ones to the calling of a view.

Accepted Solutions (0)

Answers (0)