Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
ABAP CDS is not meant to be a query runtime performance improvement. Instead, it's about how you develop and deploy your application. For example you can use CDS approach in case of ODATA consumption.

Requirement : Obtain material master details through 2 different methods

Traditional ABAP Code and through ABAP Core Data Services (CDS) with SQL functions.

Approach 1: Traditional ABAP Code approach

In Traditional ABAP Code approach we are joining above 2 tables and bringing the data to application layer. Then we will loop through above obtained result table and remove the preceding zero’s using standard function module.
report ytest_mara_cds.
tables: mara, makt.
types : begin of ty_mara,
matnr type matnr,
maktx type makt-maktx,
end of ty_mara.
data : it_mara type table of ty_mara,
wa_mara type ty_mara.
select mr~matnr
mk~maktx from mara as mr
inner join makt as mk
on mr~matnr = mk~matnr
into table it_mara
where mk~spras = 'E'.
loop at it_mara into wa_mara.
input = wa_mara-matnr
OUTPUT = wa_mara-matnr
modify it_mara from wa_mara.
clear wa_mara.

Approach 2 :Code the same requirement using ABAP Core Data Services(CDS). Here we are pushing the data and using the SQL function LTRIM. This SQL function will improve the performance.
@AbapCatalog.sqlViewName: 'ZXSHIMAT'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Material View'
define view ZXSH_I_MATERIAL
as select from mara
association [0..1] to makt as _makt
on mara.matnr = _makt.matnr {
key LTRIM( matnr, '0') as Material_Code,
mtart as Material_Type
_makt.spras = 'E'

Call this CDS view in ABAP.
repot ytest_mara_cds

select * from ZXSHIMAT into table @data(it_mara).

Conclusion :

We were able to push down the function module approach in scenario 1 to scenario 2. Similar way we can push most of the application layer logic to database layer through ABAP CDS.
Labels in this area