‎2008 Jun 11 7:30 AM
hi, All.
can anyone help me out by explaining me the difference between RETURNING VALUE and EXPORTING in the abap objects.....
Regards
Preetesh
‎2008 Jun 11 8:55 PM
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
‎2008 Jun 11 7:40 AM
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.
‎2008 Jun 11 7:57 AM
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
‎2008 Jun 11 9:42 AM
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
‎2008 Jun 11 12:36 PM
thanx 4 the reply .....
but still i didn't understand where to use the RETURNING VALUE and where EXPORTING....
Regards.
Preetesh
‎2008 Jun 11 8:55 PM
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
‎2008 Jun 12 7:32 AM
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