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

RETURNING VALUE and EXPORTING

Former Member
32,964

hi, All.

can anyone help me out by explaining me the difference between RETURNING VALUE and EXPORTING in the abap objects.....

Regards

Preetesh

1 ACCEPTED SOLUTION
Read only

12,121

Basically, it depends on the situation and your personal taste. As swetha stated, several restrictions apply when using RETURN VALUE (the most important: only one return parameter allowed). However, it might be used for more convenient programming, as Uwe supposes. E.g., checking a boolean value with Exporting would look like this:

object->method( IMPORTING value = boolvar ).

IF boolvar eq 'X' ...

whereas a functional call would look like

IF object->method( ) eq 'X'

You might now also understand, why a method could only have one return value.

Best regards

Enrico

6 REPLIES 6
Read only

Former Member
12,121

Hi,

To get some values from a method , one can use the EXPORTING, CHANGING or RETURNING parameters.

If one uses RETURNING parameters, the following restrictions apply:-

(1) No EXPORTING/CHANGING parameters can be used for the method.

(2) Only one RETURNING parameter can be used.

(3) RETURNING parameters are only passed by value.

Reward if useful.

Regards,

Swetha.

Read only

uwe_schieferstein
Active Contributor
0 Likes
12,121

Hello Pretesh

Methods having a RETURNING parameter are like Java class methods which have a single returning value as well.

In addition, you can use so-called functional method calls, .e.g.:

CALL METHOD cf_reca_message_list=>create
  RETURNING
    ro_instance = go_msglist.

" OR function method call:
  go_msglist = cf_reca_message_list=>create( ).

Regards

Uwe

Read only

Former Member
0 Likes
12,121

Methods that have a RETURNING parameter are described as functional methods

This means that they can have neither an EXPORTING nor a CHANGING

parameter. The RETURNING parameter must always be passed using the VALUE

addition, that is, passed by value.

Functional methods can be called directly within various expressions:

• Logical expressions: IF, ELSEIF, WHILE, CHECK, WAIT

• Case conditions: CASE, WHEN

• Arithmetic expressions and bit expressions: COMPUTE

• Sources of values as a local copy: MOVE

• Search clauses for internal tables, assuming that the operand is not a

component of the table row: LOOP AT ... WHERE

Read only

Former Member
0 Likes
12,121

thanx 4 the reply .....

but still i didn't understand where to use the RETURNING VALUE and where EXPORTING....

Regards.

Preetesh

Read only

12,122

Basically, it depends on the situation and your personal taste. As swetha stated, several restrictions apply when using RETURN VALUE (the most important: only one return parameter allowed). However, it might be used for more convenient programming, as Uwe supposes. E.g., checking a boolean value with Exporting would look like this:

object->method( IMPORTING value = boolvar ).

IF boolvar eq 'X' ...

whereas a functional call would look like

IF object->method( ) eq 'X'

You might now also understand, why a method could only have one return value.

Best regards

Enrico

Read only

Former Member
0 Likes
12,121

Hi There,

Basiaclly speaking, if you look at the constructor of a class, it generally returns the object of the class. You cannot have a exporting parameters. So exporting is generally used if you need to retun more than one value.

In general a method of a class can either use an exporting or returning parameter. It depends on how the developer wants to use it. There are certain restrictions that one should be aware about before making use of the returning.

For eg. If one uses returning parameter, both changing/exporting cannot be used.

I hope this clarifies your doubt.

Regards,

Saurabh