Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

while returning parameters even tho i am using changing parameters

Balu483
Participant
0 Likes
2,967

hi folks,

i saw in some of the SCN threads regarding RETURNING parameter in methods .like below

Regarding Returning Parameter and Static method | SCN

ABAP Keyword Documentation

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

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,718

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)

4 REPLIES 4
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,719

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)

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,718

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.

Read only

Former Member
0 Likes
1,718

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

Read only

0 Likes
1,718

... 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