ABAP CDS View Templates


Dear SAPLearners, in this blog post you will learn about ABAP CDS view Templates.

ABAP Core Data Service(CDS) view plays a very important role in S/4HANA Projects. Developers needs to create ABAP CDS view for different purposes like reporting, SAP Fiori Smart Templates, OData services, BEx queries in Embedded Analytics.

During the ABAP CDS View development, we spent many hours writing same DDL source code.

CDS View Templates: Data Definition

Eclipse based ADT provides Data Definition Templates, to address the above problem and reduce the time spent on ABAP CDS view development.

When you create an ABAP CDS view in ADT and follow the Data Definition creation wizard, when you reach the step Templates, where you will find the predefined code templates available for selection.

Also Read: How to create ABAP CDS View.
ABAP CDS View Templates

Eclipse ADT IDE provides 12 predefined ABAP CDS view templates. You can view all data definition templates available in Window -> Preference section.

ABAP CDS View Template Step3

You can view the preview of Data Definition Template by selecting any of the template.

ABAP CDS View Template Step4

Okay this is cool! 😎 Can I create additional Data Definition templates for my own use? Yes, we can create, edit and remove templates. Lets see how we can do it.

Create a New Template

1. Under Templates section, click on New.

ABAP CDS View Template Step5

2. On New Template dialog window. Specify the Name and the Description, and select Data Definition (creation) as the Context.

3. Choose the Insert Variable button to add variables in the Pattern field.

Add annotations and other fields as per need to prepare your template. Here I created the template with all annotations I need for SAP Fiori Elements application.

ABAP CDS View Template Step6

4. Click on OK.

5. Click on Apply and Close button to save the template.

ABAP CDS View Template Step7

6. Finally our new template is ready for use. Lets create a ABAP CDS view based on newly created template. Select the custom template

ABAP CDS View Template Step8

7. Boooom!!! DDL source code is pre-populated based on the template, all you have to do is to replace the table and field names.

ABAP CDS View Template Step9


Congrats!! you have learned about ABAP CDS view templates and also how to create new re-usable template. In your next S/4 HANA project try creating these templates and speed up the development. Also read the benefits of using these templates here.

Please feel free to comment and let us know your feedback. Subscribe for more updates.

If you liked it ❤️, please share it! Thanks!