What is CDS Table Entity?
A CDS Table entity defines a database table in ABAP CDS as an ABAP-managed database object.
Table entities are like a special container that provide a persistence layer for ABAP applications.
It supports CDS associations, semantic meta data with CDS annotations and typing with both CDS simple types and CDS enumerated types.
Advantages
> By using CDS table entity we can perform the CRUD (Select, update, modify, delete) operations and also it can be used as a data type in ABAP.
>CDS entities as the active persistence layer in scenarios with or without draft capabilities.
>When you're building a business object (like something that handles customer orders or travel bookings), you need a place to store its data permanently. You can do this by using table entities, which act like real database tables. This setup makes sure your business object's data is saved and managed, so it’s always available when needed.
>We can also control who can read the data in these tables by setting access rules, so only the right people can see sensitive information.
>It helps you organize data by showing how different parts are connected—like building a tree structure where one item is the parent and others are children. This is called a composition tree, and it helps model complex relationships in your data.
>Annotations at the element level can be used to add semantic information, such as text labels.
Disadvantages
>Table entities are not supported for draft persistence as of now. The reason is that currently include structures are not supported for table entities, which prevents including a draft admin include required for RAP draft tables.
>Extending table entities is currently not supported.
>Currently, CDS table entities cannot be used in ABAP analytics for building analytical data models, such as cubes and dimensions. They can't be enabled for data-extraction.
Defining table Entities
Let’s take a look at the delightful syntax that brings a table entity to life!"
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Table Entity'
@AbapCatalog.deliveryClass: #APPLICATION_DATA
@ClientHandling.type: #CLIENT_INDEPENDENT
define table entity Entity_Name
{
[field]
[association]
}
🌟Let’s light up the concept with a hands-on example!
We can create a Table Entity with key or without key field as well.
Without Key field
🌟In this example, we’ll be creating a table entity featuring a key field to uniquely identify each record.
💡Before we dive into performing CRUD operations in this class, there's an important note to highlight: we’ll be using a specific interface IF_OO_ADT_CLASSRUN that contains a dedicated method main for executing these operations. While it's technically possible to perform the actions without it, using this interface ensures that the output is properly displayed in the console.
⚠️To ensure smooth execution of the class, it's essential to implement the IF_OO_ADT_CLASSRUN interface. Without it, the system will display the message below.
✨Now, let’s build a class that handles CRUD operations seamlessly using our CDS table entity.
🚀Next, we’ll proceed with inserting records into the CDS table entity to demonstrate its functionality in action.
Output:
We can see the output in console
🔍Let’s now perform the read operation and retrieve the records we just inserted into the CDS table entity.
Output:
🌟"Let's proceed with the update operation and retrieve the records to review the changes. Similarly, we can perform modifications as needed!"
Output:
🌟"Let's move on to the final step—performing the delete operation and retrieving the records to confirm the changes!"
Output:
Quick Recap 🧠
CDS Table Entities offer a powerful way to define and manage persistent data in ABAP applications. They support CRUD operations, semantic annotations, and complex data modeling through composition trees. While they’re not yet compatible with draft persistence or analytics, they remain a key building block for structuring business objects in ABAP.
💬If you’ve got thoughts, questions, or experiences with CDS Table Entities, feel free to drop them in the comments—I’d love to hear how you're using them in your ABAP projects.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 33 | |
| 21 | |
| 18 | |
| 16 | |
| 13 | |
| 12 | |
| 10 | |
| 9 | |
| 9 | |
| 9 |