CREATE OBJECT 

The ABAP key word CREATE OBJECT generates an object of the class "class".

Basic form:

CREATE OBJECT obj class.

     

Addition:

LANGUAGE langu

     

To address an OLE Automation Server (e.g. EXCEL) from ABAP, the server must be registered with SAP. The transaction SOLE (see Registering External Applications in R/3) allows you to assign an automation server to a class.

The CREATE statement generates the initial object of this class and this can be processed further with the related key words. The return code value of SY-SUBRC indicates the result of the generation. The return code value can be as follows:

Object successfully generated.

SAPGUI communication error.

SAPGUI function call error. The frontend ports of SAP’s OLE implementation modules are implemented only under Windows and Apple Macintosh.

The OLE-API call resulted in an error - possibly a storage space problem.

The object is not registered with SAP.

The addition LANGUAGE determines the language chosen for method and attribute names of the object class. If no specification is made, English is the default.

CREATE OBJECT belongs to a group of key words that allows you to process external objects with ABAP. At present, only the object model OLE2 is supported, i.e. all objects must be of type OLE2_OBJECT. This type and other necessary data are defined in the INCLUDE module OLE2INCL.

Generate an EXCEL object.

INCLUDE OLE2INCL.
DATA EXCEL TYPE OLE2_OBJECT.
CREATE OBJECT EXCEL 'Excel.Application'.

Related topics are SET PROPERTY, GET PROPERTY, CALL METHOD and FREE OBJECT.