CDS View with input parameters Part 7 ABAP on HANA Course
Summary
TLDRThis video tutorial delves into the creation and use of parameterized CDS (Core Data Services) views in SAP. It explains how to define parameters for a CDS view, making some mandatory and others optional by setting default values. The video walks through examples of passing parameters such as sales order numbers and dates, and shows how default system fields like client, system date, and user ID can be applied. Additionally, the tutorial discusses the differences between DDIC-based CDS views and new CDS entity views, providing insights on how to manage parameters effectively.
Takeaways
- 📊 Parameterized CDS views require user input for certain values to execute, especially for filtering data dynamically.
- ⚙️ Parameters can be passed during the execution or while calling the CDS view in a select statement.
- 💡 Defining parameters in a CDS view allows more flexibility as users can input values instead of relying on constants.
- 📝 Parameters need to be referenced using the `$parameters` syntax to pass the user input into WHERE conditions.
- 🚫 All parameters are mandatory unless a default system value (like system date or client) is assigned.
- 📅 You can define multiple parameters, including dates, and use them in the WHERE clause or output fields.
- 🚀 Default values for parameters can be assigned using system variables (e.g., system date), making those parameters optional during execution.
- 🔧 When using parameters in output fields, an alias must be specified.
- 📝 SAP provides system fields like system date, system time, and client as default values, but only a few system fields can be used as defaults.
- 🖥️ SAP's standard demo programs provide examples for testing and understanding parameterized CDS views.
Q & A
What is a parameterized CDS view in SAP?
-A parameterized CDS view is a Core Data Services (CDS) view that accepts input parameters. When executing the view, it asks for parameter values, and only after these values are provided does it generate the output.
Why would you use a parameterized CDS view instead of a normal CDS view?
-You would use a parameterized CDS view when you want to control which data is displayed by asking the user to provide specific input values. This makes the view more dynamic and flexible, as it can return different results based on the parameters passed.
How do you define a parameter in a CDS view?
-To define a parameter in a CDS view, you add the `with parameters` clause after the view entity definition. You specify the parameter name, its data type (like ABAP types or data elements), and optionally default values using system variables.
Can you explain how to access a parameter in a WHERE clause in CDS?
-To access a parameter in a WHERE clause, you use the `$parameters` keyword followed by the parameter name. For example, `$parameters.p_vbeln` would be used to access a parameter named `p_vbeln` and pass its value to the WHERE clause.
Are parameters in a CDS view always mandatory?
-Yes, parameters in a CDS view are mandatory by default. However, there is an exception if you provide a default value using system fields (like system date, system client). In such cases, the parameter is not mandatory.
What annotation is used to assign a default value to a parameter in a CDS view?
-The `@Environment.systemField` annotation is used to assign default values to parameters in a CDS view. This annotation allows you to use predefined system values like the system date, time, client, etc.
What happens if you don't pass a parameter value when calling a parameterized CDS view in ABAP?
-If a mandatory parameter is not passed when calling a parameterized CDS view in an ABAP program, the system will raise a syntax error or cause a dump, indicating that the parameter is missing.
Can a parameter be used in fields other than the WHERE clause?
-Yes, parameters can be used in various parts of the CDS view, such as the field list, WHERE clause, or even in aggregation and on conditions. You can access the parameter value using the `$parameters` expression.
What types of system fields can be used as default values in CDS parameters?
-The system fields that can be used as default values include the system client, system date, system time, system user, system language, and system timezone.
What is the difference between a DDIC-based CDS view and a CDS view with entity definitions?
-A DDIC-based CDS view can use colon syntax (:) to access parameters, while a CDS view with entity definitions requires the use of the `$parameters` expression. The newer entity-based CDS views have stricter syntax rules.
Outlines
此内容仅限付费用户访问。 请升级后访问。
立即升级Mindmap
此内容仅限付费用户访问。 请升级后访问。
立即升级Keywords
此内容仅限付费用户访问。 请升级后访问。
立即升级Highlights
此内容仅限付费用户访问。 请升级后访问。
立即升级Transcripts
此内容仅限付费用户访问。 请升级后访问。
立即升级5.0 / 5 (0 votes)