Skip to Content
0
Sep 12, 2007 at 05:45 PM

Chained method calls

62 Views

Hello,

In Java it's possible to use in a single call the returning reference of a given method as the source of another call. As this:

wdComponentAPI.getApplication().getName()

Now, if I want to do the same in ABAP, so far i haven't found a way other than declaring all the intermediate reference variables and calling one method after another, as in this code, even though the only variable i'm interested at keeping is l_name:

  DATA: l_name TYPE string,
        l_comp TYPE REF TO if_wd_component,
        l_appl TYPE REF TO if_wd_application,
        l_appl_info TYPE REF TO if_wd_rr_application.

  l_comp = wd_comp_controller->wd_get_api( ).
  l_appl = l_comp->get_application( ).
  l_appl_info = l_appl->get_application_info( ).
  l_name = l_appl_info->get_name( ).

Isn't it possible to use a similar shorter form as the used in Java with ABAP? I've tried with this:

l_name = wd_comp_controller->wd_get_api( )->get_application( )->get_application_info( )->get_name( ).

but it doesn't pass the syntax check.

Many thanks