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

pass by value vs pass by reference

Former Member
0 Likes
6,022

hey,

what difference makes if I pass the parameter by value vs pass by reference.

thanks.

- deepan

Edited by: Deepan Gunalan on Feb 13, 2008 10:57 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,052

Pass by reference:

A way of passing data from actual parameters to formal parameters. When you pass by reference, no local data object is specified for the actual parameter, but the procedure receives a reference to the actual parameter during call and works with the actual parameter itself. A change to the formal parameter in the subroutine also changes the value of the actual parameter.

Pass by value:

a local object with the same data type as the corresponding actual parameter is created in the subroutine and filled with its values. A change to the formal parameter in the subroutine does not change the value of the actual parameter. The actual parameter also retains its original value even after the subroutine has ended.

Check this thread for sample program to understand better

3 REPLIES 3
Read only

former_member156446
Active Contributor
0 Likes
1,052

Actual parameters can be any data objects or field symbols of the calling program whose technical attributes are compatible with the type specified for the corresponding formal parameter. When you specify the actual parameters, note that those you pass by reference to a formal parameter and those you pass by value to an output parameter can be changed by the subroutine. You should therefore ensure that only data objects that you want to be changed appear in the corresponding position of the actual parameter list.

ref:http://help.sap.com/saphelp_nw70/helpdata/en/9f/db979d35c111d1829f0000e829fbfe/content.htm

Read only

Former Member
0 Likes
1,053

Pass by reference:

A way of passing data from actual parameters to formal parameters. When you pass by reference, no local data object is specified for the actual parameter, but the procedure receives a reference to the actual parameter during call and works with the actual parameter itself. A change to the formal parameter in the subroutine also changes the value of the actual parameter.

Pass by value:

a local object with the same data type as the corresponding actual parameter is created in the subroutine and filled with its values. A change to the formal parameter in the subroutine does not change the value of the actual parameter. The actual parameter also retains its original value even after the subroutine has ended.

Check this thread for sample program to understand better