ABAPCREATE_OBJECT - CREATE OBJECT
General Data in Customer Master ROGBILLS - Synchronize billing plansThis documentation is copyright by SAP AG.
CREATE OBJECT
Syntax Forms
Defining a Class Implicitly
1. CREATE OBJECT oref [area_handle][parameter_list].
Defining a Class Explicitly
2. CREATE OBJECT oref [area_handle]
TYPE { class [parameter_list] }
| { (name) [parameter_list|parameter_tables] }.
Effect
The CREATE OBJECT statement creates an instance of a class or object and assigns the object referenceto the reference variable oref. Directly after the object has been created, the instance constructor of the class is called.
By default, the object is created in the internal session of the current program and remains there as long as it is needed. When it is no longer referenced by any reference variable, it is deleted from thegarbagecollector. You can use the area_handle addition to create the object as ashared object.
The reference variable oref must be declared as an object reference variable. Instance components of an object created using CREATE OBJECT can only be accessed using object reference variables (seeData Objects in Operand Positions).
You can use the TYPE addition to specify the class of the created object. The static type of the object reference variable must be more general than or identical to the class of the created object, in accordance with the rules forAssignments Between Object Reference Variables.
With the additions parameter_listand parameter_tables,the compulsory input parameters of the first explicitly implemented instance constructor that is onthe path of the inheritance tree from the classed instanced to the root object object must be supplied. The non-class-based exceptions of the instance constructor can be assigned values using these additions.
If an exception that can be handled occurs in the runtime environment during the creation of the object,it is not created and the object reference variable oref is initialized. If, after the object has been created, an exception that can be handled occurs in the instance constructor of the class or amessageis sent using MESSAGE RAISING, the created object is deleted and the object reference oref is initialized.
Return Value
If the CREATE OBJECT statement is executed successfully,sy-subrc is set to 0. Values other than 0 are set by specifying EXCEPTIONS in parameter_spec when non-class-based exceptions of the instance constructor are handled.
Note
You can only create an instance of a class where permitted by the CREATE addition of the CLASS DEFINITION statement.
Exceptions
Catchable Exceptions
- Cause: You tried to instantiate an abstract class
Runtime Error: CREATE_OBJECT_CLASS_ABSTRACT (catchable) - Cause: The class specified in the TYPE addition does not exist
Runtime Error: CREATE_OBJECT_CLASS_NOT_FOUND (catchable) - Cause: You tried to instantiate a private class externally
Runtime Error: CREATE_OBJECT_CREATE_PRIVATE (catchable) - Cause: You tried to instantiate a protected class externally
Runtime Error: CREATE_OBJECT_CREATE_PROTECTED (catchable)
Non-Catchable Exceptions
- Cause: You must specify a reference as the target variable
Runtime Error: CREATE_OBJECT_NO_REFTYPE:
ABAP Short Reference RFUMSV00 - Advance Return for Tax on Sales/Purchases
This documentation is copyright by SAP AG.
Length: 6665 Date: 20120522 Time: 042357 triton ( 209 ms )






