SAP CREATE DATA BUILT IN ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• LENGTH CREATE DATA
• DECIMALS CREATE DATA

CREATE DATA, TYPE abap_type
Short Reference

ABAP_SYNTAX
CREATE DATA dref $[ area_handle$]
TYPE ${abap_type$|(name)$}
$[LENGTH len$] $[DECIMALS dec$].

What does it do?
Creation of a data object with an explicitly specified data type. For the data type, all built-in data types , apart from b and s, can be used that are more specific than the static type of dref or are identical to it. The name of the type can be specified as follows:
abap_type Direct static specification as abap_type.
(name) Specification as the content of a character-like data object name without case-sensitivity. The following can be specified for name:
Literal or constant
If the data object name is specified as a character literal or as a constant, it can be evaluated statically and the specified type is recognized as the used object.
Variable
BEGIN_SECTION ID CREATE-DATA-DYNAMIC-TYPE
If the data object name is specified as a variable, it is specified only dynamically and the content is not evaluated statically.
END_SECTION ID CREATE-DATA-DYNAMIC-TYPE When the statement is executed, name is not evaluated until runtime (in both cases).
For the ABAP types c, n, p, and x, the length of the data type dtype can be determined by specifying a numeric data object len after the addition LENGTH, which, when the statement is executed, contains a value within the length range specified for the respective type. If the addition LENGTH is not specified, the standard length from the table is used. For all other ABAP types, the length is determined by the value in the table and the addition LENGTH cannot be specified.
For the ABAP type p, the number of decimal places can be determined by specifying a numeric data object dec after the addition DECIMALS. If DECIMALS is specified, the same applies as to the statement TYPES. If the addition DECIMALS is not specified, no decimal places are created.
BEGIN_SECTION VERSION 5 OUT For the decimal separator to be respected in operations with packed numbers, the program property fixed point arithmetic must be set. Otherwise, the addition DECIMALS only affects the formatting of dynpros and the statement WRITE $[TO$]. For all other ABAP types and if name is specified dynamically, the addition DECIMALS is not allowed.
END_SECTION VERSION 5 OUT



Latest notes:

If a data type abap_type is used, the instance operator NEW acts like the statement CREATE DATA dref TYPE abap_type and can be used in general expression positions. The dynamic specification of name is not possible here.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Creation of an anonymous data object of the type of a packed number with length specification and decimal places.
ABEXA 00156
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Creating Elementary Data Objects
ABAP_EXAMPLE_END

Return to menu