Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

GetObject in ABAP language

stefan_schnell
Active Contributor
0 Kudos

Hello community,

to create a new COM object I use the command CREATE OBJECT in ABAP. Is it possible to use an existing COM object on the presentation server? Other programming languages offers the command GET OBJECT to return a reference to an existing object. Is there an equivalent in ABAP?

Thanks for hints and tips.

Cheers

Stefan

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

If you mean using OLE, yes there is such a way in ABAP. Search for term +CREATE OBJECT ole + .

Also nice references how to import various controls from outside SAP [Using .Net Windows Controls in the ABAP Control Framework|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/754] [original link is broken] [original link is broken] [original link is broken] [original link is broken]; and [Using Classic ActiveX Controls in the ABAP Control Framework|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/995] [original link is broken] [original link is broken] [original link is broken] [original link is broken];

Regards

Marcin

4 REPLIES 4

arseni_gallardo
Active Participant
0 Kudos

No there is not. If you are going to write a Z class you can achieve the same functionality by using the Singleton pattern ([http://en.wikipedia.org/wiki/Singleton_pattern]). In ABAP you can achieve more or less like this:


CLASS lcl_test DEFINITION   CREATE PROTECTED .

  PUBLIC SECTION.
    CLASS-METHODS get_instance
     RETURNING
       value(re_instance) TYPE REF TO lcl_test.

  PROTECTED SECTION.
    CLASS-DATA: my_instance TYPE REF TO lcl_test.
ENDCLASS.                    "lcl_test DEFINITION

CLASS lcl_test IMPLEMENTATION.
  METHOD get_instance.
    IF my_instance IS NOT BOUND.
      CREATE OBJECT my_instance.
    ENDIF.
    re_instance = my_instance.
  ENDMETHOD.                    "get_instance
ENDCLASS.                    "lcl_test IMPLEMENTATION

0 Kudos

Hello Arseni,

thanks for your answer and your snippet to simulate GetObject in ABAP.

Cheers

Stefan

MarcinPciak
Active Contributor
0 Kudos

If you mean using OLE, yes there is such a way in ABAP. Search for term +CREATE OBJECT ole + .

Also nice references how to import various controls from outside SAP [Using .Net Windows Controls in the ABAP Control Framework|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/754] [original link is broken] [original link is broken] [original link is broken] [original link is broken]; and [Using Classic ActiveX Controls in the ABAP Control Framework|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/995] [original link is broken] [original link is broken] [original link is broken] [original link is broken];

Regards

Marcin

stefan_schnell
Active Contributor
0 Kudos

Hello community,

here is a solution for this problem.

Cheers

Stefan