SAP DATA OPTIONS ABAP Statements

Get Example source ABAP code based on a different SAP table
  



DATA - data_options

Short Reference

ABAP_BASIC_FORM_7 ... [ VALUE val|{IS INITIAL} ]
[ READ-ONLY ].

ABAP Addition
1 ... VALUE val|{IS INITIAL}
2 ... READ-ONLY

What does it do? The additions VALUE and READ-ONLY are specifically for data objects. They differentiate the DATA from the TYPES syntax.



Latest notes:As well as the VALUE and READ-ONLY additions,
the syntax also allows the obsolete addition COMMON PART.
• VALUE DATA
• IS INITIAL DATA
• VALUE CLASS-DATA
• IS INITIAL CLASS-DATA
• VALUE STATICS
• IS INITIAL STATICS
• VALUE CONSTANTS
• IS INITIAL CONSTANTS

ABAP Addition

What does it do? The addition VALUE can be used to define (for all forms of the variable declaration) a start value val for the content of the variable. This is used to initialize the variable when created before LOAD-OF-PROGRAM. The VALUE addition is not allowed in the declaration part of an interface for the DATA statement.

The start value val can either be specified as a literal or as a predefined constant. Where constants are involved, rather than their actual values being used, they function like the literal specified after VALUE when the constant is declared. A check is usually performed to verify if the length of the specified value matches the data type. Any deviations result in a warning from the syntax check. If the data type of the literal does not match the data type of the declar ation, it is usually converted in accordance with the conversion rules for elementary data types.
INTHINT A ... TYPE x LENGTH 2 VALUE 1234 gives another
INTHINT result then ... TYPE xstring VALUE 1234!
INTHINT In the latter case 1234 works like '1234'.

Without the VALUE addition, or if IS INITIAL is specified, the content is set to an 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.

The VALUE addition is possible for all data types, in particular for the deep types (strings, reference types, table types, or structured types with deep components, including boxed components). A start value val, however, can only be specified for the ABAP types string and xstring. Otherwise, only IS INITIAL is possible. IS INITIAL is also the only possible start value for structures with components that are not purely character-like and flat.

ABAP_PGL Specifying Start Values Appropriate to the Type

Latest notes:A start value should be specified according to type. In particular, no longer values should be specified and, in the case of certain data types such as d and t, the length must match exactly.
If numbers with decimal places are specified or if, in the scientific notation with mantissa, an exponent is used as a start value for data objects of the data types p or f, there are no literals for these numbers. Instead, the character literals must be specified with the appropriate content. These are then converted into the numeric data type in accordance with the conversion rules for elementary data types. The same applies to by te-like data objects.
The value operator VALUE can also be used to construct the content of complex data objects (structures, internal tables).
• READ-ONLY DATA
• READ-ONLY CLASS-DATA

ABAP Addition

What does it do? This addition is always possible in the public visibility area of a class or in an interface. This addition makes an attribute declared using DATA readable from outside of the class, but can only be changed using methods of the class or its subclasses. This addition is ignored by the friends of the class.

A class attribute defined using READ-ONLY can be used outside of the class, its friends, and subclasses only at reader positions in ABAP statements.

Latest notes:The declaration of attributes using the addition READ-ONLY does not prevent methods of the class from passing references to these attributes externally as reference variables or field symbols and therefore making the attributes modifiable outside of the class.
The addition READ-ONLY is always recommended if attributes need to be invisible, but a GET method for every read access is to be avoided.

Return to menu