Skip to Content
0
Former Member
Dec 07, 2011 at 09:31 AM

Calling a method in ABAP OO via ->

31 Views

Hi,

I've seen that there are two ways to call a method (correct me if I'm wrong):

the first is by using CALL METHOD

the second is by using object->method( )

Whenever possible (ie. the parameters are only of Returning and Importing type) I prefer the second method a lot because it's more compact and Java-style.

Now I've faced the problem of getting the value of a context attribute.

Can you explain to me why this piece of code works:

  DATA lo_nd_view_settings TYPE REF TO if_wd_context_node.
  DATA lo_el_view_settings TYPE REF TO if_wd_context_element.
  lo_nd_view_settings = wd_context->get_child_node( name = wd_this->wdctx_view_settings ).
  lo_el_view_settings = lo_nd_view_settings->get_element( ).

and this, instead, it doesn't work:

  DATA lo_nd_view_settings TYPE REF TO if_wd_context_node.
  lo_nd_view_settings = wd_context->get_child_node( name = wd_this->wdctx_view_settings )->get_element( ).

I get this error:

Web Dynpro Comp. / Intf. ZPM_TEST_ABAP_WDP,Web Dynpro View MAIN 11 @0A\QError@

"= ..." expected after ")->GET_ELEMENT("

I mean, get_child_node returns an IF_WD_CONTEXT_NODE type object who has the method GET_ELEMENT.

So why it doesn't work?

Thank you,

Pietro