2021 Dec 27 4:02 PM
I am trying to create an AMDP for a CDS view.
Implementation of table function:
METHOD <method_name>
BY DATABASE FUNCTION FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING <view_entity_name>.
RETURN
SELECT id_1, id_2,
ROW_NUMBER( ) OVER( PARTITION BY id_1)
FROM <view_entity_name>
GROUP BY id_1, id_2.
ENDMETHOD.
However, when trying to select from a CDS view and not from a database table the following error is displayed:
<view_entity_name> is client-specific and restricts access to a single client. The calling AMDP method <method_name> must also allow this restriction.
Now, I would like to know how I can use the specified CDS view entity in the table function.
Regards,
Dhruv
2021 Dec 27 5:55 PM
Hello,
I think that you can add the following to the method's definition.
class-methods <method_name>
AMDP OPTIONS READ-ONLY
CDS SESSION CLIENT current
2021 Dec 28 8:55 AM
Hey,
I tried the suggested approach. However, when I use the mentioned additions then I am not allowed to use the "FOR TABLE FUNCTION <table_function>" line.
CLASS-METHODS get_by_cndn_no
AMDP OPTIONS READ-ONLY
CDS SESSION CLIENT current.
* FOR TABLE FUNCTION <table_function>.
So, how can I reference the table function instead of using the "FOR TABLE FUNCTION <table_function>" line?
2021 Dec 28 9:12 AM
Hi,
For the moment I don't have access to hana DB, I had this on my notes.
Maybe this link can help you.
2022 Jan 05 8:43 AM
I am using the following steps to prevent the client issue:
define table function <table_function_name>
with parameters
@Environment.systemField: #CLIENT
clnt :abap.clnt
returns
{
client : abap.clnt;
...
}
...
where <table_name>.mandt = :clnt
...
2022 Jun 22 6:14 AM
Hi All,
For this to work, i did 4 things to the table function.
Specify the annotation @ClientHandling.type: #CLIENT_DEPENDENT.
Specify the annotation @ClientHandling.algorithm: #SESSION_VARIABLE.
Specify a client input parameter of type abap.clnt flagged with the annotation @Environment.systemField: #CLIENT.
Add field with type abap.clnt in the signature (position 1) for fields to be retrieved
then for the class-method, you have to return mandt at position 1, corresponding to the signature of the table function.
Rowie
a month ago