SAP CREATE OBJECT EXPLICIT ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• TYPE CREATE OBJECT

CREATE OBJECT, TYPE
Short Reference

ABAP_SYNTAX
CREATE OBJECT oref $[ area_handle$]
TYPE ${ class $[ parameter_list$] $}
$| ${ (name) $[ parameter_list$|parameter_tables $] $}.

What does it do?
Creation of an instance of an explicitly specified class. A concrete class that is more specific than or identical to the static type of the object reference variable oref can be specified. The reference variable oref can be a class reference variable or an interface reference variable. The name of the class can be specified as follows:
class Direct static specification as class.
(name) Specification as the content of a character-like data object name . The data object name must contain the name of the class in uppercase letters when the statement is executed. The class name in name can also be an absolute type name. 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 class is recognized as the used object.
Variable
BEGIN_SECTION ID CREATE-OBJECT-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-OBJECT-DYNAMIC-TYPE When the statement is executed, name is not evaluated until runtime (in both cases).
The class must be usable at the current position:
The addition CREATE of the class definition must allow objects to be created.
The package check must allow an object of a global class to be created.



Latest notes:

If the class is specified dynamically, the parameters can either be specified statically in parameter_list or dynamically in parameter_tables.
When a class is used, the instance operator NEW acts like the statement CREATE OBJECT oref TYPE class and can be used in general expression positions. The dynamic specification of name is not possible here.
NON_V5_HINTS
ABAP_HINT_END