Using Code Pushdown in CDS Views Flashcards

1
Q

What are the benefits of using code pushdown in CDS views?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do SQL expressions in CDS views enhance database calculations?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What types of literals are supported in ABAP CDS?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does the CAST expression function in ABAP CDS compared to ABAP SQL?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the differences between simple and complex CASE distinctions in ABAP CDS and ABAP SQL?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are arithmetic expressions handled in ABAP CDS?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Provide an example of an arithmetic expression moved from ABAP SQL to a CDS view.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do built-in functions in ABAP CDS compare to those in ABAP SQL?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Can you explain the use of conversion functions in ABAP CDS with an example?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why do some conversion functions have all parameters mandatory in ABAP CDS, unlike in ABAP SQL?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is the DISTINCT addition used in ABAP CDS views?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are aggregations performed in ABAP CDS views?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does the GROUP BY clause function in ABAP CDS views?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What quick fix does the CDS data definitions editor offer related to the GROUP BY clause?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How are joins used in ABAP CDS views?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are unions used in ABAP CDS views?

A

Unions in ABAP CDS views combine the result sets of two or more SELECT statements. Each SELECT statement must have the same number of columns in the same order.

17
Q

What is a join in SQL, and how is it used in ABAP CDS?

A

A join in SQL combines two data sources into one result set, consisting of columns from both data sources. The rows are determined by the join type and the join condition (ON-condition). ABAP CDS supports the same join types as ABAP SQL, such as INNER JOIN, LEFT OUTER JOIN, and RIGHT OUTER JOIN.

18
Q

How does the syntax for joins differ between ABAP SQL and ABAP CDS?

A

In ABAP CDS, the period sign (.) is used as a separator between a field name and the data source or its alias, following the SQL standard. In ABAP SQL, the tilde sign (~) is used due to the period sign being a statement delimiter in ABAP. In ABAP CDS, the data source name is mandatory for all fields in the field list, while in ABAP SQL, it is only required when there are fields with the same name in different data sources.

19
Q

What are the prerequisites and rules for using UNION or UNION ALL in ABAP CDS views?

A

The prerequisites and rules for using UNION or UNION ALL in ABAP CDS views include:

The result sets must have the same number of elements.
Element pairs in the same position must have compatible data types.

Direct element names or alias names must match for each column in the element lists.

Key elements must match across all element lists.
Only the element list of the first SELECT statement can define element annotations.

The @Metadata.ignorePropagatedAnnotations: true annotation is mandatory to avoid conflicts.

20
Q

What are input parameters in CDS views, and why are they needed?

A

Input parameters in CDS views allow the consumer to provide additional information when retrieving data from the view. They are needed to influence calculations, specify dynamic values like target currencies for conversions, apply filters for aggregations, or ensure mandatory selection criteria. For example, a consumer might specify a target currency for a conversion or a date up to which revenue should be considered.

21
Q

How do you define input parameters in a CDS view?

A

Input parameters are defined by adding WITH PARAMETERS after the CDS view entity name. Parameters are specified in a comma-separated list, with each parameter typed using an elementary data type. The syntax includes the parameter name followed by a colon and the parameter type.

22
Q

How can input parameters be accessed within a CDS view definition?

A

Input parameters within a CDS view are accessed using the prefix $parameters followed by a period and the parameter name. They can be used in various positions such as the element list, case distinctions, expressions, functions, WHERE clauses, and filter conditions in path expressions.

23
Q

How are input parameters supplied when using a CDS view in ABAP SQL?

A

When using a CDS view with input parameters in ABAP SQL, the parameters are supplied using the equals sign (=) instead of the colon (:). Values can be provided using literals, ABAP constants, ABAP variables (host variables), or ABAP expressions (host expressions).

24
Q

How can system fields be accessed using CDS view parameters?

A

System fields can be accessed by defining input parameters in the CDS view and annotating them with @Environment.systemField. The ABAP runtime automatically supplies the parameter with the value of the related system field if no other value is provided by the consumer.

25
Q

What are session variables in ABAP CDS, and how are they used?

A

Session variables provide an alternative way to access system field values without defining input parameters. They are prefixed with $session. and can be used in various operand positions. However, they are only valid if the reading request originates from an ABAP system; otherwise, their values are undefined.

26
Q

Give a brief summary of Input Parameters

A

Input parameters in CDS views enable dynamic data retrieval and calculations.

Parameters are defined with WITH PARAMETERS and accessed with $parameters.<parameter_name>.</parameter_name>

ABAP SQL uses = to supply input parameter values.

System fields can be accessed by annotating parameters with @Environment.systemField.

Session variables offer a simpler alternative but are only reliable within ABAP system requests.

27
Q

Which of the following SQL techniques is available in ABAP SQL but NOT supported in ABAP CDS?

A
ORDER BY

B
UNION

C
DISTINCT

D
GROUP BY

A

A
ORDER BY

28
Q

Type conversions in ABAP CDS are performed with a CONV( ) expression.

A
True

B
False

A

B
False

You are right. Type conversions in ABAP CDS are performed with a CAST( ) expression.

29
Q

All built-in functions that you can use in ABAP SQL are also available in ABAP CDS.

A
True

B
False

A

B
False

There are built-in functions for string, date, and time processing, that are not supported in ABAP CDS.

30
Q
A