Friday, 20 March 2020

ABAP CDS VIEWS simplified – PART 1

INTRODUCTION:


ABAP Core Data Service Views also known as ABAP CDS Views. There are so many limitations in SE11 views but we can come out of all the limitations and create a powerful views with the help of ABAP CDS Views.

In general SE11 views and ABAP CDS Views both will create a database views at the backend. When we try to access these views as a table in the ABAP code, this code will be executed at the database level.

Hence, SE11 views and ABAP CDS Views both will implement code push-down, In-spite of this, CDS views has many advantages in CDS views.

Below are the comparison between SE11 views and ABAP CDS Views:

SE11 Views CDS Views 
1. It can be created from SAPGUI or Eclipse.
2. Calculated column are not possible.
3. Input Parameters are not possible.
4. Only Join is possible.
5. Grouping and aggregation are not possible.
6. Annotations are not possible. 
1. It can be created from SAPGUI or Eclipse.
2. Calculated column are not possible.
3. Input Parameters are not possible.
4. Only Join is possible.
5. Grouping and aggregation are not possible.
6. Annotations are not possible. 

Basic ABAP CDS View creation:


Below are the prerequisite knowledge required to create a ABAP CDS View:

1. Creation of ABAP Project
2. Creation of ABAP Package
3. ABAP programming

I have already created the ABAP Project and ABAP Package in the HANA Development perspective and below are the screen shot of these object.

ABAP Project

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

2. ABAP Package

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

Note: Make sure that you should create a ABAP package inside the ABAP project.

I am demonstrating the ABAP CDS view creation using SPFLI table with all the fields of it.

Step 1. Right click on the ABAP Package and select new ABAP repository object and navigate to Core Data Services, select the Data Defination and provide a name to CDS view.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

Step 2 and Step 3. Please provide a suitable name based on your project’s naming                   convention. Click on next and select the Transport request as shown below:

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

Step 4. Select the template based on your requirement and Click finish. I am selecting Define View template since I am creating a ABAP CDS view with all the fields of Database table SPFLI.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

Step 5. As soon as you click on the finish, Below code will appears. Please refer the screen shot for explanation.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

Step 6: Below is the logic for CDS views.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

Step 7. Activate it and click on data preview option.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

Step 8. Click on data preview to view the data of this CDS view.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP CDS

With this example, we have completed the First part of ABAP CDS VIEWS simplified.

No comments:

Post a Comment