Core Data Services (CDS) views have become a central element in SAP HANA Live and S/4HANA analytics, enabling rich, semantic data modeling directly on the database layer. Among the advanced capabilities of CDS views, parameters stand out as a powerful feature to enable dynamic filtering, enhance reusability, and improve performance by pushing selection logic to the database. This article explores how parameters are used in CDS views within SAP HANA Live, their syntax, use cases, and best practices.
Parameters in CDS views act like input variables that can be passed during query execution to filter or modify the data output dynamically. Unlike fixed filters hardcoded in the view logic, parameters allow end-users or consuming applications to supply values at runtime, providing flexible and context-driven reporting.
Parameters are declared in the CDS view syntax in the @Param section or directly in the view definition, typically as:
@AbapCatalog.sqlViewName: 'ZCDS_SALES'
@AccessControl.authorizationCheck: #CHECK
define view ZSalesOrders
with parameters
p_sales_org : bukrs,
p_date_from : sy-datum,
p_date_to : sy-datum
as select from vbak
{
key vbak.vbeln,
vbak.erdat,
vbak.vkorg,
vbak.netwr
}
where vbak.vkorg = :p_sales_org
and vbak.erdat between :p_date_from and :p_date_to
with parameters clause.: prefix.The primary use of parameters is to restrict datasets dynamically by adding conditions in the where clause. For example:
where vbak.vkorg = :p_sales_org
Multiple parameters can be combined with logical operators to form complex filters.
CDS views with parameters can be consumed in various ways:
@AbapCatalog.sqlViewName: 'ZCDS_SALES'
define view ZSalesByPeriod
with parameters
p_vkorg : vkorg,
p_date_fr: sy-datum,
p_date_to: sy-datum
as select from vbak
{
key vbak.vbeln,
vbak.erdat,
vbak.netwr
}
where vbak.vkorg = :p_vkorg
and vbak.erdat between :p_date_fr and :p_date_to
This view returns sales orders for a specified sales organization and date range, improving flexibility and reducing unnecessary data processing.
@Consumption.filter to indicate parameters should be exposed as filters in UIs.Parameters in CDS views empower SAP HANA Live developers to create dynamic, reusable, and high-performance analytical models. By leveraging parameters, enterprises can deliver tailored reporting experiences that align precisely with business needs, making data consumption more efficient and user-friendly. Understanding how to design and implement parameters effectively is crucial for anyone working with SAP’s modern data modeling frameworks.