Welcome To My BLOG

This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me

Share this link with your friends

http://www.rebtel.com/u/15163104576

For every friend who signs up using this link and makes a payment, we'll give you 8 €!


Monday, December 13, 2010

OOPS:Use of RETURNING parameters in method

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.

This program demonstrates the use of RETURNING parameters and the various ways to call a method with RETURNING parameter to get the value into some variable.
-------------------------------------------------------------------------------------------
report ysubdel1 message-id 00.

data : w_num type i.

class c1 definition .
public section.
methods : m1 importing input1 type i
input2 type i
returning value(result) type i .
endclass.

class c1 implementation.
method : m1.
result = input1 * 2 + input2.
endmethod.
endclass.

start-of-selection.
data : obj1 type ref to c1 .
create object obj1.
* Syntax 1
call method obj1->m1 EXPORTING input1 = 5
input2 = 4
RECEIVING result = w_num.
write:/5 w_num .
* Syntax 2
w_num = obj1->m1( input1 = 10 input2 = 20 ).
write:/5 w_num .
* Syntax 3
move obj1->m1( input1 = 2 input2 = 3 ) to w_num .
write:/5 w_num .

Output 14
40
7

No comments: