CDS Views Part 9: Parameters and Filtering
Preview · a free account unlocks the full lesson
Define CDS views with input parameters, use $parameters in WHERE, calculations and path filters, default parameters from system fields, and pass parameters from ABAP. Learn when parameters are the right tool and when a simple WHERE by the consumer is better.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 8 restricted rows by user; now we let the consumer supply values that actually shape the result, through CDS parameters.
A view declares them with with parameters, for example define view entity ZX with parameters p_keydate : abap.dats, p_currency : waers as select from ..., using either built-in abap.* types or data elements; every parameter is mandatory unless it's given a default through @Environment.systemField.
Parameters are the right tool when the value changes the calculation itself — a key date, a target currency, a language — not for plain row filtering.
Inside the view, parameters are used as $parameters.<name>, whether in a WHERE clause (WHERE erdat <= $parameters.p_keydate), in a calculation (dats_days_between( erdat, $parameters.p_keydate )), in a path filter (_Text[1: Language = $parameters.p_language]), or as the target of a currency conversion (target_currency => $parameters.p_currency).
@Environment.systemField lets a parameter fill itself automatically when the consumer doesn't pass it — common values are #SYSTEM_DATE, #SYSTEM_LANGUAGE, #CLIENT, and #USER. For simple needs like "today" or "the logon language," $session variables, covered in Part 2, can avoid the need for a parameter entirely.
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
Interview questions on this topic
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
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.