CREATE OBJECT statement in ABAP programming is used for creating an instance of the class or object.
CREATE OBJECT <obj>
CREATE OBJECT <obj> <class>
Here the second variation of CREATE OBJECT is for calling external objects in OLE2 Automation. We should use reference variables point to the created objects. We cannot address objects directly.
The main additions used with this statement
- area_handle addition: By default the created instance of the object will be stored in an internal session of the current program and will be deleted once it no longer referenced by any reference variables. We can use the addition area_handle with the CREATE OBJECT statement for making the object as shared.
- TYPE addition: It is used for specifying the class.
- parameter_list addition: it is used for specify the values for non-optional parameters.
- NO FLUSH addition : (used for object in OLE2 Automation)Using this the calls from automation methods are collected in the automation buffer
- QUEUE-ONLY addition: (used for object in OLE2 Automation)The effect of this addition is that during the flush, the created object is not transferred as a return value using methods called by CALL METHOD OF to the specified ABAP data object
The main runtime errors are
Return values in the system field SY-SUBRC
- SY-SUBRC=0 (Successfully generated the object)
- SY-SUBRC=1 (SAPGUI communication error)
- SY-SUBRC=2 (SAPGUI function call error)
- SY-SUBRC=3 (Error in OLE-API call)
- SY-SUBRC=4 (Called object is not registered)
Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes