Reading Data from the Database Flashcards
What is a key feature of SAP S/4HANA’s architecture?
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.
What is a key in a database table?
A key is a combination of values that uniquely identifies each row in a table.
How does SAP keep client-specific data separate?
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.
What are the main clauses of a SELECT statement in ABAP SQL?
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.)
What does the FROM clause in a SELECT statement specify?
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.
What is the purpose of the WHERE clause in a SELECT statement?
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.
Why is it important to use the WHERE clause in a SELECT statement?
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.
What is the significance of system field SY-SUBRC in ABAP SQL?
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 does ABAP SQL handle an empty result set from a SELECT statement?
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.
What value does system field SY-SUBRC contain if an error is returned?
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.
What is ABAP Core Data Services (ABAP CDS)?
ABAP CDS is an infrastructure for defining and consuming semantically rich data models in ABAP using a CDS DDL.
What are the main components of a CDS View definition?
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.
What are annotations used for in CDS View definitions?
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.
What is the main part of a CDS View definition?
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 are associations defined in CDS View definitions?
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’