2017 Feb 15 9:26 PM
Is it possible to chain objects together in a call in the following manner?
I have a class cl_msg with a static method construct_bapiret2.
I have an object cl_salesdoc with an attribute mo_msg which is type ref cl_msg.
In the constructor of cl_salesdoc, I:
create object mo_msg.
Sometimes, I can do this:
data: lo_salesdoc type ref to cl_salesdoc.
lo_salesdoc->mo_msg=>construct_bapiret2( )
and sometimes, I get an error.
I feel like I'm not supposed to chain objects together like this?
2017 Feb 15 9:48 PM
Hi!
A static method is always called on the class itself. So in your case cl_msg=>construct_bapiret2( ) will work but your atttribute mo_msg is an object and therefore a static method can not be used.
Regarding method chaining. You can apply an instance method after a static method but not vice versa.
hope it helps, Andreas
2017 Feb 15 9:48 PM
Hi!
A static method is always called on the class itself. So in your case cl_msg=>construct_bapiret2( ) will work but your atttribute mo_msg is an object and therefore a static method can not be used.
Regarding method chaining. You can apply an instance method after a static method but not vice versa.
hope it helps, Andreas