2016 May 05 7:55 AM
hi folks,
i saw in some of the SCN threads regarding RETURNING parameter in methods .like below
Regarding Returning Parameter and Static method | SCN
in that while RETURNING parameter in method deceleration, we should not use EXPORTING and CHANGING parameters in that
but
in a local method creation i am using EXPORTING and CHANGING parameters including with RETURNING parameter
but i didn't get any error message.
program is executing fine
what exactly the concept of RETURNING parameters
2016 May 05 8:21 AM
I guess you are using ABAP Release >= 740 SP02 because since ABAP 740 SP02 you can use EXPORTING/CHANGING params together with RETURNING params. (Read - ABAP Objects in Release 7.40, SP02 - ABAP Keyword Documentation)
2016 May 05 8:21 AM
I guess you are using ABAP Release >= 740 SP02 because since ABAP 740 SP02 you can use EXPORTING/CHANGING params together with RETURNING params. (Read - ABAP Objects in Release 7.40, SP02 - ABAP Keyword Documentation)
2016 May 05 8:23 AM
a RETURNING parameter is essential to write concise code. You may write statements like:
result = math->square_root( '15.24' ).
IF math->square_root( number ) = 4.Imagine how long the corresponding code would be with EXPORTING/CHANGING.
2016 May 05 8:28 AM
Hi,
The threads are pretty old. If you are getting no error in syntax then it's not an issue.
But it's upto you how you design. Returning though has more contextual meaning in terms that you would expect some object (variable/workarea/structure) would be updated as output based on certain input conditions.
If I have an exporting parameter or multiple exporting parameters, I would not use returning or changing while If i want to have a value updated based on certain (read only) parameters, returning is obvious here.
Also, one important difference between Returning and Exporting is you need to use fully defined types in ABAP dictionary for Returning variables. By 'Fully Defined Types' i mean, the TYPE should exist in ABAP dictionary.
Thanks,
VS
2016 May 05 10:50 AM
... and here my 2 cents:
- a RETURNING parameter must be fully typed BUT the result may be moved to any other compatible simple type. Quite frequently the TYPE of an EXPORTING parameter causes trouble when the function or method is re-used because you are forced to us this type. A returned STRING can be assigned to any kind of character variable, a returned INT4 can be assigned to any kind of numeric variable.
- functional methods (a.k.a methods with RETURN parameter) can be used in method chaining. That means whereever a parameter value is expected, you can place a functional method call.
i.e.
VAR myvalue TYPE CURR09 value '3.14-'.
myvalue = floor( abs( myvalue ) ). "Result is 3.00
Regards Clemens