2016 Jan 07 4:19 PM
How to get static Values in ABAP?
a)
apparently there is no "class-constants" in ABAP
e.g. so there is no:
class zmyclass definition final.
public section.
class-constantsb)
so using instead class-data and read only
e.g.
class zmyclass definition final.
public section.
class-data c_example type char2 value 'eg' read-only.
yet, when zmyclass is a global class,
while this works:
REPORT Z1.
PARAMETERS p_1 type char2 default zmyclass=>C_EXAMPLE.
this gives Syntax Error (Field C_EXAMPLE is unkown.) ...
REPORT Z1.
constants c_1 type char2 value zmyclass=>C_EXAMPLE.
2016 Jan 07 4:56 PM
Hi,
it's the other way around.
There is no "instance"-CONSTANTS in ABAP. As documented, the usage of CONSTANTS in the declaration part of a class defines a static attribute (CONSTANTS is implicitly the same as "CLASS-"CONSTANTS).
If you use CONSTANTS instead of CLASS-DATA in your global class, you can use the constant of the global class behind VALUE in your program.
Horst
Hi,
it's the other way around.
There is no "instance"-CONSTANTS in ABAP. As documented, the usage of CONSTANTS in the declaration part of a class defines a static attribute (CONSTANTS is implicitly the same as "CLASS-"CONSTANTS).
If you use CONSTANTS instead of CLASS-DATA in your global class, you can use the constant of the global class behind VALUE in your program.
Horst
2016 Jan 07 4:56 PM
Hi,
it's the other way around.
There is no "instance"-CONSTANTS in ABAP. As documented, the usage of CONSTANTS in the declaration part of a class defines a static attribute (CONSTANTS is implicitly the same as "CLASS-"CONSTANTS).
If you use CONSTANTS instead of CLASS-DATA in your global class, you can use the constant of the global class behind VALUE in your program.
Horst
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |