In previous article, we have experienced by using CDS View inside CDS Table function. And now, we will try with AMDP procedure
Like as CDS table function, with AMDP Procedure, we will also catch an error
Because this CDS View which we used in this article is a client specific. But AMDP is not. Basically, AMDP will get all data of all client (assume your system have several clients), that is a reason why you catch this error when working with CDS view.
So, how to resolve it? Please read this article with me.
A little bit CDS View and AMDP. If you don’t have any experience, please follow link
We will create Global Class and handle method to get data from CDS View, both standard CDS View and Customized CDS View are good
CLASS zcl_demo_amdp DEFINITION
CREATE PUBLIC .
INTERFACES if_amdp_marker_hdb .
TYPES: BEGIN OF ty_test,
mandt TYPE mandt,
bukrs TYPE bukrs,
belnr TYPE belnr_d,
gjahr TYPE gjahr,
docln TYPE docln,
END OF ty_test.
TYPES: tt_test TYPE STANDARD TABLE OF ty_test.
get_CDS AMDP OPTIONS CDS SESSION CLIENT current
EXPORTING VALUE(tt_return) TYPE tt_test .
CLASS zcl_demo_amdp IMPLEMENTATION.
METHOD get_CDS BY DATABASE PROCEDURE
FOR HDB LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY USING i_journalentryitem .
TT_RETURN = SELECT MANDT AS MANDT,
CompanyCode AS BUKRS,
AccountingDocument AS BELNR,
FiscalYear AS GJAHR,
LedgerGLLineItem AS DOCLN
AMDP OPTIONS CDS SESSION CLIENT current is very important, With this statement, the system will only get the correct data of the current client
Yeah, we have successfully used CDS view inside AMDP Procedure, I hope it can help you!!!
If this blog is good, please like and share it. If you don't understand something, please leave a comment in the article.