How to Write CDS Table Functions the Standard SAP Way
In SAP S/4HANA, we cannot always express complex business logic using pure CDS syntax. To manage scenarios like long text processing, procedural calculations, or important joins, SAP uses CDS Table Functions implemented through AMDP.
While many developers create table functions on the fly, SAP sticks to a strict and consistent design pattern across its standard content. This approach ensures good performance, readability, upgrade safety, and transportability.
A useful way to grasp this standard is to look at how SAP builds transactional CDS views, especially those that use CDS Table Functions. By examining SAP-delivered objects like I_SalesOrderTP, we can clearly see the structure, naming conventions, annotations, and implementation method that SAP expects developers to follow.
This guide explains how SAP writes table functions, how they implement them using AMDP, and how they use them in CDS views. This will help you design your own extensions in the same way SAP does.
2. Locate the Table Function Used Inside the View.
3. You will find the CDS Table Function that SAP has written.
4. Open the AMDP Class to See SAP’s Logic.
When crafting Table Functions ", in the manner SAP does " consistently adhere to this structure:
Create a CDS Table Function with parameters.
Implement it via an AMDP class/method using native SQLScript.
Consume it in your final CDS view using with parameters.
Follow the exact naming, annotation, and structure shown in standard objects such as I_SalesOrderTP, I_PurchaseOrderTP, I_BillingDocumentTP, etc.
Following this pattern guarantees:
Best performance (native HANA execution)
Transportability and upgrade-safety
Consistency with thousands of standard SAP-delivered objects
Conclusion
It is a tried-and-true architectural best practice to use SAP's standard pattern for CDS Table Functions. You can align your custom developments with the same design principles used in core SAP objects like *I_SalesOrderTP*, *I_PurchaseOrderTP*, and *I_BillingDocumentTP* by defining a CDS Table Function with parameters, implementing its logic in an AMDP method using native SQLScript, and consuming it through a final CDS view.
This method guarantees that sophisticated logic runs directly on SAP HANA for maximum efficiency, stays neatly isolated from the consumption layer, and is resilient to upgrades and transports. More significantly, because it adheres to a well-known and extensively used standard, it makes your solution instantly comprehensible to other SAP developers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 30 | |
| 28 | |
| 23 | |
| 18 | |
| 15 | |
| 13 | |
| 13 | |
| 13 | |
| 10 | |
| 8 |