What is Constants Statement
A constant is almost identical to a variable except that its value cannot be changed. To define one, you use the constants statement.
Use a constant when you need to include the same literal multiple times in a program. You can define a constant with the same value as the literal and use the constant in the body of the program in place of the literal. Later, if you need to change the value of the literal, you can simply change the value of the constant, causing its value to be updated wherever it is used in the program.
ABAP/4 has one pre-defined constant: SPACE. It is a constant having a value equal to spaces. You can use it in place of the literal ‘ ‘.
Syntax for the CONSTANTS Statement
The following code demonstrates the syntax for defining a constant. It is similar to the data statement; however, the addition value is required. In all other ways, constants conform to the same rules as variables defined using the data statement.
constants c1[(l)] [type t] [decimals d] value ‘xxx’.
or
constants c1 like cv value ‘xxx’.
where:
- c1 is the name of the constant.
- cv is the name of a previously defined constant or variable, or is the name of a field that belongs to a table or structure in the Data Dictionary.
- (l) is the internal length specification.
- t is the data type.
- d is the number of decimal places (used only with type p).
- ‘xxx’ is a literal that supplies the value of the constant.
Popularity: 4% [?]






