How fast is ABAP Core Data Service (CDS) with SQL functions?  This is one of the frequent question raised by technical consultants after any ABAP CDS sessions. We can demonstrate speed of ABAP CDS with SQL functions through below simple approach, I have written same requirement in two different methodologies. Business requirement is to obtain the material number from MARA table and material description from MAKT table. Material number in final result should be without preceding zero’s.

We will approach above requirement through two 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. call function 'CONVERSION_EXIT_ALPHA_OUTPUT' exporting input = wa_mara-matnr IMPORTING OUTPUT = wa_mara-matnr . modify it_mara from wa_mara. clear wa_mara. endloop. 

Now run the transaction SAT to check the runtime analysis.

From above analysis , it took 174047 micro seconds which is equal to 0.17 sec.

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 } where _makt.spras = 'E' 

Call this CDS view in ABAP.

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 * from ZXSHIMAT INTO TABLE @it_mara.

Now run the transaction SAT to check the runtime analysis.

From above analysis , it took 87895 micro seconds which is equal to 0.088 sec.

Conclusion : ABAP CDS approach with SQL functions took only half of the traditional approach execution time. This is achieved because of the use of SQL function ‘LTRIM’ in ABAP CDS query. How ever if there is only simple select query without any material conversions, then performance will not have much difference in both cases.Query performance will improve by using SQL functions. This is also the case for any aggregations.

*These findings may vary depending on the system load, but not much.

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !