Application Development and Automation 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: 
Read only

abap OO chain method call

Former Member
0 Likes
722

Hi Guys,

Is it possible to use such bolded statement in ABAP OO?

data: some_object type ref to dummy.

create object some_object.

<b>some_object->get_another()->method_of_another_object().</b>

Best regards,

Wojciech

Hi Guys,

Is it possible to use such bolded statement in ABAP OO?

data: some_object type ref to dummy.

create object some_object.

<b>some_object->get_another()->method_of_another_object().</b>

Best regards,

Wojciech

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
607

Hello Wojciech

I use frequently the interface IF_RECA_MESSAGE_LIST as message handler for my classes. The interface is defines as instance attribute (e.g. MO_MSGLIST).

At the beginning of the CONSTRUCTOR method I instantiate this interface:

  me->mo_msglist = cf_reca_message_list=>create( ).

In order to collect SYST messages I use the following method:

  me->mo_msglist->add_symsg( id_detlevel = '1' ).

However, if your bolded statement implies that instance <i>some_object</i> instantiates another object instance and <b>simultaneously</b> calls one of its methods I do not think this is (yet) possible.

Regards

Uwe

Read only

0 Likes
607

Hi,

I'm getting an reference in get_another to another object. This object already exists.

Regards,

Wojciech

Read only

0 Likes
607

Hello Wojciech

If I adjust my example to your logic then the coding would look like this:

" some_object->get_another() ==> cf_reca_message_list=>create( ) " returns instance

" method_of_another_object() ==> -add_symsg (of returned instance)

  cf_reca_message_list=>create( )->add_symsg( id_detlevel = '1' ).

Well, in this case I am convinced that is <b>not possible</b>.

Regards

Uwe

Read only

Former Member
0 Likes
607

I've checked it on two systems 6.4 and 7.0. On both application servers it's not possible to use more than one method in one statement. Access to internal reference is only available via public reference fields. Thank you for your involvement.

Best regards,

Wojciech