Calling CDS in AMDP Part -3



CLASS zcl_amdp_client DEFINITION

PUBLIC

FINAL

CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_amdp_marker_hdb.


TYPES : tt_zcds_sample_01 TYPE TABLE OF zvsql_sample_01.

CLASS-METHODS get_data_cds

AMDP OPTIONS

CDS SESSION CLIENT iv_clnt

IMPORTING VALUE(iv_clnt) TYPE sy-mandt

EXPORTING VALUE(et_so) TYPE tt_zcds_sample_01.


PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.


CLASS zcl_amdp_client IMPLEMENTATION.

METHOD get_data_cds BY DATABASE PROCEDURE

FOR HDB

LANGUAGE SQLSCRIPT

USING zcds_sample_01.

et_so = select *

from zcds_sample_01

WHERE mandt = :iv_clnt;

* Where mandt = session_context( 'CDS_CLIENT' );

ENDMETHOD.


ENDCLASS.




**********************************************************************



**********************************************************************

*AMDP does not support implicit client handling.

*We should pass client in parameter interface


*Exception :- When we are calling another CDS view which is using

* @ClientHandling.algorithm:#SESSION_VARIABLE.

* In this case CDS_CLIENT is used in where condition which came

*from AMDP OPTIONS CDS SESSION CLIENT .

*If it is not specified or passed from importing

*parameter then and it is different from CDS_CLIENT

*we will get empty result




@AbapCatalog.sqlViewName: 'ZVSQL_SAMPLE_01'

@EndUserText.label: 'This is my fist DDIC based CDS'

@AbapCatalog.preserveKey: true

@AbapCatalog: {

buffering: {

status:#SWITCHED_OFF,

type: #NONE,

numberOfKeyFields: 000

},


viewEnhancementCategory: [#PROJECTION_LIST,#UNION],

compiler: {

compareFilter: true

},

dataMaintenance: #RESTRICTED

}

@AccessControl.authorizationCheck: #CHECK

@ClientHandling: {

type: #INHERITED,

algorithm:#SESSION_VARIABLE

}


define view zcds_sample_01 --( SO, Kunnr, curr,netwr,clnt,sydate,syslang)

as select from vbak

association [1..*] to vbap as _item on vbak.vbeln = _item.vbeln

{


key vbeln as so,

kunnr as cust,

waerk,

netwr,

vkorg,

vbtyp,

ernam ,

$session.client as syst_client,

$session.system_date as syst_date,

$session.system_language as syst_lang,

_item


}













/*define view zcds_sample_01

as select

key vbeln as so,

kunnr as cust

from vbak; */

// Commentsingle

-- vndvld

/*

DataAging Annotations

ObjectModel.usageType

//@Metadata.ignorePropagatedAnnotations: true

//@ObjectModel.usageType:{

// serviceQuality: #X,

// sizeCategory: #S,

// dataClass: #MIXED

//}

This information is especially important in regards of performance

that can be expected by the consumer of the view.



Create a view use in select report to display results.





/*When an object defined in the CDS source code is activated,

the annotations defined in the CDS annotation syntax these are saved in

internal system tables. These tables can then be accessed to evaluate the data.


We use below class for evaluation of annatation

CL_DD_DDL_ANNOTATION_SERVICE

-> First it gets data from metadata extension though it's method

-> Then CDS Entity itself to evaluate


-> Annotation devided in three parts

1. Metadata extension

2. Direct Annotation (GET_DIRECT_ANNOS_ )

3. indirect Annotation ( Derived and inheritate )

inheritate -> CDS entities which accessed in thid cds

Derived -> It derived from data element if it is not define in cds

*/

Comments

Popular posts from this blog

AMDP ( ABAP Managed Database Procedure ) Part - 1

Backup all ADT Objects & Other queries RAP Part 10.1

SAP CDS Introduction Part 2 - ABAP on HANA Course