ERPClimb logoERPClimb

SAP RAP / CDS / OData CDS Table Functions Interview Questions

Interviewers use cds table functions to test depth rather than coverage: the follow-up question is almost always "why does the system behave that way?", and that is where prepared answers usually run out.

Understand CDS table functions for scenarios that require database-side logic beyond standard CDS expressions. Learn AMDP-backed implementation, parameter handling, result contracts, performance trade-offs and when a table function is justified instead of Open SQL or a normal CDS view.

This page carries 10 reviewed SAP RAP / CDS / OData cds table functions interview questions, each with a complete written answer and no sign-in required. The set breaks down into 1 foundational, 6 mid-level and 3 advanced questions, so you can start at the top for a first interview or skip ahead to the scenario-based items for a senior round.

If you can handle every question here without hesitating, cds table functions is unlikely to be what costs you an SAP RAP / CDS / OData interview — and the same reasoning pattern transfers to the neighbouring topics linked at the bottom of this page.

10 CDS Table Functions questions with answers

easyCDS Table Functions

1. What is a CDS table function and how is it built?

A CDS entity whose data is computed by an AMDP method. CDS side: define table function with parameters and a returns structure, implemented by method class=>method. ABAP side: class with if_amdp_marker_hdb, CLASS-METHODS m FOR TABLE FUNCTION <entity>, implemented BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING …, RETURN SELECT matching the returns structure exactly. Consumers use it like any CDS entity; expose it via a wrapping view entity with access control.
mediumCDS Table Functions

2. When would you use a CDS table function instead of a CDS view entity?

Only when a view entity cannot express the logic efficiently: ranking/window logic (e.g. top N per group) where not supported in CDS, multi-step SQLScript with intermediate results, special HANA functions, or proven performance needs. First check CASE, casts, date functions, aggregations, unions, associations, parameters, hierarchies. Costs of table functions: HANA dependency, limited filter pushdown, manual client handling, harder testing. Document the reason.
mediumCDS Table Functions

3. A table function fails to activate with "result structure does not match". What do you check?

Compare the RETURN SELECT with the returns structure: number and order of columns, names/aliases, and data types (e.g. DECIMAL vs INT4, lengths). The client column must be first for client-dependent functions. Check the USING list, the method declared FOR TABLE FUNCTION with the correct entity name, and activate CDS and class together. A comment listing returns fields in order above the SELECT helps prevent recurrence.
mediumCDS Table Functions

4. A supplier dashboard based on a table function shows each supplier twice in a test system. What is the likely cause?

Missing client handling: SQLScript does not filter the client automatically, so rows from several clients are returned or joined. Check that the function is client-dependent (@ClientHandling.type #CLIENT_DEPENDENT, algorithm #SESSION_VARIABLE), client is the first return field, and every client-dependent source — including joined text tables — is filtered with SESSION_CONTEXT('CDS_CLIENT'). Also check join conditions (language, keys). Test in two clients.
mediumCDS Table Functions

5. What trade-offs do you consider before approving a CDS table function?

Benefits: SQLScript expressiveness, ranking/multi-step logic, HANA functions, possibly performance. Costs: HANA-specific code, fewer optimizer options and filter pushdown, manual client handling, harder testing and debugging, specialized skills for maintenance, ABAP Cloud dependency restrictions. Approve only with documented justification, parameters for selective filters, a wrapping view with DCL, tests and measurements, and an owner.
mediumCDS Table Functions

6. How do parameters and session defaults work in CDS table functions?

Parameters are declared in the CDS definition and used in SQLScript as :p_name; consumers pass them (FROM ztf( p = @v )), wrapping views pass them on with $parameters. @Environment.systemField provides defaults (#SYSTEM_DATE, #SYSTEM_LANGUAGE, #CLIENT, #USER), so services and analytics need not supply them. Selective filters should be parameters applied inside SQLScript, because consumer WHERE conditions act on the computed result.
mediumCDS Table Functions

7. How do you test and secure a CDS table function?

Test through a wrapping view entity with ABAP Unit and the CDS Test Double Framework (cl_cds_test_environment), inserting controlled data and asserting ranking, client isolation, parameters and edge cases; run tests in ATC/transport checks. Secure via the wrapping view with @AccessControl.authorizationCheck: #CHECK and a DCL role; consumers must not read the function directly. In ABAP Cloud restrict USING to own or C4-released objects.
hardCDS Table Functions

8. Walk through building a "top 3 oldest open requests per supplier" feature with a table function.

Confirm CDS cannot do it efficiently (ROW_NUMBER over PARTITION). Define table function with p_keydate (#SYSTEM_DATE) and p_bukrs parameters, client-dependent with #SESSION_VARIABLE, returns client, keys, supplier, days open, rank. Implement FOR TABLE FUNCTION: filter client, company and status first into a table variable, then ROW_NUMBER() OVER (PARTITION BY supplier ORDER BY created_on). Wrap in a view entity with WHERE rank <= 3, DCL and annotations; test with test doubles; measure with ST05/PlanViz.
hardCDS Table Functions

9. You inherit several CDS table functions. What do you review?

Justification (could a view entity do it now?); returns structure and wrapper usage; parameters with defaults and selective filters inside SQLScript; client handling on every source; set-based SQLScript; USING list against ABAP Cloud/C4 rules; access control on wrappers; tests; performance evidence; documentation. Replace functions that newer CDS features cover.
hardCDS Table Functions

10. A table function behind a dashboard takes five seconds. How do you improve it?

Trace the consumer query with ST05; check PlanViz/explain plan for the dominant operator. Typical causes: window functions over unfiltered data, consumer filters applied after computation, too many columns, cursors/loops. Fixes: make selective filters parameters with defaults and filter first (table variables), rank only the reduced set, select needed columns, keep SQLScript set-based; compare with a CDS alternative; document before/after figures.

Related lesson

CDS Table Functions Part 4: Performance with HANA Plan Analysis

Related topics

Next practice step

Go deeper on this topic