ERPClimb logoERPClimb
CDS Table Functions
RAP / CDS / ODataintermediate 9 min read

CDS Table Functions Part 2: Building a Table Function with an AMDP Implementation

Preview · a free account unlocks the full lesson

Key takeaway

Build a CDS table function end to end: the CDS definition with parameters and return structure, the AMDP class with FOR TABLE FUNCTION, the SQLScript implementation, activation and a first test in data preview.

In this lessonShow sections

Explanation

On the CDS side, a table function is declared as "define table function … with parameters … returns { … } implemented by method class=>method". On the ABAP side, it's a class implementing if_amdp_marker_hdb with a static method declared FOR TABLE FUNCTION. The implementation itself is written BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING <tables>. One strict requirement: the SELECT list must match the returns structure exactly, in names, order and types.

Part 1 made the case for a table function for "age rank per supplier"; this part builds it as ZTF_PurchReqAgingRank.

The first step is the CDS definition. It starts with "define table function ZTF_PurchReqAgingRank," takes a parameter such as p_keydate — the date used for the age calculation — and declares its output structure with "returns { … }"; for client-dependent data, the first element in that structure is the client field, a detail covered in Part 3. It's tied to its implementation with "implemented by method zcl_tf_purchreq_aging=>get_aging_rank." In ADT, you'd create this via New → Data Definition, using the template "Define Table Function with Parameters."

Free account

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.