Name all the data objects in ABAP
Variables, Constants, and Literals
What is the difference between Variable, Constant, and Literal data objects?
Variables:
>Data object with content that can change during runtime.
>identified by a name.
Constant:
>Value is hard coded in source code.
>identified by name
Literals:
>Value is hard coded in source code.
>Anonymous (no name)
Keyword to declare a variable in an ABAP program?
Give syntax for declaration of variables.
A variable in an ABAP program is declared with keyword DATA.
Syntax:
DATA <variable> TYPE <type> [ VALUE <starting_value> ].</starting_value></type></variable>
Example:
DATA my_var1 TYPE i.
DATA my_var1 TYPE string.
DATA my_var1 TYPE string VALUE ‘Hello World’.
Keyword to declare a constant in an ABAP program?
Give syntax for declaration of constants.
In ABAP, you declare a constant using keyword CONSTANTS.
( A CONSTANT statement consists of the same parts as a DATA statement. The only difference is, that the VALUE addition is mandatory.)
Syntax:
CONSTANTS <variable> TYPE <type> [ VALUE <starting_value> ].</starting_value></type></variable>
Name three types of data objects in ABAP.
Variables, Constants, and Literals
What is the difference between Variables, Constants, Literals?
Variables:
>Value may change during runtime
>Identified by a name
Constants:
>Value hard-coded in source code
>Identified by a name
Literals:
>Value hard-coded in source code
>Anonymous (no name)
Give the keywords to declare Variables and Constants.
Give statement examples of these keywords.
Variables in ABAP are declared with keywords ‘DATA’
i.e:
DATA <variable_name> TYPE <type> [VALUE <starting_value> ].</starting_value></type></variable_name>
Constants in ABAP are declared with keyword ‘CONSTANTS’
i.e:
CONSTANTS <variable_name> TYPE <type> [VALUE <starting_value> ].</starting_value></type></variable_name>
List the sources of ABAP Data Types.
What are literals used for?
Literals are used to define non-initial values for constants and non-initial starting values for variables.
List and describe the different types of literals.
In a value assignment the type of the source expression and the type of the target variable can be different. If that is the case, the runtime attempts in a type conversion.
Why should type conversions be avoid, if possible?
Values with type conversions require more runtime than value assignments with identical types.
Some combinations of source type and target type can lead to runtime errors. If, for example, the target variable has a numeric type l and the source expression has a character like type, then the runtime will raise an error if it cannot translate the text into a number.
Some combinations of source type and target type do not cause runtime errors but can lead to a loss of data. If, for example, source and target are of both of type C but the type of the target variable is shorter. Then the runtime simply truncates the value of the source.
What is the CLEAR statement used for?
Give syntax example if this statement.
The CLEAR statement is used to reset a variable to its type-specific initial value.
Syntax:
CLEAR <variable_name>.</variable_name>
Examples:
DATA my_var1 TYPE i.
DATA my_var2 TYPE i VALUE 1234.
DATA my_var3 TYPE string.
my_var1 = my_var2.
my_var3 = ‘HELLO WORLD’
CLEAR my_var1. (Value is reset to 0)
CLEAR my_var2. (Value is reset to 0)
CLEAR my_var3. (String is now empty again).
What is an inline declaration?
Give example.
It is declaring a variable where you also fill it with data.
Explicit Declaration:
DATA my_var1 TYPE string.
DATA my_var2 TYPE i.
my_var1 = ‘HELLO WORLD’
my_var2 = 17
Inline Declaration:
DATA(my_var1) = ‘HELLO WORLD’
DATA(my_var2) = 17
What are basic features of the ABAP Language?
What does a data object represent in ABAP?
Represents a reserved section of the program memory.