Skip to Content
Technical Articles
Author's profile photo Pavan Golesar

SAP CDS hints annotation & its application in ABAP

Hi All,

SAP%20CDS%20HINTS

SAP CDS HINTS

/wp-content/uploads/2016/02/sapnwabline_885687.png

Introduction

Hints can be used to influence preparation, optimization, and execution of SQL statements. Hint can be modeled on view level using annotations, While working with CDS hints we learned few things.

/wp-content/uploads/2016/02/sapnwabline_885687.png

Problem Statement

Following blog Optimize CDS views using dbHints annotation | SAP Blogs we ran into a scenario as below:

CDS Hint annotation:

@AbapCatalog.dbHints: [{dbSystem: #HDB, hint: ‘<hint_name>’}] .“→ which is now deprecated annotation

SELECT *
FROM Z<CDS View>
WITH HINT ( USE_ESX_PLAN )

We faced below error by after calling the CDS in abap statement:SAP%20CDS%20HINTS%20GRAMMAR%20ERROR

                                        SAP CDS HINTS GRAMMAR ERROR

 

/wp-content/uploads/2016/02/sapnwabline_885687.png

Solution

Hence we have to use the up-to-date annotation as below:

@Consumption.dbHints: ['HINT1', 'HINT2'] ."→ up-to-date annotation

example as shown below:

CDS%20hints%20annotation%20%28old%20and%20new%29

CDS hints annotation (old and new)

Further calling the above sample CDS into ABAP code as below for successful usage, and found significant performance increase in testing environment.

SELECT * FROM zckub %_HINTS HDB 'USE_OLAP_PLAN' INTO TABLE @DATA(lt_tab).

/wp-content/uploads/2016/02/sapnwabline_885687.png

Conclusion

This is example on how to use and apply CDS dbHints into existing SAP ABAP program.

For BTP ABAP beginners series you can check my next SAP blog:

Exploring SAP BTP ABAP Environment

/wp-content/uploads/2016/02/sapnwabline_885687.png

Share & Connect

Useful? like and share on social media.
Connect with me on :

Thank you,

Pavan Golesar

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Andre Fischer
      Andre Fischer

      Why do you show the source code of a CDS view in SAPGUI and not in ADT 😉 ?

      Author's profile photo Pavan Golesar
      Pavan Golesar
      Blog Post Author

      Hi Andre,

      Nice spot, I have other reason however I've replaced that image with ADT

      Thanks,

      Pavan Golesar

      Author's profile photo Andre Fischer
      Andre Fischer

      Much nicer :-).