SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Calling AMDP Method Must Also Allow This Restriction


During code enhancements on S4/HANA system based ABAP Test Cockpit ATC and CVA checks, I decided to move an OpenSQL Select statement into an CDS view accessed via AMDP stored procedure on HANA database.
But I experienced the error CDS view is client-specific and restricts access to a client. The calling AMDP method must also allow this restriction. during activation of the AMDP class codes on SAP HANA Studio.

I create CDS View where I filter data based on session client value on MANDT column using session parameter $session.client in WHERE clause like in following SELECT code

select * from vbrk where vbrk.mandt = $session.client;
Code

CDS view with session parameter client

When I tried to use this CDS View in my AMDP class method (stored procedure on HANA database), I experienced following error which prevent the AMDP to be successfully compiled and activated.

"Z_CDS_VIEW" is client-specific and restricts access to a client. The calling AMDP method "AMDP_METHOD" must also allow this restriction.

In the following code line ABAP developers can see how I called CDS view within AMDP and applied a WHERE clause using APPLY_FILTER command.

lt_vbrk = apply_filter ("Z_CDS_VIEW", :iv_where);
Code

After a short search I find out that stored procedure requires additional AMDP options defined in the AMDP class method declaration.
ABAP programmers can find the official documentation about AMDP options at ABAP Documentation

ABAP AMDP class methods for SAP HANA stored procedures

To resolve error message 'Z_CDS_VIEW is client-specific and restricts access to a client. The calling AMDP method "AMDP_METHOD" must also allow this restriction.', I had modified the AMDP class method definition as follows:

class-methods AMDP_METHOD
AMDP OPTIONS READ-ONLY
CDS SESSION CLIENT current
importing
 value(iv_where) type string
exporting
 value(et_invoicelist_xl) type ZSOM_INF_INV_VBRK_TT
raising cx_amdp_error .
Code

ABAP developer makes above modification on Class Method Definition by adding AMDP OPTIONS CDS SESSION CLIENT CURRENT. There is no need to make any modifications in the method implementation.

AMDP class method options for CDS session client parameters

Converting the OpenSQL statements into CDS views or AMDP methods also resolves CVA security checks for ABAP where sensitive database tables are read.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.