Using Code Pushdown in ABAP SQL Flashcards
What are the two kinds of literals in ABAP SQL, and how are they specified?
text literals and number literals.
Text literals are specified within simple quotes, while number literals can be positive or negative whole numbers.
What types are literals in ABAP SQL, and how do they correspond to ABAP types?
Text literals in ABAP SQL are of type C (character), while number literals are of type I (integer). These types correspond to the types used in ABAP, where character literals are of type C and number literals are of type I.
What is the recommended practice for using literals in ABAP SQL, and why?
Instead of using literals directly, it’s recommended to define constants and use them inside ABAP SQL statements. This practice improves readability and provides access to more types than just character and integer. When using a constant in an ABAP SQL statement, the prefix “@” is mandatory.
How are constants used in ABAP SQL, and what prefix is mandatory when using them?
Constants are used in ABAP SQL by prefixing their name with “@”. This prefix is mandatory when using constants in ABAP SQL statements. For example, if a constant named “C_NUMBER” of type I with a value of 1234 is defined, it would be used in an ABAP SQL statement as “@C_NUMBER”.
What is the purpose of the CAST expression in ABAP SQL?
The CAST expression in ABAP SQL allows for explicit type conversions, unlike ABAP itself which supports implicit type conversions. It enables developers to convert data from one type to another in a structured manner.
What types of operands can be used for type conversion in the CAST expression?
The operands for type conversion in the CAST expression can include literals, fields from the data source, arithmetic expressions, predefined functions, and various other expressions.
What types can be specified as target types in the CAST expression?
Most predefined dictionary types, such as INT4, CHAR, DEC, FLTP, DATS, and others.
However, it’s not possible to use Dictionary Data elements as target types in ABAP SQL.
Are there any restrictions or limitations when using the CAST expression in ABAP SQL?
Yes, there are restrictions regarding the combination of source type and target type in the CAST expression. Some combinations are not supported at all, while others may work with limitations and could lead to runtime errors.
How are predefined types in the ABAP Dictionary mapped to specific ABAP types?
Predefined types in the ABAP Dictionary are mapped to specific ABAP types based on their definitions.
For example, the Dictionary type CHAR is mapped to ABAP type C, INT to type I, FLTP to type F, DEC to P, and so on.
Are there any Dictionary types that do not have a direct counterpart in ABAP?
Some Dictionary types, like MANDT, UNIT, and CUKY, are mapped to ABAP types C or P.
How is the length specified for Dictionary types DEC, QUAN, and CURR?
The length for DEC, QUAN, and CURR in the Dictionary is specified by the number of digits, while for ABAP type P, it’s specified by the number of bytes.
What does ABAP SQL’s case distinction provide?
a single value based on specified conditions, starting with “CASE” and ending with “END.”
What are the important restrictions when using division (/) in ABAP SQL arithmetic expressions?
The division operator (/) is only allowed in floating point expressions. Mixing floating point types with other numeric types in the same expression is not possible.
How can you ensure compatibility with floating point expressions in ABAP SQL?
You can use the CAST() function to convert any numeric operand to FLTP, ensuring compatibility within a floating point expression.
How can you ensure that a number literal, such as 100, is treated as a floating-point number in an arithmetic expression in ABAP SQL?
You can convert the number literal to type FLTP using the CAST() function. Alternatively, you can define a constant of type f with the value 100.0 and use it in the SQL expression.
What is the default display format for floating-point numbers in ABAP SQL?
Floating-point numbers in ABAP SQL are displayed in scientific notation by default.
What are the four numeric functions?
DIV( sql_exp1, sql_exp2 )
MOD( sql_exp1, sql_exp2 )
DIVISION( sql_exp1, sql_exp2, dec )
ROUND( sql_exp, pos)
What is the purpose of the operator && in ABAP?
In ABAP, the operator && allows you to combine char-like arguments into one long string.
How is the operator && used in ABAP SQL?
In ABAP SQL, the operator && can be used to perform concatenation operations directly on the database.
Why is it necessary to manually add blanks when using the operator && in ABAP SQL?
The operator && does not add separators of any kind, so if blanks are needed between concatenated values, they must be added manually.
Give a few examples for important string functions.
. Function CONCAT( sql_exp1, sql_exp2 ) concatenates two strings (without
blanks).
. Function CONCAT_WITH_SPACE( sql_exp1, sql_exp2, num ) does the same but inserts a specified number of blanks in the middle.
. Functions UPPER( sql_exp ) and LOWER( sql_exp ) transforms an argument to uppercase / lowercase.
. Function INITCAP( sql_exp ) works like LOWER( ) but transforms the first letter of each word to upper case.
. Functions LEFT ( sql_exp, num ) extracts the first num characters from a given argument.
. RIGHT( sql_exp, num ) does the same but starts from the right.
. Function SUBSTRING( sql_exp, pos, num ) extracts a given numberof characters, starting from a given position.
How does the CONCATENATE operator && behave with trailing blanks?
The CONCATENATE operator && ignores trailing blanks and only keeps a single blank if specified explicitly as ‘ ‘.
What types of functions are available for date, time, and timestamp information in ABAP SQL?
ABAP SQL offers both type-specific functions, which require input of a specific data type (e.g., DATS, DATN, TIMS, TIMN), and generic functions that can handle different types of input. Type-specific functions start with a prefix indicating the type they require, while generic functions have generic names.
What is the difference between TIMS and TIMN in ABAP?
TIMS and TIMN represent time data types in ABAP. TIMS stores time information as a character-like string in the format ‘HHMMSS’, while TIMN stores time information in the format preferred by the database.
How is TIMESTAMP data stored in ABAP?
TIMESTAMP stores time stamp information as a number without decimals, where each digit of the number represents the year, month, day, hours, minutes, and seconds.
What are the options for storing date information in a database field?
In ABAP, you can choose between DATS and DATN to store date information in a database field. DATS stores the date as a character of length 8 in the format ‘YYYYMMDD’, while DATN stores the information in the date type of the database, automatically converting it back to the 8-digits format when read with ABAP SQL.
Can you explain the difference between type-specific and generic functions?
Type-specific functions are designed to work with a specific data type, such as dates (DATS), times (TIMS), or timestamps (TIMESTAMPL). Generic functions, on the other hand, can handle different types of input and are not tied to a specific data type.
How can we use these functions in ABAP SQL (DATS, DATN, TIMS, TIMN)?
You can use these functions in SELECT statements to manipulate, validate, or extract information from date, time, or timestamp fields. For example, you can use the IS_VALID() function to check the validity of a date or timestamp, or to perform calculations based on date or time information.
What are some examples of conversion functions available in ABAP SQL?
DATS_FROM_DATN() converts from the DB-specific date representation (DATN) to the ABAP-specific char-like date format (DATS).
DATS_TO_DATN() performs the conversion from DATS to DATN.
TMSTMP_TO_DATS() converts a timestamp into a date field.
TMSTMP_TO_TIMS() converts a timestamp into a time field.
UNIT_CONVERSION() converts a quantity from a source unit to a target unit, such as kilometers to miles.
CURRENCY_CONVERSION() converts an amount in one currency to the same amount in another currency on a specific reporting date.