Using Code Pushdown in CDS Views Flashcards
What are the benefits of using code pushdown in CDS views?
The benefits of using code pushdown in CDS views include:
Encapsulation: SQL logic is hidden within the CDS view definition, making ABAP SQL statements easier to read.
Reuse: The SQL logic can be reused in various applications by reading from the same CDS view.
Semantics: Calculation results can have meaningful names and annotations.
Authorization Rules: Access to calculated data can be restricted using CDS access controls.
How do SQL expressions in CDS views enhance database calculations?
SQL expressions in CDS views allow complicated calculations to be performed within the database rather than in the ABAP layer. This leverages SAP HANA’s powerful data analysis capabilities, leading to more efficient and faster data processing.
What types of literals are supported in ABAP CDS?
ABAP CDS supports a larger variety of literals compared to ABAP SQL, including:
Character Literals: Predefined type NUMC for character literals consisting of only digits.
Numeric Literals: Types INT4, INT2, INT1, and FLTP. This includes non-integer literals containing a decimal point.
How does the CAST expression function in ABAP CDS compared to ABAP SQL?
The CAST expression in ABAP CDS functions similarly to ABAP SQL with some differences:
Requires prefix “abap.” for predefined dictionary types.
Allows casting to dictionary data elements, which includes semantic information.
Restrictions on combinations of source and target types, particularly with FLTP as a source.
What are the differences between simple and complex CASE distinctions in ABAP CDS and ABAP SQL?
There are no functional differences between simple and complex CASE distinctions in ABAP CDS and ABAP SQL. Both follow the same syntax rules and provide the same functionality. The differences are mainly in formatting and editor coloring.
How are arithmetic expressions handled in ABAP CDS?
Arithmetic expressions in ABAP CDS can be used in the element list of a CDS view definition, following the same rules and restrictions as in ABAP SQL. The key restriction is that the division operator (/) is only allowed in floating point expressions. Numeric operands can be converted to FLTP using CAST for floating point expressions.
Provide an example of an arithmetic expression moved from ABAP SQL to a CDS view.
How do built-in functions in ABAP CDS compare to those in ABAP SQL?
Built-in functions in ABAP CDS are similar to those in ABAP SQL but have some differences, such as the handling of optional parameters. In ABAP CDS, all parameters for certain functions must be provided, even if they are optional in ABAP SQL.
Can you explain the use of conversion functions in ABAP CDS with an example?
Conversion functions in ABAP CDS transform data from one type to another. For example, the timestamp conversion function TSTMP_TO_DATS() in ABAP SQL has four parameters, two of which are optional. However, in ABAP CDS, all four parameters must be provided without explicit parameter names.
Why do some conversion functions have all parameters mandatory in ABAP CDS, unlike in ABAP SQL?
In ABAP CDS, the absence of named parameters necessitates providing all parameters explicitly, making optional parameters in ABAP SQL mandatory in ABAP CDS. This ensures that the function operates correctly within the CDS framework.
How is the DISTINCT addition used in ABAP CDS views?
In ABAP CDS views, DISTINCT is used to remove duplicates from the result set. It is placed directly after the SELECT statement and not as part of the element list in curly brackets.
define view ZDistinctView as select distinct from some_table {
column1,
column2
}
How are aggregations performed in ABAP CDS views?
Aggregations in ABAP CDS views use common aggregate functions such as AVG, SUM, MIN, and MAX. The as abap.fltp addition inside the parentheses specifies the numeric type for the result, and the AS addition is mandatory in CDS views.
define view ZAggregateView as select from sales_table {
key,
AVG(sales_amount) as avg_sales_amount,
SUM(sales_quantity) as total_sales_quantity
}
How does the GROUP BY clause function in ABAP CDS views?
The GROUP BY clause in ABAP CDS views lists all fields of the data source that appear in the field list outside of aggregations. This is similar to its use in ABAP SQL.
What quick fix does the CDS data definitions editor offer related to the GROUP BY clause?
The editor offers a quick fix to generate the GROUP BY clause, which is particularly useful when the element list is long or contains complicated expressions. It also provides a quick fix to adjust the GROUP BY clause after making changes to the element list.
How are joins used in ABAP CDS views?
Joins in ABAP CDS views combine data from multiple tables based on related columns. Different types of joins (INNER JOIN, LEFT OUTER JOIN, etc.) can be used.