SAP DOBJ GENERAL Get Example source ABAP code based on a different SAP table
SAP Help
General Properties of Data Objects ITOC
Creating and Addressing Data Objects There is a distinction between:
Named data objects> that are declared statically using a data-defining statement and are addressed using a name. The typical data-defining statement is DATA>>. Named objects are created at the start of the lifetime of a context (a program, class, object, or procedure) by the ABAP runtime framework and live for as long as their context exists. Anonymous data objects> that are created in the heap> by the statement CREATE DATA>> or the instance operator NEW>> and are addressed using data reference variables >. Anonymous data objects exist in the ABAP_ISESS > of the program in which they were created and are subject to garbage collection>. Literals> that are defined in the source code of a program and are fully defined by their value. In addition to data objects declared in programs, there is a set of built-in data objects> that can always be accessed in ABAP programs. Furthermore, some statements create data objects implicitly that are then available for special purposes. BEGIN_SECTION VERSION 5 OUT Examples are sum( )>>, cnt( )>> in group level processing for extracts> and title>> when selection screens> are created. END_SECTION VERSION 5 OUT ABAP_EXAMPLE_VX5 In the following example, dref> is a named data object whose content points to an anonymous data object after the instance operator NEW>> is used. 555> is a numeric literal. ABEXA 00979 ABAP_EXAMPLE_END Data Types of Data Objects Every data object has a specific data type, and every data object occupies memory for the data. The data type of a data object is defined either with reference to a standalone data type> or as a bound data type> when the data object is created. The data type of a data object is always defined uniquely and cannot be changed at runtime of a program. In the case of anonymous data objects, this data type determines the dynamic type> of the associated reference variables. ABAP_EXAMPLE_VX5 In the following example, c_20> is a standalone data type used to declare the data object text1>. The data object text2>, on the other hand, has a bound data type. ABEXA 00980 ABAP_EXAMPLE_END Variable and Constant Data Objects Variable data objects are distinguished from constant data objects in how they can change. Variables> can change their value at runtime. Constants> always keep their initial value. Literals> and text symbols> are also constant. Input parameters> in procedures> usually cannot be changed if this would cause the assigned actual parameter> to be changed. Immutable variables> are a special kind of variables. A value can be assigned to an immutable variable at exactly one write position> of a context>. Immutable variables are declared inline with the declaration operator FINAL(var)>>. Although one and the same declaration can appear only one time in a context, it can be processed multiple times - for example in a loop - and different values can be assigned then. Latest notes: Immutable variables can improve the robustness of programs whenever a variable is filled at a write position only once and after that only read accesses occur. NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 In the following example, true> and false> are constants that can be assigned to the variable flag>. TYPES bool TYPE c LENGTH 1. CONSTANTS: true TYPE bool VALUE 'X', false TYPE bool VALUE ' '. DATA flag TYPE bool. IF ... flag = true. ELSE. flag = false. ENDIF.> ABAP_EXAMPLE_END Static and Dynamic Data Objects Static data objects, for which all technical properties must be defined when declared, are distinguished from dynamic data objects, whose memory requirement or size is not defined until runtime. Strings> and internal tables> are dynamic data objects. The length of a string is 0 after declaration and changes at runtime depending on the content assigned to it. Internal tables do not contain any lines after their declaration. There can be any number of lines and the number is defined dynamically at runtime when the internal table is filled. Structures that contain dynamic components are also dynamic data objects. Latest notes: See also Maximum Size of Dynamic Data Objects>. NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 In the following example, text_field> is a static data object and text_string> is a dynamic data object. When abcde> is assigned to text_field>, it is truncated from the tenth character. text_string> is given all characters and has the same length as sy-abcde> after the assignment. ABEXA 00981 ABAP_EXAMPLE_END Flat and Deep Data Objects All static data objects except reference variables are flat. Their content corresponds to the actual work data. Dynamic data objects and reference variables are deep, and they contain references that refer to the actual content. The handling of references is implicit for dynamic data objects (strings and internal tables), and explicit for reference variables. Structures that do not contain any deep components are flat structures. Structures that contain at least one deep component are deep structures. Latest notes: See also Memory Management of Deep Objects >. NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 In the following example, struct1> is a flat structure and struct2> is a deep structure. In the flat structure, character-like components are stored consecutively in the memory and substring access> is possible. In the deep structure, the components contain pointers to the actual data and substring access is not possible. ABEXA 00982 DATA(section2) = struct2+3(4). 'Syntax error> ABAP_EXAMPLE_END