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

Call by reference and Changing

Former Member
0 Likes
846

Hi all,

Can anybody tell me what is difference between Call by reference and Changing parameters.

good help will be rewarded

Sachin.

1 ACCEPTED SOLUTION
Read only

Vijay
Active Contributor
0 Likes
821

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

9 REPLIES 9
Read only

Vijay
Active Contributor
0 Likes
821

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>

Read only

Former Member
0 Likes
821

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

Read only

Vijay
Active Contributor
0 Likes
821

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>

Read only

Former Member
0 Likes
821

Hi vijay,

That means in pass by reference we need to send formal parameters.

sachin

Read only

Vijay
Active Contributor
0 Likes
821

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>

Read only

Vijay
Active Contributor
0 Likes
821

hi sachin

is there any problem.

please close the thread if answered and reward points accordingly.

Read only

Former Member
0 Likes
821

Hi Vijay,

I am not been able to reward points. SDN is giving error while assigning.

Sachin

Read only

Vijay
Active Contributor
0 Likes
822

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

Read only

Vijay
Active Contributor
0 Likes
821

hi

i guess there are 3 options while assigning points

thnx anyways..