... [ VALUE val|{IS INITIAL} ]
[ READ-ONLY ].
1. ... VALUE val|{IS INITIAL}
2. ... READ-ONLY
The two additions VALUE and
READ-ONLY are specifically for data objects. They differentiate the DATA from the TYPES syntax.
In addition to the VALUE and
READ-ONLY additions, the syntax also allows the obsolete addition COMMON PART.
... VALUE val|{IS INITIAL}
Using the VALUE addition, you can define - for all forms (since Release 6.40) of the variable declaration - a start value val for the contents of the variable. This is used to initialize the variable at the time of its creation before the time LOAD-OF-PROGRAM. In the declaration part of an interface, the VALUE addition is not allowed for the DATA statement. The start value val can either be specified as a literal or as a constant already defined. If the data type of the specified start value does not match the data type of the declaration, it is converted according to the conversion rules for elementary data types. No start value must be specified for structures with numeric components.
Without the VALUE addition, or if IS INITIAL is specified, the content will be set to initial value. The initial values are dependent on the data type.
In the case of initial structures, the components are initial; initial reference variables contain the
null reference that does not point to an object, and initial internal tables do not contain any rows.
... READ-ONLY
This addition is solely possible in the public visibility area of a class or in an interface. It has the effect that an attribute declared using DATA is readable from an external point, but can only be changed using methods of the class or its subclasses.
A class attribute defined using READ-ONLY can be used outside of the class only at read positions in ABAP statements.
The declaration of attributes with the READ-ONLY addition does not prevent methods of the
references class for these attributes from getting outside in the form of
reference variables or
field symbols, in which case the attributes could thus be changed outside of the class.