‎2007 Jul 30 10:50 AM
Hi all,
Can anybody tell me what is difference between Call by reference and Changing parameters.
good help will be rewarded
Sachin.
‎2007 Jul 30 1:01 PM
HI SACHIN
<b>keep trying but please dont forget :):):):)</b>
<b>and <b>one more thing to clear ur doubt</b>. you change the values of p_num1 and p_num2 in form endform. u see the value of num1 and num2 gets chenged which wont happen at all if it is pass by value . so its clear that its pass by reference.</b>
EXAMPLE
DATA: num1 TYPE i,
num2 TYPE i,
sum TYPE i.
num1 = 2. num2 = 4. sum = 0.
PERFORM expRef USING num1 num2.
write: / num1 , num2.
FORM expRef using p_num1 p_num2.
data: add_sum type i.
add_sum = p_num1 + p_num2.
p_num1 = 3.
p_num2 = 5.
write: / 'Sum is:',add_sum.
ENDFORM.
regards
vijay
‎2007 Jul 30 10:55 AM
hi sachin
<b>Call by reference</b>: actaul parameters are passed, no formal parameters exist.
<b>Changing parameters</b>: pass by value, actaul parameters are passed to formal parameters , temporary memeory allocated to formal parameters
please <b>Go thru this link it will help you a lot.</b>
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db984635c111d1829f0000e829fbfe/content.htm
regards
vijay
<b>plz dont forget to reward if useful</b>
‎2007 Jul 30 11:02 AM
TRY this as it is giving error bcoz of no ACTUAL parameters.
Pls correct me if i am wrong.
DATA: num1 TYPE i,
num2 TYPE i,
sum TYPE i.
num1 = 2. num2 = 4. sum = 0.
PERFORM expRef USING num1 num2.
FORM expRef.
data: add_sum type i.
add_sum = num1 + num2.
write: / 'Sum is:',add_sum.
ENDFORM
‎2007 Jul 30 11:07 AM
hi sachin
here is ur correct code
DATA: num1 TYPE i,
num2 TYPE i,
sum TYPE i.
num1 = 2. num2 = 4. sum = 0.
PERFORM expRef USING num1 num2.
FORM expRef using p_num1 p_num2.
data: add_sum type i.
add_sum = p_num1 + p_num2.
write: / 'Sum is:',add_sum.
ENDFORM.
regards
vijay
<b>plz dont forget to reward points if helpful</b>
‎2007 Jul 30 11:17 AM
Hi vijay,
That means in pass by reference we need to send formal parameters.
sachin
‎2007 Jul 30 11:20 AM
hi sachin
<b>no its not like that. in pass by reference the address of the variables are copied not the value . in this example the address of these varables num1 and num2 gets copied to
p_num1 and p_num2. thatswhy it is pass by reference</b>
hope it clears ur doubt
regards
vijay
<b>plz dont forget to reward points if useful</b>
‎2007 Jul 30 11:39 AM
‎2007 Jul 30 12:57 PM
Hi Vijay,
I am not been able to reward points. SDN is giving error while assigning.
Sachin
‎2007 Jul 30 1:01 PM
HI SACHIN
<b>keep trying but please dont forget :):):):)</b>
<b>and <b>one more thing to clear ur doubt</b>. you change the values of p_num1 and p_num2 in form endform. u see the value of num1 and num2 gets chenged which wont happen at all if it is pass by value . so its clear that its pass by reference.</b>
EXAMPLE
DATA: num1 TYPE i,
num2 TYPE i,
sum TYPE i.
num1 = 2. num2 = 4. sum = 0.
PERFORM expRef USING num1 num2.
write: / num1 , num2.
FORM expRef using p_num1 p_num2.
data: add_sum type i.
add_sum = p_num1 + p_num2.
p_num1 = 3.
p_num2 = 5.
write: / 'Sum is:',add_sum.
ENDFORM.
regards
vijay
‎2007 Jul 30 1:10 PM