Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

The calling AMDP method must also allow this restriction

7,162

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

6 REPLIES 6

luis_sismeiro
Participant
3,333

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

0 Kudos
3,333

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?

0 Kudos
3,333

Hi,

For the moment I don't have access to hana DB, I had this on my notes.

Maybe this link can help you.

0 Kudos
3,333

I am using the following steps to prevent the client issue:

  • Insert "@ClientHandling.type: #CLIENT_DEPENDENT" in the table function definition
  • Provide the client as a parameter to the table function
define table function <table_function_name>
with parameters
@Environment.systemField: #CLIENT
clnt :abap.clnt
  • Add the client also in the return statement of the table function
returns
{
client : abap.clnt;
... }
  • Use the client in the where-clause in the abap class
...
where <table_name>.mandt =  :clnt
...

3,333

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

sangy1
Newcomer
0 Kudos
656

Hi Dhruv,

 

Was your issue resolved?