Reading Data from the Database Flashcards

1
Q

What is a key feature of SAP S/4HANA’s architecture?

A

SAP S/4HANA is built on the SAP HANA in-memory database platform, enabling real-time data processing and analytics. This architecture ensures faster data access, processing, and analysis compared to traditional disk-based databases.

Now only the SAP HANA database is supported. Previous versions supported Oracle, Microsofts and IBM databases as well.

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

What is a key in a database table?

A

A key is a combination of values that uniquely identifies each row in a table.

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

How does SAP keep client-specific data separate?

A

SAP uses client-specific tables with a client field (e.g., CLIENT or MANDT) as the first key field. ABAP SQL ensures operations only manipulate data from the current client.

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

What are the main clauses of a SELECT statement in ABAP SQL?

A

The main clauses of a SELECT statement in ABAP SQL are:

FROM: Specifies the data source from which to read (database table or view).

FIELDS: Lists the columns of the database table to read, separated by commas.

WHERE: Specifies conditions for selecting rows from the table.

INTO: Specifies the variables in the ABAP program where the data should be placed.

Example:

SELECT SINGLE

FROM /dmo/connection

FIELDS airport_from_id

WHERE carrier_id = ‘LH’
AND connection_id = ‘0400’

INTO @airport_from_id.

(The at sign (@) identifies airport_from_id as the name of an ABAP data object. It is mandatory for all variables and constants that you use in an ABAP SQL statement.)

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

What does the FROM clause in a SELECT statement specify?

A

The FROM clause specifies the data source from which to read, which can be a database table or view. It allows combining data from multiple sources in the same SELECT statement.

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

What is the purpose of the WHERE clause in a SELECT statement?

A

The WHERE clause specifies conditions for selecting rows from the table. It allows filtering data based on specified criteria, such as specific values or combinations of values in certain columns.

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

Why is it important to use the WHERE clause in a SELECT statement?

A

The WHERE clause helps narrow down the data retrieved from the table, reducing the workload on the database and improving performance. Without a WHERE clause, all data from the table is retrieved, which can cause serious performance problems and should be avoided.

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

What is the significance of system field SY-SUBRC in ABAP SQL?

A

System field SY-SUBRC indicates the success or failure of a statement in ABAP SQL. A value of 0 indicates success, while a value of 4 indicates an empty result set returned by the database.

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

How does ABAP SQL handle an empty result set from a SELECT statement?

A

ABAP SQL does not touch the target variable after the INTO clause if the database returns an empty result set. This means the target variable is not initialized, even in case of an error.

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

What value does system field SY-SUBRC contain if an error is returned?

A

If an error is returned, SY-SUBRC contains a value greater than 4, typically indicating the type of error encountered during the execution of the statement.

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

What is ABAP Core Data Services (ABAP CDS)?

A

ABAP CDS is an infrastructure for defining and consuming semantically rich data models in ABAP using a CDS DDL.

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

What are the main components of a CDS View definition?

A

A CDS View definition contains reusable SQL logic for data manipulation, including projections, calculations, aggregations, joins, unions, and associations to reflect relationships within the data model. Annotations are used for semantic enrichment.

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

What are annotations used for in CDS View definitions?

A

Annotations, indicated by the @ sign, are used to semantically enrich the view definition for consumers. Entity annotations define metadata for the view entity as a whole, while element annotations define metadata for individual elements of the view.

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

What is the main part of a CDS View definition?

A

The main part of a CDS View definition is the DEFINE VIEW ENTITY statement, which specifies the name of the view entity and the data source, typically a database table or another CDS View.

Example:
define view entity /DMO/I_Connection as select from /dmo/connection as Connection
{
key Connection.carrier_id as AirlineIdD,

}
key defines this element as a key field of the CDS View entity.

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

How are associations defined in CDS View definitions?

A

Associations in CDS View definitions are defined using the association addition, linking the view entity to another CDS view entity. These associations become available for consumers of the view by adding them to the element list, a process referred to as exposing the association.

Metadata for the CDS View Entity, written before “define view”:
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText. label: ‘Connection View - CDS Data Model’

Metadata for a view element. written within the curly brackets:
@objectModel.text.association: ‘ Airline’

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

How can you open the Data Preview for a CDS entity?

A

right-click anywhere in the data definition and choose Open With > Data Preview. Alternatively, place the cursor in the database table definition and press Ctrl + F8.

17
Q

What functions are available in the Data Preview tool for CDS entities?

A

you can sort, filter, and adjust the display of the data returned by the CDS entity.

18
Q

How can you display related data using associations in the Data Preview tool?

A

right-click on a row in the display, choose Follow Association from the context menu, and select the desired association from the list.

19
Q

How can you find all CDS Views that use a specific database table as a source?

A

open the definition of the database table, right-click anywhere in the source code, and choose Get Where-used List from the context menu. Alternatively, press Ctrl + Shift + G, or use the corresponding button from the toolbar. Apply filters in the Where-used List to refine the search results if needed.

20
Q

What are the advantages of using a CDS view entity as a data source in ABAP SELECT statements?

A

The advantages include:

Re-use of SQL logic contained in the CDS view.

Concise and easy-to-read access to related data using associations.

Improved readability of view and element names compared to technical database table and field names.

21
Q

How are CDS view entities used in ABAP SELECT statements?

A

CDS view entities are used as data sources instead of directly reading from database tables. The names used in the FIELDS clause and WHERE conditions are the alias names of the view elements.

22
Q

What is a path expression in the context of CDS view usage in ABAP SELECT statements?

A

A path expression is used to access elements from associated CDS view entities. It involves using the backslash () as a mandatory prefix for association names.

Example:
SELECT SINGLE
FROM /DMO/I_CONNECTION
FIELDS DestinationAirport, _Airline-Name

DestinationAirport is the view element name
_Airline_Name is the path expression to read name of associated airline

23
Q

You are writing a SELECT statement that reads data using a CDS view entity. In the field list, you want to read a field from an associated table. What do you use?

A

A path expression

24
Q

Which are valid data sources for a CDS view entity?

A

Another CDS view entity, A database table

25
Q

Which part of SQL is represented by ABAP SQL?

A

Data Manipulation Language

26
Q

What is the correct sequence of clauses in the SELECT SINGLE statement?

A

SELECT SINGLE FROM… FIELDS… WHERE… INTO