‎2017 Jul 25 3:08 PM
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.
Can some help me understand the concept behind this?
‎2017 Jul 25 3:41 PM
This type of method call is called a 'Functional Method' and as such can be used directly in assignments, conditions etc etc. It cannot be used for example as an argument to a function module.
There is nothing strange about things happening behind the scenes - it's a parameter with a 'Returning' rather than a 'Changing' or 'Exporting' type.
You would define it in a local class something like:
Close_Notification Final
Importing i_Notif_No Type Notification_Number
Returning Value(r_State) Type Notification_State,
And specify it in SE80 basically the same way.
‎2017 Jul 25 5:27 PM
"It cannot be used for example as an argument to a function module."
Yes it can.
‎2017 Jul 25 5:36 PM
Is that "yes it can, now", or "yes it can and it's been possible since 46c"? 😉
‎2017 Jul 25 5:40 PM
‎2017 Jul 26 7:51 AM
Our system chokes:

So I think Matt nailed it. I was going to query it but I thought I'd wait till I got on a system....
‎2017 Jul 25 3:48 PM
‎2017 Jul 25 4:12 PM
‎2017 Jul 27 9:14 AM
Your statement
"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"."
is not true.
Method "get_columns" of the instance ALV returns a parameter of type REF TO CL_SALV_COLUMNS_TABLE.
Your Question: