Method chaining

Jul 25, 2017 at 02:08 PM|179 Views

Got a simple question on method chaining. I understand this is not a new topic and there are several threads showing examples on how to chain methods but there seems to be a small thing that makes understanding of this concept a little difficult.

I am using the class CL_SALV_TABLE where in the variable ALV is an instance of the class CL_SALV_TABLE.

While chaining, we use the below code.

alv->get_columns( )->set_optimize( ).

Now the method "get_columns" of the instance ALV returns a parameter of type CL_SALV_COLUMNS_TABLE thru which we call the method "set_optimize".

Question -> for the method call "get_columns" the returning parameter is NOT OPTIONAL. So what exactly happens behind the scenes which allow us to skip the helper variable? The instance of the variable ALV and the return parameter of the method "get_columns" are not of the object.