CDS Table Functions Part 5: Testing, Clean Core and Alternatives
Preview · a free account unlocks the full lesson
Keep table functions maintainable: test them with ABAP Unit and test doubles, protect them with access control on the wrapping view, respect ABAP Cloud rules for AMDP, and know the modern alternatives in CDS.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Table functions are tested with ABAP Unit, using test doubles for the tables they read. Access control (DCL) belongs on the wrapping CDS view entity that consumers actually use, not on the table function itself. In ABAP Cloud, AMDP may only access your own objects and SAP objects released for AMDP use under contract C4. It's worth periodically re-checking whether a newer CDS release has made the table function unnecessary altogether.
Parts 1 through 4 built a correct and fast table function; this part is about keeping it safe and maintainable.
For testing, unit tests use the CDS Test Double Framework, cl_cds_test_environment, on the wrapping view, with test doubles standing in for the database tables the AMDP actually reads — depending on your release, the framework may be able to double the table function's dependencies directly.
Controlled test data — say two suppliers, several dates, and two clients if that's relevant — should be inserted, with assertions covering ranking, day counts, client isolation and parameter filtering. It's also worth testing edge cases: no data at all, equal dates that create ranking ties, and boundary dates. These tests should run as part of ATC and transport checks.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.