‎2007 Jul 17 8:19 AM
what is the exact difference between pass by value and pass by reference particularly regaring subroutines,methods,function modules what will we do
‎2007 Jul 17 8:23 AM
if you pass the parameters (formal paramters) by value, whatever the changes done to them inside the method or subroutine will not reflect back. but if you pass by reference the changes done inside method or subroutine will reflect back.
REPORT z_grs_pass_by_value .
DATA: i1 TYPE i, i2 TYPE i, i3 type i.
i1 = 10.
i2 = 20.
i3 = 30.
WRITE: / 'Before calling Subrouting'.
WRITE: / i1, i2, i3.
PERFORM pass USING i1 i2 CHANGING i3.
WRITE: / 'After calling Subrouting'.
WRITE: / i1, i2, i3.
&----
*& Form pass
&----
text
----
-->P_I1 text
-->P_I2 text
----
FORM pass USING p_i1
value(p_i2)
p_i3.
p_i1 = 11.
p_i2 = 12.
p_i3 = 13.
WRITE: / 'Inside Subrouting'.
WRITE: / p_i1, p_i2, p_i3.
ENDFORM. " pass
OUTPUT:
-
Before calling Subrouting
10 20 30
Inside Subrouting
11 12 13
After calling Subrouting
11 20 13
Message was edited by:
raghav sharma
‎2007 Jul 17 8:21 AM
hi,
For pass-by-value u will directly pass the value and for Pass-by-reference u need to pass a reference variable for that particular variable.
‎2007 Jul 17 8:22 AM
Hi
In Pass-By-Value : Values of actual parameters will be passed to formal parameters.
Pass-By-Reference : Copy of values of actual parameters will be passed to formal parameters.
Regards,
Sree
‎2007 Jul 17 8:23 AM
if you pass the parameters (formal paramters) by value, whatever the changes done to them inside the method or subroutine will not reflect back. but if you pass by reference the changes done inside method or subroutine will reflect back.
REPORT z_grs_pass_by_value .
DATA: i1 TYPE i, i2 TYPE i, i3 type i.
i1 = 10.
i2 = 20.
i3 = 30.
WRITE: / 'Before calling Subrouting'.
WRITE: / i1, i2, i3.
PERFORM pass USING i1 i2 CHANGING i3.
WRITE: / 'After calling Subrouting'.
WRITE: / i1, i2, i3.
&----
*& Form pass
&----
text
----
-->P_I1 text
-->P_I2 text
----
FORM pass USING p_i1
value(p_i2)
p_i3.
p_i1 = 11.
p_i2 = 12.
p_i3 = 13.
WRITE: / 'Inside Subrouting'.
WRITE: / p_i1, p_i2, p_i3.
ENDFORM. " pass
OUTPUT:
-
Before calling Subrouting
10 20 30
Inside Subrouting
11 12 13
After calling Subrouting
11 20 13
Message was edited by:
raghav sharma