ABAP CDS View Templates

0
8319

Are you tired of writing repetitive DDL source code for your ABAP CDS views? But here’s some good news: ABAP CDS View Templates, available through Eclipse-based ABAP Development Tools (ADT), offer a powerful solution. If you’re working on S/4HANA projects, you already know that ABAP Core Data Services (CDS) views are essential components for various applications – from reporting and SAP Fiori Smart Templates to OData services and BEx queries in Embedded Analytics.

As ABAP developers, we often find ourselves spending countless hours crafting similar DDL source code for these views. But here’s some good news: Eclipse-based ABAP Development Tools (ADT) offers a powerful solution through its Data Definition Templates feature.

In this blog post, we’ll explore how these templates can significantly reduce your development time and streamline your CDS view creation process. Let’s dive in and discover how to make your ABAP development more efficient!

CDS View Templates: Data Definition

Eclipse based ADT provides Data Definition Templates, 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.

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 custom 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. Hurray!!! 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

Conclusion

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!