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: 

Instanciation of a business object in ABAP?

Former Member
0 Kudos

Hello,

I know that you can call the methods of business objects with BAPIs. But I want to instantiate a business object directly in the ABAP code. Does anybody have a code example for doing this?

In theory I think that I have first do define a reference variable of the objecttype of the buisness object. Than I have to call the Create-Methode of the business object and assign the returned object to the reference variable. Is this correct?

Thanks.

Regards, Lars.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Business objects are not really class which can be instaniated. They are more or less "documentation" of the business element(process) which may or may not have a BAPI tied to it. If that is the case, then the BAPI is the coding that you would need to call.

Regards,

Rich Heilman

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Business objects are not really class which can be instaniated. They are more or less "documentation" of the business element(process) which may or may not have a BAPI tied to it. If that is the case, then the BAPI is the coding that you would need to call.

Regards,

Rich Heilman

Former Member
0 Kudos

Hello,

INCLUDE <cntn01>.

DATA: l_object type swc_object.

DATA: lv_key(70) type c.

swc_container m_container.

SWC_CREATE_OBJECT l_object 'BUS2081' lv_key.

*WHERE bus2081 is any object type

*where lv_key is the key of the object

swc_call_method l_object 'DISPLAY' m_container.

where mcontainer is the methd container

0 Kudos

hai,

how do we capture the standard events in bussines objects.

like what we do the class i the class builder using

set handeler obj->method of object

cheers

0 Kudos

please create a new topic for this. Thx

Former Member
0 Kudos

Hello,

thank you for your quick responces. They helped me a lot.

Regards, Lars.

0 Kudos

if this is the solution do you want to be so kind to close the message and reward points.

thx,

Peter

0 Kudos

Lars,

Some more info to add to what Peter has already explained well.

If you are going to call a method that has parameters (like a Create method as you mentioned) you would need to create and populate the container as follows.


 swc_container wa_container.

   swc_set_element wa_container 'Element1'  'Value'.
   swc_set_table wa_container 'Element2'  Itab.

Also make sure you are not calling a dialog method in a background context!

Cheers,

Ramki Maley.